docs(console): document cost and allowance in inference responses (#58660)

This commit is contained in:
Adam
2026-10-24 03:54:51 -05:00
committed by GitHub
Unverified
parent 1873fbe304
commit f20760b8bf
2 changed files with 34 additions and 1 deletions
@@ -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.
+2 -1
View File
@@ -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.