Estimate workflow credits
curl --request POST \
--url https://api.magica.com/api/v1/workflows/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/workflows/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/workflows/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/workflows/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/workflows/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/workflows/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/workflows/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{
"totalMicrocredits": 123,
"estimates": [
{
"microcredits": 123
}
]
}Workflows
Estimate workflow credits
Total microcredit estimate for a workflow, plus a per-node breakdown.
POST
/
v1
/
workflows
/
estimate-credits
Estimate workflow credits
curl --request POST \
--url https://api.magica.com/api/v1/workflows/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/workflows/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/workflows/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/workflows/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/workflows/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/workflows/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/workflows/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{
"totalMicrocredits": 123,
"estimates": [
{
"microcredits": 123
}
]
}Returns the total microcredit cost of a workflow run, along with a per-node breakdown so you can render the same number on a workflow summary and on individual node cards.
Uses the same pricing engine as
POST /v1/nodes/estimate-credits — the
response guarantees totalMicrocredits === sum(estimates[].microcredits) by
construction.Authorizations
string
required
Bearer API key. Format:
Bearer gx_your_api_key.Body
array
required
Array of node configurations that make up the workflow. Capped at the
per-workflow node limit enforced by the workflow editor.
Response
number
Total cost of running the whole workflow. Equals the sum of
estimates[].microcredits.array
Per-node breakdown, in input order.
Show Each estimate
Show Each estimate
number
Cost contributed by that node, in microcredits.
Request
- cURL
- Node.js
- Python
curl -X POST https://api.magica.com/api/v1/workflows/estimate-credits \
-H "Authorization: Bearer $MAGICA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"nodes": [
{ "type": "flux_2_pro", "data": { "prompt": "A red Ferrari" } },
{ "type": "gpt_5_4", "data": { "prompt": "Describe this" } }
]
}'
const res = await fetch(
"https://api.magica.com/api/v1/workflows/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 { totalMicrocredits, estimates } = await res.json();
import os, requests
res = requests.post(
"https://api.magica.com/api/v1/workflows/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"}},
]
},
)
payload = res.json()
print(payload["totalMicrocredits"], payload["estimates"])
Response example
{
"totalMicrocredits": 3700000,
"estimates": [{ "microcredits": 2500000 }, { "microcredits": 1200000 }]
}
Errors
| Status | Reason |
|---|---|
400 | Invalid body, exceeds max nodes per workflow, or unparseable JSON |
401 | Missing or invalid API key |
500 | Pricing engine failure |
Was this page helpful?
⌘I