Relay docs

Cost

Estimate spend before you make calls, and read the catalog's pricing. Both endpoints need only a valid key — no scope.

#Pricing catalog

GET /v1/pricing — per-model rates from the catalog: input/output cost per 1M tokens, context window, and max output tokens. It lists every enabled model in the catalog, unlike GET /v1/models, which is narrowed to the key's workspace and allow-list.

{ "object": "list", "data": [
  { "model": "gpt-4o", "input_cost_per_1m": 5.00, "output_cost_per_1m": 15.00, "context_window": 128000, "max_output_tokens": 16384 }
] }

#Simulate a cost

POST /v1/cost/simulate — estimate USD from token counts, or from sample text (a ~4-characters-per-token heuristic), optionally multiplied over many calls.

FieldMeaning
modelPublic alias. Required; an unknown one returns 404 model_not_found.
promptTokens, completionTokensToken counts, when you know them.
input, outputSample prompt / sample answer text, used to estimate the count a field above does not supply.
requestsMultiply the single-call cost by this many calls (default 1).

The two token-count fields are read in camelCase, as written above — the snake_case spelling other endpoints use is not recognised here and is silently ignored, which makes the estimate fall back to the sample text (or to zero).

{ "model": "gpt-4o", "promptTokens": 1200, "completionTokens": 400 }

or

{ "model": "gpt-4o", "input": "…a long prompt…", "output": "…a typical answer…", "requests": 1000 }

Response:

{
  "model": "gpt-4o",
  "prompt_tokens": 1200, "completion_tokens": 400, "estimated": false,
  "input_cost_usd": 0.006, "output_cost_usd": 0.006, "cost_per_call_usd": 0.012,
  "requests": 1, "total_cost_usd": 0.012
}

estimated is true when either count came from sample text. The simulator prices every prompt token at the full input rate; it does not model prompt caching or the cached-input rate.

#Where cost shows up

  • Non-streaming chat completions (including agent runs and /v1/responses) carry an X-Relay-Cost-Usd header — 0 on a cache hit or an idempotent replay. Streamed and embeddings calls record cost in telemetry only, because the usage is not known when the headers go out.
  • Every generation records its cost in telemetry, attributed per workspace / app (API key) / model / provider / end user / agent / prompt version. Cached prompt tokens are priced at the model's cached-input rate when one is set.
  • The panel's Cost page shows actual spend from telemetry and wraps /v1/cost/simulate; the Dashboard and Telemetry pages show real spend; Budgets enforce caps. See Telemetry & dashboards.