CumulusDocs
Open Studio
On this page

Get run usage and cost

Read measured usage, pricing and completeness for one run.

Operation ID: runs.usage.

Request

GET /api/v1/runs/{run_id}/usage

  • TypeScript SDK: client.runs.usage (path arguments use path).
  • MCP tool: sdk_client_call with operationId: "runs.usage" (path arguments use input.path). Legacy alias: runs_usage. Connect to your authenticated /mcp endpoint with an API key for the same environment.
  • Minimum API key role: viewer.
  • Idempotency: No idempotency header required.

Read resource IDs from earlier responses and use a key for the same environment.

Request example

Set each path variable to an ID returned by an earlier API request.

Set CUMULUS_BASE_URL to your workspace API URL and CUMULUS_API_KEY to a key for that environment. Example values are synthetic.

cURL

curl
curl --fail-with-body -sS "${CUMULUS_BASE_URL%/}/api/v1/runs/${RUN_ID}/usage" \
  -H "Authorization: Bearer $CUMULUS_API_KEY"

TypeScript

typescript
import { Cumulus } from "@cumulus/sdk";

const baseUrl = process.env.CUMULUS_BASE_URL;
const apiKey = process.env.CUMULUS_API_KEY;
if (!baseUrl || !apiKey) throw new Error("Set CUMULUS_BASE_URL and CUMULUS_API_KEY");
const client = new Cumulus({ baseUrl, apiKey });

const response = await client.runs.usage({
  "path": {
    "run_id": "<run_id>"
  }
});

Input schema

Path, query and header parameters

run_id

path parameter · Required.

Type: string (uuid). pattern: ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$.

JSON request body

This operation has no JSON request body.

Complete OpenAPI schema
OpenAPI JSON
{
  "parameters": [
    {
      "name": "run_id",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string",
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$"
      }
    }
  ],
  "requestBody": null
}

Responses

HTTP 200

Read metered usage and cost of one run

application/json

FieldType or valuesRequiredDescription and limits
run_idstring (uuid)RequiredRun identifier returned when the run was admitted. pattern: ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$.
connected_msinteger or nullRequiredAt least 0. At most 9007199254740991.
llm_input_tokensinteger or nullRequiredAt least 0. At most 9007199254740991.
llm_output_tokensinteger or nullRequiredAt least 0. At most 9007199254740991.
stt_msinteger or nullRequiredAt least 0. At most 9007199254740991.
tts_charactersinteger or nullRequiredAt least 0. At most 9007199254740991.
measurementsintegerRequiredAt least 0. At most 9007199254740991.
costobjectRequired—
cost.currency"USD"Required—
cost.amountstring or nullRequiredpattern: ^(0|[1-9][0-9]*)(.[0-9]{1,12})?$.
cost.completeness"complete" · "partial" · "unpriced"Required—

Error responses

HTTPDescription
4XXTyped error (ApiError)
5XXTyped error (ApiError)

Errors use the shared error envelope. Inspect error.code, retryable, outcome and details before retrying.

Complete OpenAPI schema
OpenAPI JSON
{
  "200": {
    "description": "Read metered usage and cost of one run",
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/RunsUsageResponse200"
        }
      }
    }
  },
  "4XX": {
    "description": "Typed error (ApiError)",
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/ApiError"
        }
      }
    }
  },
  "5XX": {
    "description": "Typed error (ApiError)",
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/ApiError"
        }
      }
    }
  }
}

Referenced schemas

Expand the complete OpenAPI definitions for integrations that generate their own clients.

Complete OpenAPI schema
OpenAPI JSON
{
  "components": {
    "schemas": {
      "RunsUsageResponse200": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$"
          },
          "connected_ms": {
            "nullable": true,
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "llm_input_tokens": {
            "nullable": true,
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "llm_output_tokens": {
            "nullable": true,
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "stt_ms": {
            "nullable": true,
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "tts_characters": {
            "nullable": true,
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "measurements": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "cost": {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string",
                "enum": [
                  "USD"
                ]
              },
              "amount": {
                "nullable": true,
                "type": "string",
                "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]{1,12})?$"
              },
              "completeness": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial",
                  "unpriced"
                ]
              }
            },
            "required": [
              "currency",
              "amount",
              "completeness"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "run_id",
          "connected_ms",
          "llm_input_tokens",
          "llm_output_tokens",
          "stt_ms",
          "tts_characters",
          "measurements",
          "cost"
        ],
        "additionalProperties": false
      },
      "ApiError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "unauthenticated",
                  "forbidden",
                  "not_found",
                  "conflict",
                  "invalid_request",
                  "idempotency_conflict",
                  "policy_denied",
                  "capability_unavailable",
                  "provider_unavailable",
                  "knowledge_unavailable",
                  "publication_invalid",
                  "run_not_active",
                  "rate_limited",
                  "outcome_unknown",
                  "internal"
                ]
              },
              "message": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean"
              },
              "outcome": {
                "type": "string",
                "enum": [
                  "none",
                  "unknown"
                ]
              },
              "details": {
                "type": "object",
                "additionalProperties": {}
              }
            },
            "required": [
              "code",
              "message",
              "retryable",
              "outcome"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      }
    }
  }
}

Errors and recovery

See API error handling and Troubleshooting.

Content version 21cdf473Customer SDKMarkdown source
Get run usage and cost · Cumulus developer docs