> ## Documentation Index
> Fetch the complete documentation index at: https://magica.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Estimate workflow credits

> Total microcredit estimate for a workflow, plus a per-node breakdown.

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.

<Info>
  Uses the same pricing engine as [`POST
      /v1/nodes/estimate-credits`](/api-reference/nodes/estimate-credits) — the
  response guarantees `totalMicrocredits === sum(estimates[].microcredits)` by
  construction.
</Info>

## Authorizations

<ParamField header="Authorization" type="string" required>
  Bearer API key. Format: `Bearer gx_your_api_key`.
</ParamField>

## Body

<ParamField body="nodes" type="array" required>
  Array of node configurations that make up the workflow. Capped at the
  per-workflow node limit enforced by the workflow editor.

  <Expandable title="Each node">
    <ParamField body="type" type="string" required>
      Node type identifier (e.g. `flux_2_pro`, `nano_banana_pro`, `gpt_5_4`).
    </ParamField>

    <ParamField body="data" type="object">
      Input values for the node, keyed by input field name.
    </ParamField>

    <ParamField body="subModelId" type="string">
      Active sub-model identifier for multi-mode nodes.
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="totalMicrocredits" type="number">
  Total cost of running the whole workflow. Equals the sum of
  `estimates[].microcredits`.
</ResponseField>

<ResponseField name="estimates" type="array">
  Per-node breakdown, in input order.

  <Expandable title="Each estimate">
    <ResponseField name="microcredits" type="number">
      Cost contributed by that node, in microcredits.
    </ResponseField>
  </Expandable>
</ResponseField>

## Request

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    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" } }
        ]
      }'
    ```
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    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();
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    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"])
    ```
  </Tab>
</Tabs>

## Response example

```json theme={null}
{
  "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                                            |
