From 05bd8dd00e8274981e71077e16ccf55fb7e1da9c Mon Sep 17 00:00:00 2001 From: Hamza Date: Wed, 4 Mar 2026 18:59:00 +0900 Subject: [PATCH] feat: add `cost` and `cost_details` to ChatGenerationTokenUsage schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The OpenRouter API returns `cost`, `is_byok`, and `cost_details` in the `usage` object of chat completion responses, but the OpenAPI spec doesn't define these fields. This causes them to be silently dropped during deserialization. Adds the following optional/nullable fields to ChatGenerationTokenUsage: - `cost` (number) — total generation cost in USD - `is_byok` (boolean) — whether the request used bring-your-own-key - `cost_details` (object) — breakdown with upstream_inference_cost, upstream_inference_prompt_cost, upstream_inference_completions_cost Fixes #65 --- .speakeasy/in.openapi.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.speakeasy/in.openapi.yaml b/.speakeasy/in.openapi.yaml index 58e595c..8aec409 100644 --- a/.speakeasy/in.openapi.yaml +++ b/.speakeasy/in.openapi.yaml @@ -7909,6 +7909,31 @@ components: type: number description: Video input tokens description: Detailed prompt token usage + cost: + type: number + nullable: true + description: Total cost of the generation in USD + is_byok: + type: boolean + nullable: true + description: Whether the request used a bring-your-own-key provider + cost_details: + type: object + nullable: true + properties: + upstream_inference_cost: + type: number + nullable: true + description: Total upstream inference cost in USD + upstream_inference_prompt_cost: + type: number + nullable: true + description: Upstream inference cost for prompt tokens in USD + upstream_inference_completions_cost: + type: number + nullable: true + description: Upstream inference cost for completion tokens in USD + description: Breakdown of generation cost required: - completion_tokens - prompt_tokens