中继 API: generation
本页由 docs-site/openapi/relay.yaml 生成,内容为英文,请勿手工修改。
Look up what one request cost.
GET /v1/generation
Section titled “GET /v1/generation”Cost and usage of one request
operationId relayGetGeneration · auth: bearerAuth or apiKeyHeader or googApiKeyHeader or googApiKeyQuery
id is the X-Request-Id of an earlier relay response (or the id in a console request
log). Only requests of your own organisation are visible. The record is written when the
request settles, which is normally within a second; a 404 right after the response can
mean it has not settled yet, so retry briefly.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id |
query | string<uuid> | yes |
| Status | Meaning | Body |
|---|---|---|
| 200 | The generation. | application/json object |
| 404 | Error in the OpenAI envelope (error.message, error.type, error.param, error.code). |
application/json OpenAIError |
| default | Error in the OpenAI envelope (error.message, error.type, error.param, error.code). |
application/json OpenAIError |
Response 200 application/json — object
data(Generation)id(string) model(string)provider(string) — Provider tag of the channel that served the request.operation(string)streamed(boolean)status(“success” | “partial” | “client_error” | “upstream_error” | “canceled”)finish_reason(string)created_at(string) total_cost(number) — USD chargedtotal_cost_nano(string) — The same amount as an integer string of nano-USD.list_cost(number) — USD at list pricediscount_ppm(integer) — Discount in parts per million (1000000 = 100%).cost_details(array of CostLine)kind(“input” | “output” | “reasoning” | “cache_read” | “cache_write_5m” | “cache_write_1h” | “image_input” | “image_output” | “audio_input” | “audio_output” | “input_chars” | “audio_input_seconds” | “images” | “web_search” | “request”)quantity(integer) unit_price(integer) — List price in nano-USD (1e-9 USD) per unit.unit(“per_million” | “each” | “per_second”)amount(number) — USD charged for this line after discount.
attempts(integer)retries(integer)generation_time_ms(integer)ttft_ms(integer) — Time to first token; absent when unknown.usage_estimated(boolean) — true when the provider reported no usage and the gateway estimated it.price_version_id(string) api_key_id(string) usage(object) — Counters are disjoint (cached and reasoning tokens are not insideinput_tokens/output_tokens).input_tokens(integer)output_tokens(integer)reasoning_tokens(integer)cache_read_tokens(integer)cache_write_5m_tokens(integer)cache_write_1h_tokens(integer)image_input_tokens(integer)image_output_tokens(integer)audio_input_tokens(integer)audio_output_tokens(integer)input_chars(integer)audio_input_ms(integer)images(integer)web_search_calls(integer)total_tokens(integer)source(string)