Estimate node credits
curl --request POST \
--url https://api.magica.com/api/v1/nodes/estimate-credits \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"nodes": [
{
"type": "<string>",
"data": {},
"subModelId": "<string>"
}
]
}
'import requests
url = "https://api.magica.com/api/v1/nodes/estimate-credits"
payload = { "nodes": [
{
"type": "<string>",
"data": {},
"subModelId": "<string>"
}
] }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({nodes: [{type: '<string>', data: {}, subModelId: '<string>'}]})
};
fetch('https://api.magica.com/api/v1/nodes/estimate-credits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magica.com/api/v1/nodes/estimate-credits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'nodes' => [
[
'type' => '<string>',
'data' => [
],
'subModelId' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.magica.com/api/v1/nodes/estimate-credits"
payload := strings.NewReader("{\n \"nodes\": [\n {\n \"type\": \"<string>\",\n \"data\": {},\n \"subModelId\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.magica.com/api/v1/nodes/estimate-credits")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"nodes\": [\n {\n \"type\": \"<string>\",\n \"data\": {},\n \"subModelId\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magica.com/api/v1/nodes/estimate-credits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"nodes\": [\n {\n \"type\": \"<string>\",\n \"data\": {},\n \"subModelId\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"estimates": [
{
"microcredits": 123
}
]
}Nodes
Estimate node credits
Batch microcredit estimate for a list of nodes, against the inputs you’d actually run them with.
POST
/
v1
/
nodes
/
estimate-credits
Estimate node credits
curl --request POST \
--url https://api.magica.com/api/v1/nodes/estimate-credits \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"nodes": [
{
"type": "<string>",
"data": {},
"subModelId": "<string>"
}
]
}
'import requests
url = "https://api.magica.com/api/v1/nodes/estimate-credits"
payload = { "nodes": [
{
"type": "<string>",
"data": {},
"subModelId": "<string>"
}
] }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({nodes: [{type: '<string>', data: {}, subModelId: '<string>'}]})
};
fetch('https://api.magica.com/api/v1/nodes/estimate-credits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magica.com/api/v1/nodes/estimate-credits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'nodes' => [
[
'type' => '<string>',
'data' => [
],
'subModelId' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.magica.com/api/v1/nodes/estimate-credits"
payload := strings.NewReader("{\n \"nodes\": [\n {\n \"type\": \"<string>\",\n \"data\": {},\n \"subModelId\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.magica.com/api/v1/nodes/estimate-credits")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"nodes\": [\n {\n \"type\": \"<string>\",\n \"data\": {},\n \"subModelId\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magica.com/api/v1/nodes/estimate-credits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"nodes\": [\n {\n \"type\": \"<string>\",\n \"data\": {},\n \"subModelId\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"estimates": [
{
"microcredits": 123
}
]
}Returns a per-node microcredit estimate for an array of node configurations. Useful for surfacing live pricing in a UI (canvas card, playground form) before the user kicks off a run.
Pricing is computed by the same engine that charges credits at run time — this
endpoint mirrors the run-time cost exactly, without side effects. Pairs with
POST /v1/workflows/estimate-credits
via the invariant workflowEstimate.totalMicrocredits === sum(nodes[].microcredits).Authorizations
string
required
Bearer API key. Format:
Bearer gx_your_api_key.Body
array
required
Array of node configurations to estimate. Max 100 entries.
Show Each node
Show Each node
string
required
Node type identifier (e.g.
flux_2_pro, nano_banana_pro, gpt_5_4).object
Input values for the node, keyed by input field name. Pricing models may
use these to compute dynamic cost (duration, resolution, etc.).
string
Active sub-model identifier for multi-mode nodes (e.g.
image-to-image
mode of Nano Banana Pro). If omitted, the default sub-model is used.Response
array
One entry per request node, in input order.
Show Each estimate
Show Each estimate
number
Cost in microcredits. Divide by 1,000,000 to get credits.
Request
- cURL
- Node.js
- Python
curl -X POST https://api.magica.com/api/v1/nodes/estimate-credits \
-H "Authorization: Bearer $MAGICA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"nodes": [
{
"type": "flux_2_pro",
"data": { "prompt": "A red Ferrari", "image_size": "1024x1024" }
},
{
"type": "nano_banana_pro",
"data": { "prompt": "Add a dog" },
"subModelId": "image-to-image"
}
]
}'
const res = await fetch(
"https://api.magica.com/api/v1/nodes/estimate-credits",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MAGICA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
nodes: [
{ type: "flux_2_pro", data: { prompt: "A red Ferrari" } },
{ type: "gpt_5_4", data: { prompt: "Describe this" } },
],
}),
},
);
const { estimates } = await res.json();
import os, requests
res = requests.post(
"https://api.magica.com/api/v1/nodes/estimate-credits",
headers={
"Authorization": f"Bearer {os.environ['MAGICA_API_KEY']}",
"Content-Type": "application/json",
},
json={
"nodes": [
{"type": "flux_2_pro", "data": {"prompt": "A red Ferrari"}},
{"type": "gpt_5_4", "data": {"prompt": "Describe this"}},
]
},
)
estimates = res.json()["estimates"]
Response example
{
"estimates": [{ "microcredits": 2500000 }, { "microcredits": 1200000 }]
}
Errors
| Status | Reason |
|---|---|
400 | Invalid body, more than 100 nodes, or unparseable JSON |
401 | Missing or invalid API key |
500 | Pricing engine failure |
Was this page helpful?
⌘I