diff --git a/services/www/src/docs/content/console/api/inference.mdx b/services/www/src/docs/content/console/api/inference.mdx index e6d394167ef..f3302399231 100644 --- a/services/www/src/docs/content/console/api/inference.mdx +++ b/services/www/src/docs/content/console/api/inference.mdx @@ -98,3 +98,35 @@ curl -X POST "https://opencode.ai/inference/google/v1beta/models/gemini-4-argon: "contents": [{ "parts": [{ "text": "Say hi" }] }] }' ``` + +## Cost + +Every response reports what the request cost you, beside the usage its API already returns: in `usage` for OpenAI and +Anthropic, and in `usageMetadata` for Gemini. Streams report it on the event that carries the final usage: the final +usage chunk for Chat Completions with `stream_options.include_usage`, `response.completed` for Responses, +`message_delta` for Messages, and the last chunk for Gemini. + +```json +"usage": { + "prompt_tokens": 1200, + "completion_tokens": 300, + "cost": 0.00412, + "opencode": { + "billing_source": "balance", + "list_cost": 0.00412, + "tokens": { "input": 1200, "output": 300, "reasoning": 120, "cache_read": 8000, "cache_write_5m": 0, "cache_write_1h": 0 } + } +} +``` + +| Field | Meaning | +| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | +| `cost` | US dollars charged to your balance. `0` for free models and for [Go](/console/go) usage within its limits. Absent when the request used your own provider key. | +| `opencode.billing_source` | `free`, `balance`, `go`, `go-plus`, or `byok` (your own provider key). | +| `opencode.list_cost` | US dollars at the model's price, including peak hours and long-context pricing. | +| `opencode.allowance` | Go only: how much the request counted toward your [usage limits](/console/go#usage-limits), in dollars of the plan's monthly limit. | +| `opencode.tokens` | The tokens you were billed for. `input` excludes cache reads and writes; `output` includes `reasoning`. | + +Image generation reports the same fields on the response, and on each completed image of a stream with the cost so far. +The cost is known when the response ends, before your balance or Go usage is updated. If your balance or Go limits run +out during a request, you may be charged less than reported, never more. diff --git a/services/www/src/docs/content/console/go.mdx b/services/www/src/docs/content/console/go.mdx index 8b45a170b77..b711b874f64 100644 --- a/services/www/src/docs/content/console/go.mdx +++ b/services/www/src/docs/content/console/go.mdx @@ -134,7 +134,8 @@ the same for Go and Go Plus. Each model has the following usage limits: 5-hour — 20% of the monthly limit; weekly — 50%; and monthly — 100%. -Each model's monthly limit below determines how its usage counts toward those allowances. +Each model's monthly limit below determines how its usage counts toward those allowances. Each response reports how +much the request counted, as [`opencode.allowance`](/console/api/inference#cost). Token prices are per 1M tokens.