diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index f1ded117..518bd1a3 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,19 @@ lockVersion: 2.0.0 id: c48cf606-fb42-4a45-9c23-8f0555307828 management: - docChecksum: 83d0b70a137715a101f22c01da7386c4 + docChecksum: 8d13d68344724319b669bd0c8f91d05c docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 1.1.104 - configChecksum: e0c707e1d828398e7979a0220ee1c6a3 + releaseVersion: 1.1.105 + configChecksum: 21b0cd509283a2ff69d6da78244e41b4 repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: c1d5e9a3-a265-4a80-b18d-ac338da65b90 - pristine_commit_hash: f83c85e4e783d47f2203b7bbb362cf71227dc6bc - pristine_tree_hash: 356a96fd91edb952c5300f147822aa6d3a58b477 + generation_id: d8f3bcc6-0729-4b3f-99b3-1c483798c79b + pristine_commit_hash: 699531b76de97f08619d0bb672436dc7766f70a9 + pristine_tree_hash: 65f465e162ebe8c43550a6504f6fb1d0db768478 features: python: acceptHeaders: 3.0.0 @@ -1194,8 +1194,8 @@ trackedFiles: pristine_git_object: 48386287b072381a9b59de6ae804b0ffbbab221a docs/components/chatusage.mdx: id: d7c2bc8b3eb2 - last_write_checksum: sha1:94539927996d770b9629c64bde6d8188976eec1d - pristine_git_object: a32fff446094a26dfa62cdfcd02b5bc3c1293a72 + last_write_checksum: sha1:15255340388de8352f60d78e04e8cff33b50daf8 + pristine_git_object: e6412c87ff834c3727d6c5820171250cf1d8ada6 docs/components/chatusagecompletiontokensdetails.mdx: id: 0274e721a9d9 last_write_checksum: sha1:77e7b8ae3c4456f4284f4fbd0093d00fdefd06c9 @@ -1582,8 +1582,8 @@ trackedFiles: pristine_git_object: df0f53d79f8acca641d7f13a00c706f2c7883752 docs/components/costdetails.mdx: id: 15349f1e1877 - last_write_checksum: sha1:90a330bfa37e208bcee6615af2ee7535c4416a26 - pristine_git_object: 753493b8d505e9317dcaca6fc897da7e30e91d0c + last_write_checksum: sha1:82388f28c4c4274307084c3dcf79c08756801f6f + pristine_git_object: a253de5165a3148b8321c0c7daa418551e65b8b8 docs/components/createbyokkeyrequest.mdx: id: 2af3019aa2a7 last_write_checksum: sha1:a61a6569552f17904c29e6ed273c6e0faef04926 @@ -2434,8 +2434,8 @@ trackedFiles: pristine_git_object: cabf0cccfa7d7bee9faa823d66650bc395220966 docs/components/imagegenerationusage.mdx: id: 0f8faafc5148 - last_write_checksum: sha1:7662a98019e0fb829b124d14f938ee07f5ef5519 - pristine_git_object: cb01cf31c16ba5f1caea0be6b376e83ee0d82b59 + last_write_checksum: sha1:d33384d2c9ad53fd06bbfd012480d9f07aa99511 + pristine_git_object: 2785a73830d811d113ae81de25dff213b86f1195 docs/components/imagegenerationusagecompletiontokensdetails.mdx: id: 71ecb25e164d last_write_checksum: sha1:f0843acffd7d7540b07bb384f299557e7309950d @@ -3658,8 +3658,8 @@ trackedFiles: pristine_git_object: 09effe2d3fe45536c8b0aa0f23c02ce19b15f62c docs/components/openresponsesresult.mdx: id: d0fed85674d2 - last_write_checksum: sha1:3bc26b772dfc3397c0da7b769b16d938eede91fb - pristine_git_object: f5c81b7142316cd4a6ec8a96c192b682a1a34ff8 + last_write_checksum: sha1:3a89b8dea8dca1fafc0941a83dd6e38e085b7fc4 + pristine_git_object: 55c8be43f6c7b07dbd479d524faa05bb91e5a1bd docs/components/openresponsesresultobject.mdx: id: 93b1fcc70132 last_write_checksum: sha1:7579ee1bb9e0d20c55cf54a8ca2ccbc950d2921d @@ -5630,8 +5630,8 @@ trackedFiles: pristine_git_object: bdccd14638993ccc967858574f6891c7033dc78d docs/components/usagecostdetails.mdx: id: 95d8a52fead9 - last_write_checksum: sha1:d8b2597a2921b79c43fd30173a8c395cd60584b2 - pristine_git_object: 646988e4def5b952edb718a68bc8c85b39c4606e + last_write_checksum: sha1:4ff989240588aff3fa1f6766735744e8add8b4b5 + pristine_git_object: 79a3f1a3b42c6c7e91fc4f2f0703a83d8362887a docs/components/userlocation.mdx: id: d197ccf2b36c last_write_checksum: sha1:c7078ea2cd00c001dcef6ce68c790b9d3d718e2b @@ -6086,8 +6086,8 @@ trackedFiles: pristine_git_object: 4efeda7aa813ebf97131645e6af8e49853731100 docs/operations/createembeddingsusage.mdx: id: 4f9205ca2bb9 - last_write_checksum: sha1:8156e256387b12cc08a5a92f9e9332ec2b35a2af - pristine_git_object: 1218cf960cbc2285120cb399596e0bc73b44aa9f + last_write_checksum: sha1:a8e6161d696082a97e88aad4486af964de493a9b + pristine_git_object: 0bfcb70713b28628e0f01d74d44349aeb76c1b3a docs/operations/createguardrailglobals.mdx: id: ce6e792df15c last_write_checksum: sha1:6542508eed5dbd74bf6812b8cc0cc9cfd3157d06 @@ -7398,8 +7398,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:2a855ad3856908fc54865494b310600be61347a0 - pristine_git_object: 7b2404e12ba1515b839544b611bf4e80bebef40b + last_write_checksum: sha1:12817df01d071d28e432dc1a67032b8c04cbb6c9 + pristine_git_object: a55294a8bffcf7134a07f4e042514cc755f1b330 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -7426,8 +7426,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:d2cc707d265f98228f6e093310429cb33c896a9b - pristine_git_object: 18fe52ed171027a8b4dac54e53a84f8921d7cf7f + last_write_checksum: sha1:e3917ff4872537c69aff25d7471bdbd565c437c3 + pristine_git_object: 76dfcf1aa14a29f8298806d7f8bcb713be07b292 src/openrouter/analytics.py: id: cb406b5aaabb last_write_checksum: sha1:1e0004d8d1d5d797e2b54cd1cabeb7f9489d08e9 @@ -8154,8 +8154,8 @@ trackedFiles: pristine_git_object: f6e8d18d3b51501a3a2b7d7527a64fa02b9b1726 src/openrouter/components/costdetails.py: id: 513b4309de6e - last_write_checksum: sha1:1308d1504b1f78427467c6bf58776f31baac2a2a - pristine_git_object: dbafc2878cb3185fac34919e2f789b26dc86f70e + last_write_checksum: sha1:77d14d6491dfe72141a0ee708b719ad5f2974838 + pristine_git_object: 7e114e7ff311b65b7f8d3865d6df5f3501c9d704 src/openrouter/components/createbyokkeyrequest.py: id: 238e868445b4 last_write_checksum: sha1:5320d73056ed0e00b264e7dda3d7f6086fc6664a @@ -9002,8 +9002,8 @@ trackedFiles: pristine_git_object: 08d990d8cc07b7928158fc55784cd9d613f4c58b src/openrouter/components/openresponsesresult.py: id: 78f7e33b19e6 - last_write_checksum: sha1:05c792b6b0f54a5707b83527f8d81a50523cc932 - pristine_git_object: 0c7d4a2b3338b97a21f3bf72966ecbc885f47008 + last_write_checksum: sha1:5c97217073a3863866f16b9fe8dc77f222f50cab + pristine_git_object: 57b085a5447e7c3ab3ef867293dd37c6620ae2be src/openrouter/components/openrouterfile.py: id: df1961bcb130 last_write_checksum: sha1:1a9a1b1e640f4d0ef78ce0caa160b5ab342f02cc @@ -12473,3 +12473,10 @@ examples: "503": application/json: {"error": {"code": 503, "message": "Service temporarily unavailable"}} examplesVersion: 1.0.2 +releaseNotes: | + ## Python SDK Changes: + * `open_router.chat.send()`: `response` **Changed** + * `open_router.embeddings.generate()`: `response.usage.cost_details.server_tool_cost` **Added** + * `open_router.images.generate()`: `response` **Changed** + * `open_router.responses.send()`: `response` **Changed** + * `open_router.beta.responses.send()`: `response` **Changed** diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index b49abffa..2ad244b4 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -36,7 +36,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.1.104 + version: 1.1.105 additionalDependencies: dev: {} main: {} diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 5f9500ae..6e88892a 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -7091,10 +7091,17 @@ components: CostDetails: description: 'Breakdown of upstream inference costs' example: + server_tool_cost: null upstream_inference_completions_cost: 0.0004 upstream_inference_cost: null upstream_inference_prompt_cost: 0.0008 properties: + server_tool_cost: + description: 'Metered server-tool execution cost (for example, shell sandbox time) billed for this request, in USD. Matches the billed checkpoint and settlement amounts exactly.' + format: 'double' + type: + - 'number' + - 'null' upstream_inference_completions_cost: format: 'double' type: 'number' @@ -26012,6 +26019,12 @@ components: - 'null' cost_details: properties: + server_tool_cost: + description: 'Metered server-tool execution cost (for example, shell sandbox time) billed for this request, in USD. Matches the billed checkpoint and settlement amounts exactly.' + format: 'double' + type: + - 'number' + - 'null' upstream_inference_cost: format: 'double' type: @@ -26038,6 +26051,7 @@ components: example: cost: 0.0012 cost_details: + server_tool_cost: null upstream_inference_cost: null upstream_inference_input_cost: 0.0008 upstream_inference_output_cost: 0.0004 diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index ef852f47..84c93667 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.787.0 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:b830083ecd9b37e8ad3e3182e4cd128c7a911544e4932071eb6752e3696d836b - sourceBlobDigest: sha256:2ebe822059d868b010eb99a274146cd850174e2b3c3a390d245a6ea448128209 + sourceRevisionDigest: sha256:40b0b33a5ccf743d74b28e05017c078d2815e50f04376753600cc2be7c729a4d + sourceBlobDigest: sha256:94085c36bf206efd8a5c05a2620f09ec431e8ae6a654f9f315766d0d86fce8ae tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:b830083ecd9b37e8ad3e3182e4cd128c7a911544e4932071eb6752e3696d836b - sourceBlobDigest: sha256:2ebe822059d868b010eb99a274146cd850174e2b3c3a390d245a6ea448128209 + sourceRevisionDigest: sha256:40b0b33a5ccf743d74b28e05017c078d2815e50f04376753600cc2be7c729a4d + sourceBlobDigest: sha256:94085c36bf206efd8a5c05a2620f09ec431e8ae6a654f9f315766d0d86fce8ae codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:469a140e2f513fa3ebabe00511678073f42e30628dcc0a91f595c245b345d68a + codeSamplesRevisionDigest: sha256:2652602a33d9570e30c87618091c4ef824af10c47acc70cee6c8288c6efd1b71 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/RELEASES.md b/RELEASES.md index 72ec3c53..f9542fcf 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1829,4 +1829,14 @@ Based on: ### Generated - [python v1.1.104] . ### Releases -- [PyPI v1.1.104] https://pypi.org/project/openrouter/1.1.104 - . \ No newline at end of file +- [PyPI v1.1.104] https://pypi.org/project/openrouter/1.1.104 - . + +## 2026-08-31 03:07:01 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.1.105] . +### Releases +- [PyPI v1.1.105] https://pypi.org/project/openrouter/1.1.105 - . \ No newline at end of file diff --git a/docs/components/chatusage.mdx b/docs/components/chatusage.mdx index a32fff44..e6412c87 100644 --- a/docs/components/chatusage.mdx +++ b/docs/components/chatusage.mdx @@ -7,14 +7,14 @@ Token usage statistics ## Fields -| Field | Type | Required | Description | Example | -| ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `completion_tokens` | *int* | :heavy_check_mark: | Number of tokens in the completion | | -| `completion_tokens_details` | [OptionalNullable[components.ChatUsageCompletionTokensDetails]](../components/chatusagecompletiontokensdetails.mdx) | :heavy_minus_sign: | Detailed completion token usage | | -| `cost` | *OptionalNullable[float]* | :heavy_minus_sign: | Cost of the completion | | -| `cost_details` | [OptionalNullable[components.CostDetails]](../components/costdetails.mdx) | :heavy_minus_sign: | Breakdown of upstream inference costs | \{
"upstream_inference_completions_cost": 0.0004,
"upstream_inference_cost": null,
"upstream_inference_prompt_cost": 0.0008
} | -| `is_byok` | *Optional[bool]* | :heavy_minus_sign: | Whether a request was made using a Bring Your Own Key configuration | | -| `prompt_tokens` | *int* | :heavy_check_mark: | Number of tokens in the prompt | | -| `prompt_tokens_details` | [OptionalNullable[components.ChatUsagePromptTokensDetails]](../components/chatusageprompttokensdetails.mdx) | :heavy_minus_sign: | Detailed prompt token usage | | -| `server_tool_use_details` | [OptionalNullable[components.ServerToolUseDetails]](../components/servertoolusedetails.mdx) | :heavy_minus_sign: | Usage for server-side tool execution (e.g., web search) | \{
"tool_calls_executed": 2,
"tool_calls_requested": 2,
"web_search_requests": 2
} | -| `total_tokens` | *int* | :heavy_check_mark: | Total number of tokens | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `completion_tokens` | *int* | :heavy_check_mark: | Number of tokens in the completion | | +| `completion_tokens_details` | [OptionalNullable[components.ChatUsageCompletionTokensDetails]](../components/chatusagecompletiontokensdetails.mdx) | :heavy_minus_sign: | Detailed completion token usage | | +| `cost` | *OptionalNullable[float]* | :heavy_minus_sign: | Cost of the completion | | +| `cost_details` | [OptionalNullable[components.CostDetails]](../components/costdetails.mdx) | :heavy_minus_sign: | Breakdown of upstream inference costs | \{
"server_tool_cost": null,
"upstream_inference_completions_cost": 0.0004,
"upstream_inference_cost": null,
"upstream_inference_prompt_cost": 0.0008
} | +| `is_byok` | *Optional[bool]* | :heavy_minus_sign: | Whether a request was made using a Bring Your Own Key configuration | | +| `prompt_tokens` | *int* | :heavy_check_mark: | Number of tokens in the prompt | | +| `prompt_tokens_details` | [OptionalNullable[components.ChatUsagePromptTokensDetails]](../components/chatusageprompttokensdetails.mdx) | :heavy_minus_sign: | Detailed prompt token usage | | +| `server_tool_use_details` | [OptionalNullable[components.ServerToolUseDetails]](../components/servertoolusedetails.mdx) | :heavy_minus_sign: | Usage for server-side tool execution (e.g., web search) | \{
"tool_calls_executed": 2,
"tool_calls_requested": 2,
"web_search_requests": 2
} | +| `total_tokens` | *int* | :heavy_check_mark: | Total number of tokens | | \ No newline at end of file diff --git a/docs/components/costdetails.mdx b/docs/components/costdetails.mdx index 753493b8..a253de51 100644 --- a/docs/components/costdetails.mdx +++ b/docs/components/costdetails.mdx @@ -7,8 +7,9 @@ Breakdown of upstream inference costs ## Fields -| Field | Type | Required | Description | -| ------------------------------------- | ------------------------------------- | ------------------------------------- | ------------------------------------- | -| `upstream_inference_completions_cost` | *float* | :heavy_check_mark: | N/A | -| `upstream_inference_cost` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | -| `upstream_inference_prompt_cost` | *float* | :heavy_check_mark: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `server_tool_cost` | *OptionalNullable[float]* | :heavy_minus_sign: | Metered server-tool execution cost (for example, shell sandbox time) billed for this request, in USD. Matches the billed checkpoint and settlement amounts exactly. | +| `upstream_inference_completions_cost` | *float* | :heavy_check_mark: | N/A | +| `upstream_inference_cost` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | +| `upstream_inference_prompt_cost` | *float* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/components/imagegenerationusage.mdx b/docs/components/imagegenerationusage.mdx index cb01cf31..2785a738 100644 --- a/docs/components/imagegenerationusage.mdx +++ b/docs/components/imagegenerationusage.mdx @@ -7,18 +7,18 @@ Token and cost usage for the image generation request, when available ## Fields -| Field | Type | Required | Description | Example | -| ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | -| `cache_creation` | [OptionalNullable[components.AnthropicCacheCreation]](../components/anthropiccachecreation.mdx) | :heavy_minus_sign: | N/A | \{
"ephemeral_1h_input_tokens": 0,
"ephemeral_5m_input_tokens": 100
} | -| `completion_tokens` | *int* | :heavy_check_mark: | The tokens generated | | -| `completion_tokens_details` | [OptionalNullable[components.ImageGenerationUsageCompletionTokensDetails]](../components/imagegenerationusagecompletiontokensdetails.mdx) | :heavy_minus_sign: | N/A | | -| `cost` | *OptionalNullable[float]* | :heavy_minus_sign: | Cost of the completion | | -| `cost_details` | [OptionalNullable[components.CostDetails]](../components/costdetails.mdx) | :heavy_minus_sign: | Breakdown of upstream inference costs | \{
"upstream_inference_completions_cost": 0.0004,
"upstream_inference_cost": null,
"upstream_inference_prompt_cost": 0.0008
} | -| `is_byok` | *Optional[bool]* | :heavy_minus_sign: | Whether a request was made using a Bring Your Own Key configuration | | -| `iterations` | List[[components.AnthropicUsageIteration](../components/anthropicusageiteration.mdx)] | :heavy_minus_sign: | N/A | | -| `prompt_tokens` | *int* | :heavy_check_mark: | Including images, input audio, and tools if any | | -| `prompt_tokens_details` | [OptionalNullable[components.ImageGenerationUsagePromptTokensDetails]](../components/imagegenerationusageprompttokensdetails.mdx) | :heavy_minus_sign: | Breakdown of tokens used in the prompt. | | -| `server_tool_use` | [OptionalNullable[components.ServerToolUse]](../components/servertooluse.mdx) | :heavy_minus_sign: | Usage for server-side tool execution (e.g., web search) | | -| `service_tier` | *OptionalNullable[str]* | :heavy_minus_sign: | The service tier used by the upstream provider for this request | | -| `speed` | [OptionalNullable[components.AnthropicSpeed]](../components/anthropicspeed.mdx) | :heavy_minus_sign: | N/A | standard | -| `total_tokens` | *int* | :heavy_check_mark: | Sum of the above two fields | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `cache_creation` | [OptionalNullable[components.AnthropicCacheCreation]](../components/anthropiccachecreation.mdx) | :heavy_minus_sign: | N/A | \{
"ephemeral_1h_input_tokens": 0,
"ephemeral_5m_input_tokens": 100
} | +| `completion_tokens` | *int* | :heavy_check_mark: | The tokens generated | | +| `completion_tokens_details` | [OptionalNullable[components.ImageGenerationUsageCompletionTokensDetails]](../components/imagegenerationusagecompletiontokensdetails.mdx) | :heavy_minus_sign: | N/A | | +| `cost` | *OptionalNullable[float]* | :heavy_minus_sign: | Cost of the completion | | +| `cost_details` | [OptionalNullable[components.CostDetails]](../components/costdetails.mdx) | :heavy_minus_sign: | Breakdown of upstream inference costs | \{
"server_tool_cost": null,
"upstream_inference_completions_cost": 0.0004,
"upstream_inference_cost": null,
"upstream_inference_prompt_cost": 0.0008
} | +| `is_byok` | *Optional[bool]* | :heavy_minus_sign: | Whether a request was made using a Bring Your Own Key configuration | | +| `iterations` | List[[components.AnthropicUsageIteration](../components/anthropicusageiteration.mdx)] | :heavy_minus_sign: | N/A | | +| `prompt_tokens` | *int* | :heavy_check_mark: | Including images, input audio, and tools if any | | +| `prompt_tokens_details` | [OptionalNullable[components.ImageGenerationUsagePromptTokensDetails]](../components/imagegenerationusageprompttokensdetails.mdx) | :heavy_minus_sign: | Breakdown of tokens used in the prompt. | | +| `server_tool_use` | [OptionalNullable[components.ServerToolUse]](../components/servertooluse.mdx) | :heavy_minus_sign: | Usage for server-side tool execution (e.g., web search) | | +| `service_tier` | *OptionalNullable[str]* | :heavy_minus_sign: | The service tier used by the upstream provider for this request | | +| `speed` | [OptionalNullable[components.AnthropicSpeed]](../components/anthropicspeed.mdx) | :heavy_minus_sign: | N/A | standard | +| `total_tokens` | *int* | :heavy_check_mark: | Sum of the above two fields | | \ No newline at end of file diff --git a/docs/components/openresponsesresult.mdx b/docs/components/openresponsesresult.mdx index f5c81b71..55c8be43 100644 --- a/docs/components/openresponsesresult.mdx +++ b/docs/components/openresponsesresult.mdx @@ -7,42 +7,42 @@ Complete non-streaming response from the Responses API ## Fields -| Field | Type | Required | Description | Example | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `background` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | | -| `completed_at` | *Nullable[int]* | :heavy_check_mark: | N/A | | -| `created_at` | *int* | :heavy_check_mark: | N/A | | -| `error` | [Nullable[components.ResponsesErrorField]](../components/responseserrorfield.mdx) | :heavy_check_mark: | Error information returned from the API | \{
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Please try again later."
} | -| `frequency_penalty` | *Nullable[float]* | :heavy_check_mark: | N/A | | -| `id` | *str* | :heavy_check_mark: | N/A | | -| `incomplete_details` | [Nullable[components.IncompleteDetails]](../components/incompletedetails.mdx) | :heavy_check_mark: | N/A | \{
"reason": "max_output_tokens"
} | -| `instructions` | [Nullable[components.BaseInputsUnion]](../components/baseinputsunion.mdx) | :heavy_check_mark: | N/A | [
\{
"content": "What is the weather today?",
"role": "user"
}
] | -| `max_output_tokens` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A | | -| `max_tool_calls` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A | | -| `metadata` | Dict[str, *str*] | :heavy_check_mark: | Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed. | \{
"session_id": "abc-def-ghi",
"user_id": "123"
} | -| `model` | *str* | :heavy_check_mark: | N/A | | -| `object` | [components.OpenResponsesResultObject](../components/openresponsesresultobject.mdx) | :heavy_check_mark: | N/A | | -| `output` | List[[components.OutputItems](../components/outputitems.mdx)] | :heavy_check_mark: | N/A | | -| `output_text` | *Optional[str]* | :heavy_minus_sign: | N/A | | -| `parallel_tool_calls` | *bool* | :heavy_check_mark: | N/A | | -| `presence_penalty` | *Nullable[float]* | :heavy_check_mark: | N/A | | -| `previous_response_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | -| `prompt` | [OptionalNullable[components.StoredPromptTemplate]](../components/storedprompttemplate.mdx) | :heavy_minus_sign: | N/A | \{
"id": "prompt-abc123",
"variables": \{
"name": "John"
}
} | -| `prompt_cache_key` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | -| `prompt_cache_options` | [OptionalNullable[components.PromptCacheOptions]](../components/promptcacheoptions.mdx) | :heavy_minus_sign: | Request-level prompt-cache controls. `mode: "explicit"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer. | \{
"mode": "explicit",
"ttl": "30m"
} | -| `reasoning` | [OptionalNullable[components.BaseReasoningConfig]](../components/basereasoningconfig.mdx) | :heavy_minus_sign: | N/A | \{
"effort": "medium",
"summary": "auto"
} | -| `safety_identifier` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | -| `service_tier` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | -| `status` | [components.OpenAIResponsesResponseStatus](../components/openairesponsesresponsestatus.mdx) | :heavy_check_mark: | N/A | completed | -| `store` | *Optional[bool]* | :heavy_minus_sign: | N/A | | -| `temperature` | *Nullable[float]* | :heavy_check_mark: | N/A | | -| `text` | [Optional[components.TextExtendedConfig]](../components/textextendedconfig.mdx) | :heavy_minus_sign: | Text output configuration including format and verbosity | \{
"format": \{
"type": "text"
}
} | -| `tool_choice` | [components.OpenAIResponsesToolChoiceUnion](../components/openairesponsestoolchoiceunion.mdx) | :heavy_check_mark: | N/A | auto | -| `tools` | List[[components.OpenResponsesResultToolUnion](../components/openresponsesresulttoolunion.mdx)] | :heavy_check_mark: | N/A | | -| `top_logprobs` | *Optional[int]* | :heavy_minus_sign: | N/A | | -| `top_p` | *Nullable[float]* | :heavy_check_mark: | N/A | | -| `truncation` | [OptionalNullable[components.Truncation]](../components/truncation.mdx) | :heavy_minus_sign: | N/A | auto | -| `usage` | [OptionalNullable[components.Usage]](../components/usage.mdx) | :heavy_minus_sign: | Token usage information for the response | \{
"cost": 0.0012,
"cost_details": \{
"upstream_inference_cost": null,
"upstream_inference_input_cost": 0.0008,
"upstream_inference_output_cost": 0.0004
},
"input_tokens": 10,
"input_tokens_details": \{
"cached_tokens": 0
},
"output_tokens": 25,
"output_tokens_details": \{
"reasoning_tokens": 0
},
"total_tokens": 35
} | -| `user` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | -| `error_type` | [Optional[components.APIErrorType]](../components/apierrortype.mdx) | :heavy_minus_sign: | Canonical OpenRouter error type, stable across all API formats | rate_limit_exceeded | -| `openrouter_metadata` | [Optional[components.OpenRouterMetadata]](../components/openroutermetadata.mdx) | :heavy_minus_sign: | N/A | \{
"attempt": 1,
"endpoints": \{
"available": [
\{
"model": "openai/gpt-4o",
"provider": "OpenAI",
"selected": true
}
],
"total": 1
},
"is_byok": false,
"region": "iad",
"requested": "openai/gpt-4o",
"strategy": "direct",
"summary": "available=1, selected=OpenAI"
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `background` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | | +| `completed_at` | *Nullable[int]* | :heavy_check_mark: | N/A | | +| `created_at` | *int* | :heavy_check_mark: | N/A | | +| `error` | [Nullable[components.ResponsesErrorField]](../components/responseserrorfield.mdx) | :heavy_check_mark: | Error information returned from the API | \{
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Please try again later."
} | +| `frequency_penalty` | *Nullable[float]* | :heavy_check_mark: | N/A | | +| `id` | *str* | :heavy_check_mark: | N/A | | +| `incomplete_details` | [Nullable[components.IncompleteDetails]](../components/incompletedetails.mdx) | :heavy_check_mark: | N/A | \{
"reason": "max_output_tokens"
} | +| `instructions` | [Nullable[components.BaseInputsUnion]](../components/baseinputsunion.mdx) | :heavy_check_mark: | N/A | [
\{
"content": "What is the weather today?",
"role": "user"
}
] | +| `max_output_tokens` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A | | +| `max_tool_calls` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A | | +| `metadata` | Dict[str, *str*] | :heavy_check_mark: | Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed. | \{
"session_id": "abc-def-ghi",
"user_id": "123"
} | +| `model` | *str* | :heavy_check_mark: | N/A | | +| `object` | [components.OpenResponsesResultObject](../components/openresponsesresultobject.mdx) | :heavy_check_mark: | N/A | | +| `output` | List[[components.OutputItems](../components/outputitems.mdx)] | :heavy_check_mark: | N/A | | +| `output_text` | *Optional[str]* | :heavy_minus_sign: | N/A | | +| `parallel_tool_calls` | *bool* | :heavy_check_mark: | N/A | | +| `presence_penalty` | *Nullable[float]* | :heavy_check_mark: | N/A | | +| `previous_response_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | +| `prompt` | [OptionalNullable[components.StoredPromptTemplate]](../components/storedprompttemplate.mdx) | :heavy_minus_sign: | N/A | \{
"id": "prompt-abc123",
"variables": \{
"name": "John"
}
} | +| `prompt_cache_key` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | +| `prompt_cache_options` | [OptionalNullable[components.PromptCacheOptions]](../components/promptcacheoptions.mdx) | :heavy_minus_sign: | Request-level prompt-cache controls. `mode: "explicit"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer. | \{
"mode": "explicit",
"ttl": "30m"
} | +| `reasoning` | [OptionalNullable[components.BaseReasoningConfig]](../components/basereasoningconfig.mdx) | :heavy_minus_sign: | N/A | \{
"effort": "medium",
"summary": "auto"
} | +| `safety_identifier` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | +| `service_tier` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | +| `status` | [components.OpenAIResponsesResponseStatus](../components/openairesponsesresponsestatus.mdx) | :heavy_check_mark: | N/A | completed | +| `store` | *Optional[bool]* | :heavy_minus_sign: | N/A | | +| `temperature` | *Nullable[float]* | :heavy_check_mark: | N/A | | +| `text` | [Optional[components.TextExtendedConfig]](../components/textextendedconfig.mdx) | :heavy_minus_sign: | Text output configuration including format and verbosity | \{
"format": \{
"type": "text"
}
} | +| `tool_choice` | [components.OpenAIResponsesToolChoiceUnion](../components/openairesponsestoolchoiceunion.mdx) | :heavy_check_mark: | N/A | auto | +| `tools` | List[[components.OpenResponsesResultToolUnion](../components/openresponsesresulttoolunion.mdx)] | :heavy_check_mark: | N/A | | +| `top_logprobs` | *Optional[int]* | :heavy_minus_sign: | N/A | | +| `top_p` | *Nullable[float]* | :heavy_check_mark: | N/A | | +| `truncation` | [OptionalNullable[components.Truncation]](../components/truncation.mdx) | :heavy_minus_sign: | N/A | auto | +| `usage` | [OptionalNullable[components.Usage]](../components/usage.mdx) | :heavy_minus_sign: | Token usage information for the response | \{
"cost": 0.0012,
"cost_details": \{
"server_tool_cost": null,
"upstream_inference_cost": null,
"upstream_inference_input_cost": 0.0008,
"upstream_inference_output_cost": 0.0004
},
"input_tokens": 10,
"input_tokens_details": \{
"cached_tokens": 0
},
"output_tokens": 25,
"output_tokens_details": \{
"reasoning_tokens": 0
},
"total_tokens": 35
} | +| `user` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | +| `error_type` | [Optional[components.APIErrorType]](../components/apierrortype.mdx) | :heavy_minus_sign: | Canonical OpenRouter error type, stable across all API formats | rate_limit_exceeded | +| `openrouter_metadata` | [Optional[components.OpenRouterMetadata]](../components/openroutermetadata.mdx) | :heavy_minus_sign: | N/A | \{
"attempt": 1,
"endpoints": \{
"available": [
\{
"model": "openai/gpt-4o",
"provider": "OpenAI",
"selected": true
}
],
"total": 1
},
"is_byok": false,
"region": "iad",
"requested": "openai/gpt-4o",
"strategy": "direct",
"summary": "available=1, selected=OpenAI"
} | \ No newline at end of file diff --git a/docs/components/usagecostdetails.mdx b/docs/components/usagecostdetails.mdx index 646988e4..79a3f1a3 100644 --- a/docs/components/usagecostdetails.mdx +++ b/docs/components/usagecostdetails.mdx @@ -4,8 +4,9 @@ title: "UsageCostDetails" ## Fields -| Field | Type | Required | Description | -| -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -| `upstream_inference_cost` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | -| `upstream_inference_input_cost` | *float* | :heavy_check_mark: | N/A | -| `upstream_inference_output_cost` | *float* | :heavy_check_mark: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `server_tool_cost` | *OptionalNullable[float]* | :heavy_minus_sign: | Metered server-tool execution cost (for example, shell sandbox time) billed for this request, in USD. Matches the billed checkpoint and settlement amounts exactly. | +| `upstream_inference_cost` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | +| `upstream_inference_input_cost` | *float* | :heavy_check_mark: | N/A | +| `upstream_inference_output_cost` | *float* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/operations/createembeddingsusage.mdx b/docs/operations/createembeddingsusage.mdx index 1218cf96..0bfcb707 100644 --- a/docs/operations/createembeddingsusage.mdx +++ b/docs/operations/createembeddingsusage.mdx @@ -10,7 +10,7 @@ Token usage statistics | Field | Type | Required | Description | Example | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `cost` | *Optional[float]* | :heavy_minus_sign: | Cost of the request in credits | 0.0001 | -| `cost_details` | [OptionalNullable[components.CostDetails]](../components/costdetails.mdx) | :heavy_minus_sign: | Breakdown of upstream inference costs | \{
"upstream_inference_completions_cost": 0.0004,
"upstream_inference_cost": null,
"upstream_inference_prompt_cost": 0.0008
} | +| `cost_details` | [OptionalNullable[components.CostDetails]](../components/costdetails.mdx) | :heavy_minus_sign: | Breakdown of upstream inference costs | \{
"server_tool_cost": null,
"upstream_inference_completions_cost": 0.0004,
"upstream_inference_cost": null,
"upstream_inference_prompt_cost": 0.0008
} | | `is_byok` | *Optional[bool]* | :heavy_minus_sign: | Whether a request was made using a Bring Your Own Key configuration | | | `prompt_tokens` | *int* | :heavy_check_mark: | Number of tokens in the input | 8 | | `prompt_tokens_details` | [Optional[operations.PromptTokensDetails]](../operations/prompttokensdetails.mdx) | :heavy_minus_sign: | Per-modality token breakdown. Only present when the input contains 2+ modalities (e.g. text + image) and the upstream provider returns modality-level usage data. Only non-zero modality counts are included. | | diff --git a/pyproject.toml b/pyproject.toml index 7b2404e1..a55294a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.1.104" +version = "1.1.105" description = "Official Python Client SDK for OpenRouter." authors = [{ name = "OpenRouter" },] readme = "README-PYPI.md" diff --git a/src/openrouter/_version.py b/src/openrouter/_version.py index 18fe52ed..76dfcf1a 100644 --- a/src/openrouter/_version.py +++ b/src/openrouter/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "openrouter" -__version__: str = "1.1.104" +__version__: str = "1.1.105" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.914.0" -__user_agent__: str = "speakeasy-sdk/python 1.1.104 2.914.0 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.1.105 2.914.0 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/components/costdetails.py b/src/openrouter/components/costdetails.py index dbafc287..7e114e7f 100644 --- a/src/openrouter/components/costdetails.py +++ b/src/openrouter/components/costdetails.py @@ -17,6 +17,8 @@ class CostDetailsTypedDict(TypedDict): upstream_inference_completions_cost: float upstream_inference_prompt_cost: float + server_tool_cost: NotRequired[Nullable[float]] + r"""Metered server-tool execution cost (for example, shell sandbox time) billed for this request, in USD. Matches the billed checkpoint and settlement amounts exactly.""" upstream_inference_cost: NotRequired[Nullable[float]] @@ -27,12 +29,15 @@ class CostDetails(BaseModel): upstream_inference_prompt_cost: float + server_tool_cost: OptionalNullable[float] = UNSET + r"""Metered server-tool execution cost (for example, shell sandbox time) billed for this request, in USD. Matches the billed checkpoint and settlement amounts exactly.""" + upstream_inference_cost: OptionalNullable[float] = UNSET @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["upstream_inference_cost"]) - nullable_fields = set(["upstream_inference_cost"]) + optional_fields = set(["server_tool_cost", "upstream_inference_cost"]) + nullable_fields = set(["server_tool_cost", "upstream_inference_cost"]) serialized = handler(self) m = {} diff --git a/src/openrouter/components/openresponsesresult.py b/src/openrouter/components/openresponsesresult.py index 0c7d4a2b..57b085a5 100644 --- a/src/openrouter/components/openresponsesresult.py +++ b/src/openrouter/components/openresponsesresult.py @@ -251,6 +251,8 @@ class OutputTokensDetails(BaseModel): class UsageCostDetailsTypedDict(TypedDict): upstream_inference_input_cost: float upstream_inference_output_cost: float + server_tool_cost: NotRequired[Nullable[float]] + r"""Metered server-tool execution cost (for example, shell sandbox time) billed for this request, in USD. Matches the billed checkpoint and settlement amounts exactly.""" upstream_inference_cost: NotRequired[Nullable[float]] @@ -259,12 +261,15 @@ class UsageCostDetails(BaseModel): upstream_inference_output_cost: float + server_tool_cost: OptionalNullable[float] = UNSET + r"""Metered server-tool execution cost (for example, shell sandbox time) billed for this request, in USD. Matches the billed checkpoint and settlement amounts exactly.""" + upstream_inference_cost: OptionalNullable[float] = UNSET @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["upstream_inference_cost"]) - nullable_fields = set(["upstream_inference_cost"]) + optional_fields = set(["server_tool_cost", "upstream_inference_cost"]) + nullable_fields = set(["server_tool_cost", "upstream_inference_cost"]) serialized = handler(self) m = {} diff --git a/uv.lock b/uv.lock index 363f5458..508d0545 100644 --- a/uv.lock +++ b/uv.lock @@ -213,7 +213,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.1.104" +version = "1.1.105" source = { editable = "." } dependencies = [ { name = "httpcore" },