Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

<div align="center">
<a href="https://codespaces.new/OpenRouterTeam/python-sdk.git/tree/main"><img src="https://github.com/codespaces/badge.svg" /></a>
</div>
<br>

> **Remember to shutdown a GitHub Codespace when it is not in use!**

# Dev Containers Quick Start
Expand Down
149 changes: 78 additions & 71 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ generation:
skipResponseBodyAssertions: false
preApplyUnionDiscriminators: true
python:
version: 0.9.1
version: 0.9.2
additionalDependencies:
dev: {}
main: {}
Expand Down
123 changes: 118 additions & 5 deletions .speakeasy/out.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,15 @@ components:
- thinking
- signature
type: object
AnthropicThinkingDisplay:
enum:
- summarized
- omitted
- null
example: summarized
nullable: true
type: string
x-speakeasy-unknown-values: allow
AnthropicThinkingTurns:
example:
type: thinking_turns
Expand Down Expand Up @@ -5965,12 +5974,12 @@ components:
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.
example:
aspect_ratio: '16:9'
model: openai/gpt-image-1
model: openai/gpt-5-image
quality: high
properties:
model:
description: Which image generation model to use (e.g. "openai/gpt-image-1"). Defaults to "openai/gpt-image-1".
example: openai/gpt-image-1
description: Which image generation model to use (e.g. "openai/gpt-5-image"). Defaults to "openai/gpt-5-image".
example: openai/gpt-5-image
type: string
type: object
ImageGenerationStatus:
Expand Down Expand Up @@ -7255,11 +7264,12 @@ components:
properties:
effort:
description: >-
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`.
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`.
enum:
- low
- medium
- high
- xhigh
- max
- null
example: medium
Expand All @@ -7283,6 +7293,29 @@ components:
- type
- schema
type: object
task_budget:
description: >-
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.
example:
total: 400000
type: tokens
nullable: true
properties:
remaining:
minimum: 0
nullable: true
type: integer
total:
minimum: 20000
type: integer
type:
enum:
- tokens
type: string
required:
- type
- total
type: object
type: object
MessagesPingEvent:
description: Keep-alive ping event
Expand Down Expand Up @@ -7475,6 +7508,8 @@ components:
- properties:
budget_tokens:
type: integer
display:
$ref: '#/components/schemas/AnthropicThinkingDisplay'
type:
enum:
- enabled
Expand All @@ -7492,6 +7527,8 @@ components:
- type
type: object
- properties:
display:
$ref: '#/components/schemas/AnthropicThinkingDisplay'
type:
enum:
- adaptive
Expand Down Expand Up @@ -7699,6 +7736,23 @@ components:
allOf:
- $ref: '#/components/schemas/BaseMessagesResult'
- properties:
context_management:
nullable: true
properties:
applied_edits:
items:
additionalProperties:
nullable: true
properties:
type:
type: string
required:
- type
type: object
type: array
required:
- applied_edits
type: object
provider:
$ref: '#/components/schemas/ProviderName'
usage:
Expand Down Expand Up @@ -7835,6 +7889,7 @@ components:
- AionLabs
- Alibaba
- Ambient
- Baidu
- Amazon Bedrock
- Amazon Nova
- Anthropic
Expand Down Expand Up @@ -8861,6 +8916,8 @@ components:
service_tier:
nullable: true
type: string
text:
$ref: '#/components/schemas/TextExtendedConfig'
usage:
$ref: '#/components/schemas/Usage'
type: object
Expand Down Expand Up @@ -9248,6 +9305,7 @@ components:
example:
id: ig_tmp_abc123
imageUrl: https://example.com/image.png
result: https://example.com/image.png
status: completed
type: openrouter:image_generation
properties:
Expand All @@ -9257,6 +9315,10 @@ components:
type: string
imageUrl:
type: string
result:
description: The generated image as a base64-encoded string or URL, matching OpenAI image_generation_call format
nullable: true
type: string
revisedPrompt:
type: string
status:
Expand Down Expand Up @@ -9504,6 +9566,7 @@ components:
openrouter:browser_use: '#/components/schemas/OutputBrowserUseServerToolItem'
openrouter:code_interpreter: '#/components/schemas/OutputCodeInterpreterServerToolItem'
openrouter:datetime: '#/components/schemas/OutputDatetimeItem'
openrouter:experimental__search_models: '#/components/schemas/OutputSearchModelsServerToolItem'
openrouter:file_search: '#/components/schemas/OutputFileSearchServerToolItem'
openrouter:image_generation: '#/components/schemas/OutputImageGenerationServerToolItem'
openrouter:mcp: '#/components/schemas/OutputMcpServerToolItem'
Expand Down Expand Up @@ -9545,6 +9608,7 @@ components:
- $ref: '#/components/schemas/OutputToolSearchServerToolItem'
- $ref: '#/components/schemas/OutputMemoryServerToolItem'
- $ref: '#/components/schemas/OutputMcpServerToolItem'
- $ref: '#/components/schemas/OutputSearchModelsServerToolItem'
OutputItemWebSearchCall:
example:
action:
Expand Down Expand Up @@ -9788,6 +9852,32 @@ components:
- text: Analyzed the problem and found the optimal solution.
type: summary_text
type: reasoning
OutputSearchModelsServerToolItem:
description: An openrouter:experimental__search_models server tool output item
example:
arguments: '{"query":"Claude Opus"}'
id: sm_tmp_abc123
query: Claude Opus
status: completed
type: openrouter:experimental__search_models
properties:
arguments:
description: The JSON arguments submitted to the search tool (e.g. {"query":"Claude"})
type: string
id:
type: string
query:
type: string
status:
$ref: '#/components/schemas/ToolCallStatus'
type:
enum:
- openrouter:experimental__search_models
type: string
required:
- status
- type
type: object
OutputTextEditorServerToolItem:
description: An openrouter:text_editor server tool output item
example:
Expand Down Expand Up @@ -10228,6 +10318,7 @@ components:
- AionLabs
- Alibaba
- Ambient
- Baidu
- Amazon Bedrock
- Amazon Nova
- Anthropic
Expand Down Expand Up @@ -10533,6 +10624,7 @@ components:
- AionLabs
- Alibaba
- Ambient
- Baidu
- Amazon Bedrock
- Amazon Nova
- Anthropic
Expand Down Expand Up @@ -11985,7 +12077,18 @@ components:
TextExtendedConfig:
allOf:
- $ref: '#/components/schemas/TextConfig'
- properties: {}
- properties:
verbosity:
enum:
- low
- medium
- high
- xhigh
- max
- null
nullable: true
type: string
x-speakeasy-unknown-values: allow
type: object
description: Text output configuration including format and verbosity
example:
Expand Down Expand Up @@ -12469,6 +12572,10 @@ components:
additionalProperties:
nullable: true
type: object
baidu:
additionalProperties:
nullable: true
type: object
baseten:
additionalProperties:
nullable: true
Expand Down Expand Up @@ -14855,6 +14962,11 @@ paths:
description: User-Agent header from the request
nullable: true
type: string
web_search_engine:
description: The resolved web search engine used for this generation (e.g. exa, firecrawl, parallel)
example: exa
nullable: true
type: string
required:
- id
- upstream_id
Expand Down Expand Up @@ -14882,6 +14994,7 @@ paths:
- num_input_audio_prompt
- num_media_completion
- num_search_results
- web_search_engine
- origin
- usage
- is_byok
Expand Down
11 changes: 6 additions & 5 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ speakeasyVersion: 1.680.0
sources:
OpenRouter API:
sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:3982892b2b8f82bfc2a26a0f6fcc9512b665a1051dc240a9cfa29001b9453aa9
sourceBlobDigest: sha256:727d3c1f7d36ffbf94c57b565536d8a16804eaef4c4043dd6c98152fc1629c8f
sourceRevisionDigest: sha256:08722e0a4c690fe092b1524adfbddb388e84ff8e6e851ee0839f00bdad8dd1f1
sourceBlobDigest: sha256:f7157c6aea54b19cf7524859f989a386f16ecd42684f1463c5d2441b72fcad62
tags:
- latest
- speakeasy-sdk-regen-1776300046
- 1.0.0
targets:
open-router:
source: OpenRouter API
sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:3982892b2b8f82bfc2a26a0f6fcc9512b665a1051dc240a9cfa29001b9453aa9
sourceBlobDigest: sha256:727d3c1f7d36ffbf94c57b565536d8a16804eaef4c4043dd6c98152fc1629c8f
sourceRevisionDigest: sha256:08722e0a4c690fe092b1524adfbddb388e84ff8e6e851ee0839f00bdad8dd1f1
sourceBlobDigest: sha256:f7157c6aea54b19cf7524859f989a386f16ecd42684f1463c5d2441b72fcad62
codeSamplesNamespace: open-router-python-code-samples
codeSamplesRevisionDigest: sha256:db86aed74d199f265e2e20442ef652dac0911c8a657ccb3e6614d56a26b8b44e
codeSamplesRevisionDigest: sha256:6cc9415478b37c7f494e2549a92dbd967f414010b493b75c18730d9e5a6e5c57
workflow:
workflowVersion: 1.0.0
speakeasyVersion: 1.680.0
Expand Down
30 changes: 30 additions & 0 deletions README-PYPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,36 @@ asyncio.run(main())

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

<!-- Start Pagination [pagination] -->
## Pagination

Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
returned response object will have a `Next` method that can be called to pull down the next group of results. If the
return value of `Next` is `None`, then there are no more pages to be fetched.

Here's an example of one such pagination call:
```python
from openrouter import OpenRouter
import os


with OpenRouter(
http_referer="<value>",
x_open_router_title="<value>",
x_open_router_categories="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

res = open_router.guardrails.list()

while res is not None:
# Handle items

res = res.next()

```
<!-- End Pagination [pagination] -->

<!-- Start Resource Management [resource-management] -->
## Resource Management

Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@ Based on:
### Generated
- [python v0.0.16] .
### Releases
- [PyPI v0.0.16] https://pypi.org/project/openrouter/0.0.16 - .
- [PyPI v0.0.16] https://pypi.org/project/openrouter/0.0.16 - .

## 2026-04-18 00:34:54
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.680.0 (2.788.4) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v0.9.2] .
### Releases
- [PyPI v0.9.2] https://pypi.org/project/openrouter/0.9.2 - .
1 change: 1 addition & 0 deletions docs/components/providername.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
| `AION_LABS` | AionLabs |
| `ALIBABA` | Alibaba |
| `AMBIENT` | Ambient |
| `BAIDU` | Baidu |
| `AMAZON_BEDROCK` | Amazon Bedrock |
| `AMAZON_NOVA` | Amazon Nova |
| `ANTHROPIC` | Anthropic |
Expand Down
Loading