Skip to content
Merged
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
43 changes: 22 additions & 21 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ generation:
sdkClassName: OpenRouter
maintainOpenAPIOrder: true
usageSnippets:
optionalPropertyRendering: withExample
optionalPropertyRendering: never
sdkInitStyle: constructor
useClassNamesForArrayFields: true
fixes:
Expand All @@ -24,13 +24,14 @@ generation:
sdkHooksConfigAccess: true
schemas:
allOfMergeStrategy: shallowMerge
requestBodyFieldName: body
requestBodyFieldName: ""
tests:
generateTests: false
generateNewTests: true
skipResponseBodyAssertions: false
preApplyUnionDiscriminators: true
python:
version: 0.1.1
version: 0.0.21
additionalDependencies:
dev: {}
main: {}
Expand All @@ -57,11 +58,12 @@ python:
imports:
option: openapi
paths:
callbacks: ""
callbacks: callbacks
errors: errors
operations: operations
shared: components
webhooks: ""
webhooks: webhooks
inferSSEOverload: true
inferUnionDiscriminators: true
inputModelSuffix: input
legacyPyright: false
Expand Down
14 changes: 12 additions & 2 deletions .speakeasy/out.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3516,6 +3516,7 @@ components:
- Relace
- SambaNova
- SiliconFlow
- Sourceful
- Stealth
- StreamLake
- Switchpoint
Expand Down Expand Up @@ -3816,6 +3817,11 @@ components:
maxLength: 128
description: >-
A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters.
session_id:
type: string
maxLength: 128
description: >-
A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
description: Request schema for Responses endpoint
example:
model: anthropic/claude-4.5-sonnet-20250929
Expand Down Expand Up @@ -6242,6 +6248,11 @@ paths:
- object
- data
- model
text/event-stream:
schema:
type: string
description: Not used for embeddings - embeddings do not support streaming
x-speakeasy-sse-sentinel: '[DONE]'
'400':
description: Bad Request - Invalid request parameters or malformed input
content:
Expand Down Expand Up @@ -6826,6 +6837,7 @@ paths:
- Relace
- SambaNova
- SiliconFlow
- Sourceful
- Stealth
- StreamLake
- Switchpoint
Expand Down Expand Up @@ -8437,5 +8449,3 @@ x-speakeasy-globals:
parameters:
- $ref: "#/components/parameters/AppIdentifier"
- $ref: "#/components/parameters/AppDisplayName"
- $ref: "#/components/parameters/AppIdentifier"
- $ref: "#/components/parameters/AppDisplayName"
21 changes: 14 additions & 7 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,37 @@ sources:
sourceBlobDigest: sha256:ee1f2422281b3ed5b38951c74636ad192c9bb160f216069c1f7931ccc4e52553
tags:
- latest
OpenRouter API:
sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:9b410c8cfafe475dc6d9550f97a1e755b9a02b54513d3a85efe606e9bb05ca57
sourceBlobDigest: sha256:61a2d897cc5ddd893a5131bfacad7fcc311fe5b2eaaa5641fbb0a5b3321bfde7
tags:
- latest
- 1.0.0
targets:
open-router:
source: -OAS
source: OpenRouter API
sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:f1b59b9b643de5e20d6e3299a8274783d8c0854615876f5d7f6f081814842695
sourceBlobDigest: sha256:ee1f2422281b3ed5b38951c74636ad192c9bb160f216069c1f7931ccc4e52553
sourceRevisionDigest: sha256:9b410c8cfafe475dc6d9550f97a1e755b9a02b54513d3a85efe606e9bb05ca57
sourceBlobDigest: sha256:61a2d897cc5ddd893a5131bfacad7fcc311fe5b2eaaa5641fbb0a5b3321bfde7
workflow:
workflowVersion: 1.0.0
speakeasyVersion: 1.666.0
sources:
-OAS:
OpenRouter API:
inputs:
- location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api:main
- location: .speakeasy/in.openapi.yaml
overlays:
- location: .speakeasy/overlays/open-enums.overlay.yaml
- location: .speakeasy/overlays/remove-rss-responses.overlay.yaml
- location: .speakeasy/overlays/add-headers.overlay.yaml
output: .speakeasy/out.openapi.yaml
registry:
location: registry.speakeasyapi.dev/openrouter/sdk/-oas
location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api
targets:
open-router:
target: python
source: -OAS
source: OpenRouter API
publish:
pypi:
token: $pypi_token
Expand Down
10 changes: 5 additions & 5 deletions .speakeasy/workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
workflowVersion: 1.0.0
speakeasyVersion: 1.666.0
sources:
-OAS:
OpenRouter API:
inputs:
- location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api:main
- location: .speakeasy/in.openapi.yaml
overlays:
- location: .speakeasy/overlays/open-enums.overlay.yaml
- location: .speakeasy/overlays/remove-rss-responses.overlay.yaml
- location: .speakeasy/overlays/add-headers.overlay.yaml
output: .speakeasy/out.openapi.yaml
registry:
location: registry.speakeasyapi.dev/openrouter/sdk/-oas
location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api
targets:
open-router:
target: python
source: -OAS
source: OpenRouter API
publish:
pypi:
token: $pypi_token
codeSamples:
registry:
location: registry.speakeasyapi.dev/openrouter/sdk/-oas-python-code-samples
location: registry.speakeasyapi.dev/openrouter/sdk/open-router-python-code-samples
labelOverride:
fixedValue: Python (SDK)
blocking: false
112 changes: 2 additions & 110 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,7 @@ with OpenRouter(
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

res = open_router.beta.responses.send(input=[
{
"type": "message",
"role": "user",
"content": "Hello, how are you?",
},
], metadata={
"user_id": "123",
"session_id": "abc-def-ghi",
}, tools=[
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
},
},
},
},
], model="anthropic/claude-4.5-sonnet-20250929", text={
"format_": {
"type": "text",
},
"verbosity": "medium",
}, reasoning={
"summary": "auto",
"enabled": True,
}, temperature=0.7, top_p=0.9, prompt={
"id": "<id>",
"variables": {
"key": {
"type": "input_text",
"text": "Hello, how can I help you?",
},
},
}, service_tier="auto", truncation="auto", stream=False, provider={
"data_collection": "allow",
"zdr": True,
"enforce_distillable_text": True,
"order": [
"OpenAI",
],
"only": [
"OpenAI",
],
"ignore": [
"OpenAI",
],
"quantizations": None,
"sort": "price",
})
res = open_router.beta.responses.send(service_tier="auto", stream=False)

with res as event_stream:
for event in event_stream:
Expand All @@ -87,61 +33,7 @@ async def main():
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

res = await open_router.beta.responses.send_async(input=[
{
"type": "message",
"role": "user",
"content": "Hello, how are you?",
},
], metadata={
"user_id": "123",
"session_id": "abc-def-ghi",
}, tools=[
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
},
},
},
},
], model="anthropic/claude-4.5-sonnet-20250929", text={
"format_": {
"type": "text",
},
"verbosity": "medium",
}, reasoning={
"summary": "auto",
"enabled": True,
}, temperature=0.7, top_p=0.9, prompt={
"id": "<id>",
"variables": {
"key": {
"type": "input_text",
"text": "Hello, how can I help you?",
},
},
}, service_tier="auto", truncation="auto", stream=False, provider={
"data_collection": "allow",
"zdr": True,
"enforce_distillable_text": True,
"order": [
"OpenAI",
],
"only": [
"OpenAI",
],
"ignore": [
"OpenAI",
],
"quantizations": None,
"sort": "price",
})
res = await open_router.beta.responses.send_async(service_tier="auto", stream=False)

async with res as event_stream:
async for event in event_stream:
Expand Down
3 changes: 2 additions & 1 deletion docs/components/openresponsesrequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ Request schema for Responses endpoint
| `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A | |
| `provider` | [OptionalNullable[components.Provider]](../components/provider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | |
| `plugins` | List[[components.Plugin](../components/plugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
| `user` | *Optional[str]* | :heavy_minus_sign: | A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters. | |
| `user` | *Optional[str]* | :heavy_minus_sign: | A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters. | |
| `session_id` | *Optional[str]* | :heavy_minus_sign: | A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters. | |
1 change: 1 addition & 0 deletions docs/components/providername.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
| `RELACE` | Relace |
| `SAMBA_NOVA` | SambaNova |
| `SILICON_FLOW` | SiliconFlow |
| `SOURCEFUL` | Sourceful |
| `STEALTH` | Stealth |
| `STREAM_LAKE` | StreamLake |
| `SWITCHPOINT` | Switchpoint |
Expand Down
Loading