Skip to content

Commit 4839f9b

Browse files
committed
## Python SDK Changes:
* `open_router.beta.responses.send()`: `response` **Changed** **Breaking** ⚠️ * `open_router.embeddings.generate()`: `response.usage.prompt_tokens_details` **Added** * `open_router.generations.get_generation()`: `response.data.web_search_engine` **Added** * `open_router.video_generation.generate()`: * `request.provider.options.baidu` **Added**
1 parent 175b135 commit 4839f9b

27 files changed

Lines changed: 498 additions & 234 deletions

.devcontainer/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
<div align="center">
3+
<a href="https://codespaces.new/OpenRouterTeam/python-sdk.git/tree/main"><img src="https://github.com/codespaces/badge.svg" /></a>
4+
</div>
5+
<br>
6+
27
> **Remember to shutdown a GitHub Codespace when it is not in use!**
38
49
# Dev Containers Quick Start

.speakeasy/gen.lock

Lines changed: 88 additions & 77 deletions
Large diffs are not rendered by default.

.speakeasy/gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ generation:
3232
skipResponseBodyAssertions: false
3333
preApplyUnionDiscriminators: true
3434
python:
35-
version: 0.9.1
35+
version: 0.9.2
3636
additionalDependencies:
3737
dev: {}
3838
main: {}

.speakeasy/out.openapi.yaml

Lines changed: 137 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,15 @@ components:
14891489
- thinking
14901490
- signature
14911491
type: object
1492+
AnthropicThinkingDisplay:
1493+
enum:
1494+
- summarized
1495+
- omitted
1496+
- null
1497+
example: summarized
1498+
nullable: true
1499+
type: string
1500+
x-speakeasy-unknown-values: allow
14921501
AnthropicThinkingTurns:
14931502
example:
14941503
type: thinking_turns
@@ -5965,12 +5974,12 @@ components:
59655974
Configuration for the openrouter:image_generation server tool. Accepts all image_config params (aspect_ratio, quality, size, background, output_format, output_compression, moderation, etc.) plus a model field.
59665975
example:
59675976
aspect_ratio: '16:9'
5968-
model: openai/gpt-image-1
5977+
model: openai/gpt-5-image
59695978
quality: high
59705979
properties:
59715980
model:
5972-
description: Which image generation model to use (e.g. "openai/gpt-image-1"). Defaults to "openai/gpt-image-1".
5973-
example: openai/gpt-image-1
5981+
description: Which image generation model to use (e.g. "openai/gpt-5-image"). Defaults to "openai/gpt-5-image".
5982+
example: openai/gpt-5-image
59745983
type: string
59755984
type: object
59765985
ImageGenerationStatus:
@@ -7255,11 +7264,12 @@ components:
72557264
properties:
72567265
effort:
72577266
description: >-
7258-
How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer. Valid values are `low`, `medium`, `high`, or `max`.
7267+
How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer. Valid values are `low`, `medium`, `high`, `xhigh`, or `max`.
72597268
enum:
72607269
- low
72617270
- medium
72627271
- high
7272+
- xhigh
72637273
- max
72647274
- null
72657275
example: medium
@@ -7283,6 +7293,29 @@ components:
72837293
- type
72847294
- schema
72857295
type: object
7296+
task_budget:
7297+
description: >-
7298+
Task budget for an agentic turn. The model sees a countdown of remaining tokens and uses it to prioritize work and wind down gracefully. Advisory — does not enforce a hard cap.
7299+
example:
7300+
total: 400000
7301+
type: tokens
7302+
nullable: true
7303+
properties:
7304+
remaining:
7305+
minimum: 0
7306+
nullable: true
7307+
type: integer
7308+
total:
7309+
minimum: 20000
7310+
type: integer
7311+
type:
7312+
enum:
7313+
- tokens
7314+
type: string
7315+
required:
7316+
- type
7317+
- total
7318+
type: object
72867319
type: object
72877320
MessagesPingEvent:
72887321
description: Keep-alive ping event
@@ -7475,6 +7508,8 @@ components:
74757508
- properties:
74767509
budget_tokens:
74777510
type: integer
7511+
display:
7512+
$ref: '#/components/schemas/AnthropicThinkingDisplay'
74787513
type:
74797514
enum:
74807515
- enabled
@@ -7492,6 +7527,8 @@ components:
74927527
- type
74937528
type: object
74947529
- properties:
7530+
display:
7531+
$ref: '#/components/schemas/AnthropicThinkingDisplay'
74957532
type:
74967533
enum:
74977534
- adaptive
@@ -7699,6 +7736,23 @@ components:
76997736
allOf:
77007737
- $ref: '#/components/schemas/BaseMessagesResult'
77017738
- properties:
7739+
context_management:
7740+
nullable: true
7741+
properties:
7742+
applied_edits:
7743+
items:
7744+
additionalProperties:
7745+
nullable: true
7746+
properties:
7747+
type:
7748+
type: string
7749+
required:
7750+
- type
7751+
type: object
7752+
type: array
7753+
required:
7754+
- applied_edits
7755+
type: object
77027756
provider:
77037757
$ref: '#/components/schemas/ProviderName'
77047758
usage:
@@ -7835,6 +7889,7 @@ components:
78357889
- AionLabs
78367890
- Alibaba
78377891
- Ambient
7892+
- Baidu
78387893
- Amazon Bedrock
78397894
- Amazon Nova
78407895
- Anthropic
@@ -8861,6 +8916,8 @@ components:
88618916
service_tier:
88628917
nullable: true
88638918
type: string
8919+
text:
8920+
$ref: '#/components/schemas/TextExtendedConfig'
88648921
usage:
88658922
$ref: '#/components/schemas/Usage'
88668923
type: object
@@ -9248,6 +9305,7 @@ components:
92489305
example:
92499306
id: ig_tmp_abc123
92509307
imageUrl: https://example.com/image.png
9308+
result: https://example.com/image.png
92519309
status: completed
92529310
type: openrouter:image_generation
92539311
properties:
@@ -9257,6 +9315,10 @@ components:
92579315
type: string
92589316
imageUrl:
92599317
type: string
9318+
result:
9319+
description: The generated image as a base64-encoded string or URL, matching OpenAI image_generation_call format
9320+
nullable: true
9321+
type: string
92609322
revisedPrompt:
92619323
type: string
92629324
status:
@@ -9504,6 +9566,7 @@ components:
95049566
openrouter:browser_use: '#/components/schemas/OutputBrowserUseServerToolItem'
95059567
openrouter:code_interpreter: '#/components/schemas/OutputCodeInterpreterServerToolItem'
95069568
openrouter:datetime: '#/components/schemas/OutputDatetimeItem'
9569+
openrouter:experimental__search_models: '#/components/schemas/OutputSearchModelsServerToolItem'
95079570
openrouter:file_search: '#/components/schemas/OutputFileSearchServerToolItem'
95089571
openrouter:image_generation: '#/components/schemas/OutputImageGenerationServerToolItem'
95099572
openrouter:mcp: '#/components/schemas/OutputMcpServerToolItem'
@@ -9545,6 +9608,7 @@ components:
95459608
- $ref: '#/components/schemas/OutputToolSearchServerToolItem'
95469609
- $ref: '#/components/schemas/OutputMemoryServerToolItem'
95479610
- $ref: '#/components/schemas/OutputMcpServerToolItem'
9611+
- $ref: '#/components/schemas/OutputSearchModelsServerToolItem'
95489612
OutputItemWebSearchCall:
95499613
example:
95509614
action:
@@ -9788,6 +9852,32 @@ components:
97889852
- text: Analyzed the problem and found the optimal solution.
97899853
type: summary_text
97909854
type: reasoning
9855+
OutputSearchModelsServerToolItem:
9856+
description: An openrouter:experimental__search_models server tool output item
9857+
example:
9858+
arguments: '{"query":"Claude Opus"}'
9859+
id: sm_tmp_abc123
9860+
query: Claude Opus
9861+
status: completed
9862+
type: openrouter:experimental__search_models
9863+
properties:
9864+
arguments:
9865+
description: The JSON arguments submitted to the search tool (e.g. {"query":"Claude"})
9866+
type: string
9867+
id:
9868+
type: string
9869+
query:
9870+
type: string
9871+
status:
9872+
$ref: '#/components/schemas/ToolCallStatus'
9873+
type:
9874+
enum:
9875+
- openrouter:experimental__search_models
9876+
type: string
9877+
required:
9878+
- status
9879+
- type
9880+
type: object
97919881
OutputTextEditorServerToolItem:
97929882
description: An openrouter:text_editor server tool output item
97939883
example:
@@ -10228,6 +10318,7 @@ components:
1022810318
- AionLabs
1022910319
- Alibaba
1023010320
- Ambient
10321+
- Baidu
1023110322
- Amazon Bedrock
1023210323
- Amazon Nova
1023310324
- Anthropic
@@ -10533,6 +10624,7 @@ components:
1053310624
- AionLabs
1053410625
- Alibaba
1053510626
- Ambient
10627+
- Baidu
1053610628
- Amazon Bedrock
1053710629
- Amazon Nova
1053810630
- Anthropic
@@ -11985,7 +12077,18 @@ components:
1198512077
TextExtendedConfig:
1198612078
allOf:
1198712079
- $ref: '#/components/schemas/TextConfig'
11988-
- properties: {}
12080+
- properties:
12081+
verbosity:
12082+
enum:
12083+
- low
12084+
- medium
12085+
- high
12086+
- xhigh
12087+
- max
12088+
- null
12089+
nullable: true
12090+
type: string
12091+
x-speakeasy-unknown-values: allow
1198912092
type: object
1199012093
description: Text output configuration including format and verbosity
1199112094
example:
@@ -12469,6 +12572,10 @@ components:
1246912572
additionalProperties:
1247012573
nullable: true
1247112574
type: object
12575+
baidu:
12576+
additionalProperties:
12577+
nullable: true
12578+
type: object
1247212579
baseten:
1247312580
additionalProperties:
1247412581
nullable: true
@@ -14295,6 +14402,25 @@ paths:
1429514402
description: Number of tokens in the input
1429614403
example: 8
1429714404
type: integer
14405+
prompt_tokens_details:
14406+
description: >-
14407+
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.
14408+
properties:
14409+
audio_tokens:
14410+
description: Number of audio tokens in the input
14411+
type: integer
14412+
image_tokens:
14413+
description: Number of image tokens in the input
14414+
example: 258
14415+
type: integer
14416+
text_tokens:
14417+
description: Number of text tokens in the input
14418+
example: 8
14419+
type: integer
14420+
video_tokens:
14421+
description: Number of video tokens in the input
14422+
type: integer
14423+
type: object
1429814424
total_tokens:
1429914425
description: Total number of tokens used
1430014426
example: 8
@@ -14855,6 +14981,11 @@ paths:
1485514981
description: User-Agent header from the request
1485614982
nullable: true
1485714983
type: string
14984+
web_search_engine:
14985+
description: The resolved web search engine used for this generation (e.g. exa, firecrawl, parallel)
14986+
example: exa
14987+
nullable: true
14988+
type: string
1485814989
required:
1485914990
- id
1486014991
- upstream_id
@@ -14882,6 +15013,7 @@ paths:
1488215013
- num_input_audio_prompt
1488315014
- num_media_completion
1488415015
- num_search_results
15016+
- web_search_engine
1488515017
- origin
1488615018
- usage
1488715019
- is_byok

.speakeasy/workflow.lock

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ speakeasyVersion: 1.680.0
22
sources:
33
OpenRouter API:
44
sourceNamespace: open-router-chat-completions-api
5-
sourceRevisionDigest: sha256:3982892b2b8f82bfc2a26a0f6fcc9512b665a1051dc240a9cfa29001b9453aa9
6-
sourceBlobDigest: sha256:727d3c1f7d36ffbf94c57b565536d8a16804eaef4c4043dd6c98152fc1629c8f
5+
sourceRevisionDigest: sha256:b3a5e353c4475e477a187e50b4178cc6e85e3c93f0c7f5708bf2383e9e951ba4
6+
sourceBlobDigest: sha256:eec16a3c2be924a3a45cfcbc28b70c92dc94cd9332d5fdc930ab22a229003c49
77
tags:
88
- latest
9+
- speakeasy-sdk-regen-1776300046
910
- 1.0.0
1011
targets:
1112
open-router:
1213
source: OpenRouter API
1314
sourceNamespace: open-router-chat-completions-api
14-
sourceRevisionDigest: sha256:3982892b2b8f82bfc2a26a0f6fcc9512b665a1051dc240a9cfa29001b9453aa9
15-
sourceBlobDigest: sha256:727d3c1f7d36ffbf94c57b565536d8a16804eaef4c4043dd6c98152fc1629c8f
15+
sourceRevisionDigest: sha256:b3a5e353c4475e477a187e50b4178cc6e85e3c93f0c7f5708bf2383e9e951ba4
16+
sourceBlobDigest: sha256:eec16a3c2be924a3a45cfcbc28b70c92dc94cd9332d5fdc930ab22a229003c49
1617
codeSamplesNamespace: open-router-python-code-samples
17-
codeSamplesRevisionDigest: sha256:db86aed74d199f265e2e20442ef652dac0911c8a657ccb3e6614d56a26b8b44e
18+
codeSamplesRevisionDigest: sha256:c265c6339f5c03b8e72b3417df8d101b76a5aa8f98218e1a85518f92a935c9bd
1819
workflow:
1920
workflowVersion: 1.0.0
2021
speakeasyVersion: 1.680.0

README-PYPI.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,36 @@ asyncio.run(main())
169169

170170
<!-- No Custom HTTP Client [http-client] -->
171171

172+
<!-- Start Pagination [pagination] -->
173+
## Pagination
174+
175+
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
176+
returned response object will have a `Next` method that can be called to pull down the next group of results. If the
177+
return value of `Next` is `None`, then there are no more pages to be fetched.
178+
179+
Here's an example of one such pagination call:
180+
```python
181+
from openrouter import OpenRouter
182+
import os
183+
184+
185+
with OpenRouter(
186+
http_referer="<value>",
187+
x_open_router_title="<value>",
188+
x_open_router_categories="<value>",
189+
api_key=os.getenv("OPENROUTER_API_KEY", ""),
190+
) as open_router:
191+
192+
res = open_router.guardrails.list()
193+
194+
while res is not None:
195+
# Handle items
196+
197+
res = res.next()
198+
199+
```
200+
<!-- End Pagination [pagination] -->
201+
172202
<!-- Start Resource Management [resource-management] -->
173203
## Resource Management
174204

RELEASES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,14 @@ Based on:
88
### Generated
99
- [python v0.0.16] .
1010
### Releases
11-
- [PyPI v0.0.16] https://pypi.org/project/openrouter/0.0.16 - .
11+
- [PyPI v0.0.16] https://pypi.org/project/openrouter/0.0.16 - .
12+
13+
## 2026-04-19 00:38:53
14+
### Changes
15+
Based on:
16+
- OpenAPI Doc
17+
- Speakeasy CLI 1.680.0 (2.788.4) https://github.com/speakeasy-api/speakeasy
18+
### Generated
19+
- [python v0.9.2] .
20+
### Releases
21+
- [PyPI v0.9.2] https://pypi.org/project/openrouter/0.9.2 - .

0 commit comments

Comments
 (0)