mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-29 11:23:49 +08:00
chore: 🐝 Update SDK - Generate 0.9.2 (#205)
Co-authored-by: speakeasybot <bot@speakeasyapi.dev> Co-authored-by: speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
speakeasybot
speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
parent
0c735989c1
commit
0f116c9792
@@ -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
|
||||
|
||||
+4366
-528
File diff suppressed because one or more lines are too long
+1
-1
@@ -32,7 +32,7 @@ generation:
|
||||
skipResponseBodyAssertions: false
|
||||
preApplyUnionDiscriminators: true
|
||||
python:
|
||||
version: 0.9.1
|
||||
version: 0.9.2
|
||||
additionalDependencies:
|
||||
dev: {}
|
||||
main: {}
|
||||
|
||||
+11945
-850
File diff suppressed because it is too large
Load Diff
@@ -1,23 +1,24 @@
|
||||
speakeasyVersion: 1.763.2
|
||||
speakeasyVersion: 1.680.0
|
||||
sources:
|
||||
OpenRouter API:
|
||||
sourceNamespace: open-router-chat-completions-api
|
||||
sourceRevisionDigest: sha256:3982892b2b8f82bfc2a26a0f6fcc9512b665a1051dc240a9cfa29001b9453aa9
|
||||
sourceBlobDigest: sha256:727d3c1f7d36ffbf94c57b565536d8a16804eaef4c4043dd6c98152fc1629c8f
|
||||
sourceRevisionDigest: sha256:08108f43d4fba1406b4c8f624792054965c95a14819f442262663cb25ce6cc25
|
||||
sourceBlobDigest: sha256:47fc5915e6a9ff29fca019515d6491adce926407ebb47cee480feb77cfb68f03
|
||||
tags:
|
||||
- latest
|
||||
- speakeasy-sdk-regen-1776991284
|
||||
- 1.0.0
|
||||
targets:
|
||||
open-router:
|
||||
source: OpenRouter API
|
||||
sourceNamespace: open-router-chat-completions-api
|
||||
sourceRevisionDigest: sha256:3982892b2b8f82bfc2a26a0f6fcc9512b665a1051dc240a9cfa29001b9453aa9
|
||||
sourceBlobDigest: sha256:727d3c1f7d36ffbf94c57b565536d8a16804eaef4c4043dd6c98152fc1629c8f
|
||||
sourceRevisionDigest: sha256:08108f43d4fba1406b4c8f624792054965c95a14819f442262663cb25ce6cc25
|
||||
sourceBlobDigest: sha256:47fc5915e6a9ff29fca019515d6491adce926407ebb47cee480feb77cfb68f03
|
||||
codeSamplesNamespace: open-router-python-code-samples
|
||||
codeSamplesRevisionDigest: sha256:db86aed74d199f265e2e20442ef652dac0911c8a657ccb3e6614d56a26b8b44e
|
||||
codeSamplesRevisionDigest: sha256:3c7b0aef799130660fd4017ab9113e6fd3e06a80cff6a540043b9b34dc22facf
|
||||
workflow:
|
||||
workflowVersion: 1.0.0
|
||||
speakeasyVersion: 1.763.2
|
||||
speakeasyVersion: 1.680.0
|
||||
sources:
|
||||
OpenRouter API:
|
||||
inputs:
|
||||
|
||||
@@ -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.byok.list()
|
||||
|
||||
while res is not None:
|
||||
# Handle items
|
||||
|
||||
res = res.next()
|
||||
|
||||
```
|
||||
<!-- End Pagination [pagination] -->
|
||||
|
||||
<!-- Start Resource Management [resource-management] -->
|
||||
## Resource Management
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.guardrails.list()
|
||||
res = open_router.byok.list()
|
||||
|
||||
while res is not None:
|
||||
# Handle items
|
||||
|
||||
+11
-1
@@ -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-06-11 00:55:55
|
||||
### 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,10 +1,12 @@
|
||||
# CostDetails
|
||||
|
||||
Breakdown of upstream inference costs
|
||||
|
||||
|
||||
## 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 |
|
||||
| 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 |
|
||||
@@ -1,10 +0,0 @@
|
||||
# Data
|
||||
|
||||
Model count data
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- |
|
||||
| `count` | *int* | :heavy_check_mark: | Total number of available models | 150 |
|
||||
@@ -1,15 +0,0 @@
|
||||
# Effort
|
||||
|
||||
Constrains effort on reasoning for reasoning models
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| --------- | --------- |
|
||||
| `XHIGH` | xhigh |
|
||||
| `HIGH` | high |
|
||||
| `MEDIUM` | medium |
|
||||
| `LOW` | low |
|
||||
| `MINIMAL` | minimal |
|
||||
| `NONE` | none |
|
||||
@@ -22,4 +22,5 @@ Information about an AI model available on OpenRouter
|
||||
| `per_request_limits` | [Nullable[components.PerRequestLimits]](../components/perrequestlimits.md) | :heavy_check_mark: | Per-request token limits | {<br/>"completion_tokens": 1000,<br/>"prompt_tokens": 1000<br/>} |
|
||||
| `pricing` | [components.PublicPricing](../components/publicpricing.md) | :heavy_check_mark: | Pricing information for the model | {<br/>"completion": "0.00006",<br/>"image": "0",<br/>"prompt": "0.00003",<br/>"request": "0"<br/>} |
|
||||
| `supported_parameters` | List[[components.Parameter](../components/parameter.md)] | :heavy_check_mark: | List of supported parameters for this model | |
|
||||
| `supported_voices` | List[*str*] | :heavy_check_mark: | List of supported voice identifiers for TTS models. Null for non-TTS models. | <nil> |
|
||||
| `top_provider` | [components.TopProviderInfo](../components/topproviderinfo.md) | :heavy_check_mark: | Information about the top provider for this model | {<br/>"context_length": 8192,<br/>"is_moderated": true,<br/>"max_completion_tokens": 4096<br/>} |
|
||||
@@ -5,6 +5,6 @@ Model count data
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
|
||||
| `data` | [components.Data](../components/data.md) | :heavy_check_mark: | Model count data | {<br/>"count": 150<br/>} |
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
|
||||
| `data` | [components.ModelsCountResponseData](../components/modelscountresponsedata.md) | :heavy_check_mark: | Model count data | {<br/>"count": 150<br/>} |
|
||||
@@ -5,6 +5,6 @@ List of available models
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `data` | List[[components.Model](../components/model.md)] | :heavy_check_mark: | List of available models | [<br/>{<br/>"architecture": {<br/>"input_modalities": [<br/>"text"<br/>],<br/>"instruct_type": "chatml",<br/>"modality": "text-\u003etext",<br/>"output_modalities": [<br/>"text"<br/>],<br/>"tokenizer": "GPT"<br/>},<br/>"canonical_slug": "openai/gpt-4",<br/>"context_length": 8192,<br/>"created": 1692901234,<br/>"default_parameters": null,<br/>"description": "GPT-4 is a large multimodal model that can solve difficult problems with greater accuracy.",<br/>"expiration_date": null,<br/>"id": "openai/gpt-4",<br/>"knowledge_cutoff": null,<br/>"links": {<br/>"details": "/api/v1/models/openai/gpt-5.4/endpoints"<br/>},<br/>"name": "GPT-4",<br/>"per_request_limits": null,<br/>"pricing": {<br/>"completion": "0.00006",<br/>"image": "0",<br/>"prompt": "0.00003",<br/>"request": "0"<br/>},<br/>"supported_parameters": [<br/>"temperature",<br/>"top_p",<br/>"max_tokens"<br/>],<br/>"top_provider": {<br/>"context_length": 8192,<br/>"is_moderated": true,<br/>"max_completion_tokens": 4096<br/>}<br/>}<br/>] |
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `data` | List[[components.Model](../components/model.md)] | :heavy_check_mark: | List of available models | [<br/>{<br/>"architecture": {<br/>"input_modalities": [<br/>"text"<br/>],<br/>"instruct_type": "chatml",<br/>"modality": "text-\u003etext",<br/>"output_modalities": [<br/>"text"<br/>],<br/>"tokenizer": "GPT"<br/>},<br/>"canonical_slug": "openai/gpt-4",<br/>"context_length": 8192,<br/>"created": 1692901234,<br/>"default_parameters": null,<br/>"description": "GPT-4 is a large multimodal model that can solve difficult problems with greater accuracy.",<br/>"expiration_date": null,<br/>"id": "openai/gpt-4",<br/>"knowledge_cutoff": null,<br/>"links": {<br/>"details": "/api/v1/models/openai/gpt-5.4/endpoints"<br/>},<br/>"name": "GPT-4",<br/>"per_request_limits": null,<br/>"pricing": {<br/>"completion": "0.00006",<br/>"image": "0",<br/>"prompt": "0.00003",<br/>"request": "0"<br/>},<br/>"supported_parameters": [<br/>"temperature",<br/>"top_p",<br/>"max_tokens"<br/>],<br/>"supported_voices": null,<br/>"top_provider": {<br/>"context_length": 8192,<br/>"is_moderated": true,<br/>"max_completion_tokens": 4096<br/>}<br/>}<br/>] |
|
||||
@@ -39,3 +39,15 @@ value: components.OpenAIResponsesToolChoice = /* values here */
|
||||
value: components.ToolChoiceAllowed = /* values here */
|
||||
```
|
||||
|
||||
### `components.OpenAIResponsesToolChoiceApplyPatch`
|
||||
|
||||
```python
|
||||
value: components.OpenAIResponsesToolChoiceApplyPatch = /* values here */
|
||||
```
|
||||
|
||||
### `components.OpenAIResponsesToolChoiceShell`
|
||||
|
||||
```python
|
||||
value: components.OpenAIResponsesToolChoiceShell = /* values here */
|
||||
```
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------ | ------------ |
|
||||
| `TEXT` | text |
|
||||
| `IMAGE` | image |
|
||||
| `EMBEDDINGS` | embeddings |
|
||||
| `AUDIO` | audio |
|
||||
| `VIDEO` | video |
|
||||
| `RERANK` | rerank |
|
||||
| Name | Value |
|
||||
| --------------- | --------------- |
|
||||
| `TEXT` | text |
|
||||
| `IMAGE` | image |
|
||||
| `EMBEDDINGS` | embeddings |
|
||||
| `AUDIO` | audio |
|
||||
| `VIDEO` | video |
|
||||
| `RERANK` | rerank |
|
||||
| `SPEECH` | speech |
|
||||
| `TRANSCRIPTION` | transcription |
|
||||
@@ -10,6 +10,7 @@
|
||||
| `AION_LABS` | AionLabs |
|
||||
| `ALIBABA` | Alibaba |
|
||||
| `AMBIENT` | Ambient |
|
||||
| `BAIDU` | Baidu |
|
||||
| `AMAZON_BEDROCK` | Amazon Bedrock |
|
||||
| `AMAZON_NOVA` | Amazon Nova |
|
||||
| `ANTHROPIC` | Anthropic |
|
||||
@@ -26,10 +27,14 @@
|
||||
| `CLARIFAI` | Clarifai |
|
||||
| `CLOUDFLARE` | Cloudflare |
|
||||
| `COHERE` | Cohere |
|
||||
| `CRUCIBLE` | Crucible |
|
||||
| `CRUSOE` | Crusoe |
|
||||
| `DARKBLOOM` | Darkbloom |
|
||||
| `DECART` | Decart |
|
||||
| `DEEP_INFRA` | DeepInfra |
|
||||
| `DEEP_SEEK` | DeepSeek |
|
||||
| `DEKA_LLM` | DekaLLM |
|
||||
| `DIGITAL_OCEAN` | DigitalOcean |
|
||||
| `FEATHERLESS` | Featherless |
|
||||
| `FIREWORKS` | Fireworks |
|
||||
| `FRIENDLI` | Friendli |
|
||||
@@ -37,7 +42,6 @@
|
||||
| `GOOGLE` | Google |
|
||||
| `GOOGLE_AI_STUDIO` | Google AI Studio |
|
||||
| `GROQ` | Groq |
|
||||
| `HYPERBOLIC` | Hyperbolic |
|
||||
| `INCEPTION` | Inception |
|
||||
| `INCEPTRON` | Inceptron |
|
||||
| `INFERENCE_NET` | InferenceNet |
|
||||
@@ -56,12 +60,15 @@
|
||||
| `MORPH` | Morph |
|
||||
| `N_COMPASS` | NCompass |
|
||||
| `NEBIUS` | Nebius |
|
||||
| `NEX_AGI` | Nex AGI |
|
||||
| `NEXT_BIT` | NextBit |
|
||||
| `NOVITA` | Novita |
|
||||
| `NVIDIA` | Nvidia |
|
||||
| `OPEN_AI` | OpenAI |
|
||||
| `OPEN_INFERENCE` | OpenInference |
|
||||
| `PARASAIL` | Parasail |
|
||||
| `POOLSIDE` | Poolside |
|
||||
| `PERCEPTRON` | Perceptron |
|
||||
| `PERPLEXITY` | Perplexity |
|
||||
| `PHALA` | Phala |
|
||||
| `RECRAFT` | Recraft |
|
||||
@@ -78,6 +85,7 @@
|
||||
| `TOGETHER` | Together |
|
||||
| `UPSTAGE` | Upstage |
|
||||
| `VENICE` | Venice |
|
||||
| `WAFER` | Wafer |
|
||||
| `WAND_B` | WandB |
|
||||
| `XIAOMI` | Xiaomi |
|
||||
| `X_AI` | xAI |
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# Reasoning
|
||||
|
||||
Configuration options for reasoning models
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
||||
| `effort` | [OptionalNullable[components.Effort]](../components/effort.md) | :heavy_minus_sign: | Constrains effort on reasoning for reasoning models | medium |
|
||||
| `summary` | [OptionalNullable[components.ChatReasoningSummaryVerbosityEnum]](../components/chatreasoningsummaryverbosityenum.md) | :heavy_minus_sign: | N/A | concise |
|
||||
@@ -8,4 +8,5 @@ Bad Gateway - Provider/upstream API failure
|
||||
| Field | Type | Required | Description | Example |
|
||||
| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||||
| `error` | [components.BadGatewayResponseErrorData](../components/badgatewayresponseerrordata.md) | :heavy_check_mark: | Error data for BadGatewayResponse | {<br/>"code": 502,<br/>"message": "Provider returned error"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Bad Request - Invalid request parameters or malformed input
|
||||
| Field | Type | Required | Description | Example |
|
||||
| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||||
| `error` | [components.BadRequestResponseErrorData](../components/badrequestresponseerrordata.md) | :heavy_check_mark: | Error data for BadRequestResponse | {<br/>"code": 400,<br/>"message": "Invalid request parameters"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Infrastructure Timeout - Provider request timed out at edge network
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
||||
| `error` | [components.EdgeNetworkTimeoutResponseErrorData](../components/edgenetworktimeoutresponseerrordata.md) | :heavy_check_mark: | Error data for EdgeNetworkTimeoutResponse | {<br/>"code": 524,<br/>"message": "Request timed out. Please try again later."<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Forbidden - Authentication successful but insufficient permissions
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
|
||||
| `error` | [components.ForbiddenResponseErrorData](../components/forbiddenresponseerrordata.md) | :heavy_check_mark: | Error data for ForbiddenResponse | {<br/>"code": 403,<br/>"message": "Only management keys can perform this operation"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Internal Server Error - Unexpected server error
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| `error` | [components.InternalServerResponseErrorData](../components/internalserverresponseerrordata.md) | :heavy_check_mark: | Error data for InternalServerResponse | {<br/>"code": 500,<br/>"message": "Internal Server Error"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Not Found - Resource does not exist
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
||||
| `error` | [components.NotFoundResponseErrorData](../components/notfoundresponseerrordata.md) | :heavy_check_mark: | Error data for NotFoundResponse | {<br/>"code": 404,<br/>"message": "Resource not found"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Payload Too Large - Request payload exceeds size limits
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
||||
| `error` | [components.PayloadTooLargeResponseErrorData](../components/payloadtoolargeresponseerrordata.md) | :heavy_check_mark: | Error data for PayloadTooLargeResponse | {<br/>"code": 413,<br/>"message": "Request payload too large"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Payment Required - Insufficient credits or quota to complete request
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
||||
| `error` | [components.PaymentRequiredResponseErrorData](../components/paymentrequiredresponseerrordata.md) | :heavy_check_mark: | Error data for PaymentRequiredResponse | {<br/>"code": 402,<br/>"message": "Insufficient credits. Add more using https://openrouter.ai/credits"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Provider Overloaded - Provider is temporarily overloaded
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
||||
| `error` | [components.ProviderOverloadedResponseErrorData](../components/provideroverloadedresponseerrordata.md) | :heavy_check_mark: | Error data for ProviderOverloadedResponse | {<br/>"code": 529,<br/>"message": "Provider returned error"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Request Timeout - Operation exceeded time limit
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| `error` | [components.RequestTimeoutResponseErrorData](../components/requesttimeoutresponseerrordata.md) | :heavy_check_mark: | Error data for RequestTimeoutResponse | {<br/>"code": 408,<br/>"message": "Operation timed out. Please try again later."<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Service Unavailable - Service temporarily unavailable
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
||||
| `error` | [components.ServiceUnavailableResponseErrorData](../components/serviceunavailableresponseerrordata.md) | :heavy_check_mark: | Error data for ServiceUnavailableResponse | {<br/>"code": 503,<br/>"message": "Service temporarily unavailable"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Too Many Requests - Rate limit exceeded
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
||||
| `error` | [components.TooManyRequestsResponseErrorData](../components/toomanyrequestsresponseerrordata.md) | :heavy_check_mark: | Error data for TooManyRequestsResponse | {<br/>"code": 429,<br/>"message": "Rate limit exceeded"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Unauthorized - Authentication required or invalid credentials
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
|
||||
| `error` | [components.UnauthorizedResponseErrorData](../components/unauthorizedresponseerrordata.md) | :heavy_check_mark: | Error data for UnauthorizedResponse | {<br/>"code": 401,<br/>"message": "Missing Authentication header"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -8,4 +8,5 @@ Unprocessable Entity - Semantic validation failure
|
||||
| Field | Type | Required | Description | Example |
|
||||
| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
||||
| `error` | [components.UnprocessableEntityResponseErrorData](../components/unprocessableentityresponseerrordata.md) | :heavy_check_mark: | Error data for UnprocessableEntityResponse | {<br/>"code": 422,<br/>"message": "Invalid argument"<br/>} |
|
||||
| `openrouter_metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A | |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -1,13 +0,0 @@
|
||||
# APIType
|
||||
|
||||
Type of API used for the generation
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------- | ------------- |
|
||||
| `COMPLETIONS` | completions |
|
||||
| `EMBEDDINGS` | embeddings |
|
||||
| `RERANK` | rerank |
|
||||
| `VIDEO` | video |
|
||||
@@ -1,21 +0,0 @@
|
||||
# Category
|
||||
|
||||
Filter models by use case category
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| --------------- | --------------- |
|
||||
| `PROGRAMMING` | programming |
|
||||
| `ROLEPLAY` | roleplay |
|
||||
| `MARKETING` | marketing |
|
||||
| `MARKETING_SEO` | marketing/seo |
|
||||
| `TECHNOLOGY` | technology |
|
||||
| `SCIENCE` | science |
|
||||
| `TRANSLATION` | translation |
|
||||
| `LEGAL` | legal |
|
||||
| `FINANCE` | finance |
|
||||
| `HEALTH` | health |
|
||||
| `TRIVIA` | trivia |
|
||||
| `ACADEMIA` | academia |
|
||||
@@ -15,3 +15,21 @@ value: operations.ContentText = /* values here */
|
||||
value: operations.ContentImageURL = /* values here */
|
||||
```
|
||||
|
||||
### `components.ContentPartInputAudio`
|
||||
|
||||
```python
|
||||
value: components.ContentPartInputAudio = /* values here */
|
||||
```
|
||||
|
||||
### `components.ContentPartInputVideo`
|
||||
|
||||
```python
|
||||
value: components.ContentPartInputVideo = /* values here */
|
||||
```
|
||||
|
||||
### `components.ContentPartInputFile`
|
||||
|
||||
```python
|
||||
value: components.ContentPartInputFile = /* values here */
|
||||
```
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `create_guardrail_request` | [components.CreateGuardrailRequest](../components/createguardrailrequest.md) | :heavy_check_mark: | N/A | {<br/>"allowed_models": null,<br/>"allowed_providers": [<br/>"openai",<br/>"anthropic",<br/>"deepseek"<br/>],<br/>"description": "A guardrail for limiting API usage",<br/>"enforce_zdr": false,<br/>"ignored_models": null,<br/>"ignored_providers": null,<br/>"limit_usd": 50,<br/>"name": "My New Guardrail",<br/>"reset_interval": "monthly"<br/>} |
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `create_guardrail_request` | [components.CreateGuardrailRequest](../components/createguardrailrequest.md) | :heavy_check_mark: | N/A | {<br/>"allowed_models": null,<br/>"allowed_providers": [<br/>"openai",<br/>"anthropic",<br/>"deepseek"<br/>],<br/>"content_filter_builtins": [<br/>{<br/>"action": "block",<br/>"slug": "regex-prompt-injection"<br/>}<br/>],<br/>"content_filters": null,<br/>"description": "A guardrail for limiting API usage",<br/>"enforce_zdr_anthropic": true,<br/>"enforce_zdr_google": false,<br/>"enforce_zdr_openai": true,<br/>"enforce_zdr_other": false,<br/>"ignored_models": null,<br/>"ignored_providers": null,<br/>"limit_usd": 50,<br/>"name": "My New Guardrail",<br/>"reset_interval": "monthly"<br/>} |
|
||||
@@ -26,4 +26,5 @@ The created API key information
|
||||
| `usage` | *float* | :heavy_check_mark: | Total OpenRouter credit usage (in USD) for the API key | 25.5 |
|
||||
| `usage_daily` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC day | 25.5 |
|
||||
| `usage_monthly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC month | 25.5 |
|
||||
| `usage_weekly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday) | 25.5 |
|
||||
| `usage_weekly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday) | 25.5 |
|
||||
| `workspace_id` | *str* | :heavy_check_mark: | The workspace ID this API key belongs to. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
@@ -10,4 +10,5 @@
|
||||
| `include_byok_in_limit` | *Optional[bool]* | :heavy_minus_sign: | Whether to include BYOK usage in the limit | true |
|
||||
| `limit` | *OptionalNullable[float]* | :heavy_minus_sign: | Optional spending limit for the API key in USD | 50 |
|
||||
| `limit_reset` | [OptionalNullable[operations.CreateKeysLimitReset]](../operations/createkeyslimitreset.md) | :heavy_minus_sign: | Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. | monthly |
|
||||
| `name` | *str* | :heavy_check_mark: | Name for the new API key | My New API Key |
|
||||
| `name` | *str* | :heavy_check_mark: | Name for the new API key | My New API Key |
|
||||
| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | The workspace to create the API key in. Defaults to the default workspace if not provided. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
@@ -5,7 +5,7 @@ API key created successfully
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `data` | [operations.CreateKeysData](../operations/createkeysdata.md) | :heavy_check_mark: | The created API key information | {<br/>"byok_usage": 17.38,<br/>"byok_usage_daily": 17.38,<br/>"byok_usage_monthly": 17.38,<br/>"byok_usage_weekly": 17.38,<br/>"created_at": "2025-08-24T10:30:00Z",<br/>"creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",<br/>"disabled": false,<br/>"expires_at": "2027-12-31T23:59:59Z",<br/>"hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943",<br/>"include_byok_in_limit": false,<br/>"label": "sk-or-v1-0e6...1c96",<br/>"limit": 100,<br/>"limit_remaining": 74.5,<br/>"limit_reset": "monthly",<br/>"name": "My Production Key",<br/>"updated_at": "2025-08-24T15:45:00Z",<br/>"usage": 25.5,<br/>"usage_daily": 25.5,<br/>"usage_monthly": 25.5,<br/>"usage_weekly": 25.5<br/>} |
|
||||
| `key` | *str* | :heavy_check_mark: | The actual API key string (only shown once) | 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 |
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `data` | [operations.CreateKeysData](../operations/createkeysdata.md) | :heavy_check_mark: | The created API key information | {<br/>"byok_usage": 17.38,<br/>"byok_usage_daily": 17.38,<br/>"byok_usage_monthly": 17.38,<br/>"byok_usage_weekly": 17.38,<br/>"created_at": "2025-08-24T10:30:00Z",<br/>"creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",<br/>"disabled": false,<br/>"expires_at": "2027-12-31T23:59:59Z",<br/>"hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943",<br/>"include_byok_in_limit": false,<br/>"label": "sk-or-v1-0e6...1c96",<br/>"limit": 100,<br/>"limit_remaining": 74.5,<br/>"limit_reset": "monthly",<br/>"name": "My Production Key",<br/>"updated_at": "2025-08-24T15:45:00Z",<br/>"usage": 25.5,<br/>"usage_daily": 25.5,<br/>"usage_monthly": 25.5,<br/>"usage_weekly": 25.5,<br/>"workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"<br/>} |
|
||||
| `key` | *str* | :heavy_check_mark: | The actual API key string (only shown once) | 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 |
|
||||
@@ -8,4 +8,5 @@
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `x_open_router_metadata` | [Optional[components.MetadataLevel]](../components/metadatalevel.md) | :heavy_minus_sign: | Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility. | enabled |
|
||||
| `responses_request` | [components.ResponsesRequest](../components/responsesrequest.md) | :heavy_check_mark: | N/A | {<br/>"input": [<br/>{<br/>"content": "Hello, how are you?",<br/>"role": "user",<br/>"type": "message"<br/>}<br/>],<br/>"model": "anthropic/claude-4.5-sonnet-20250929",<br/>"temperature": 0.7,<br/>"tools": [<br/>{<br/>"description": "Get the current weather in a given location",<br/>"name": "get_current_weather",<br/>"parameters": {<br/>"properties": {<br/>"location": {<br/>"type": "string"<br/>}<br/>},<br/>"type": "object"<br/>},<br/>"type": "function"<br/>}<br/>],<br/>"top_p": 0.9<br/>} |
|
||||
@@ -1,10 +0,0 @@
|
||||
# CreateResponsesResponseBody
|
||||
|
||||
Successful response
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `data` | [components.StreamEvents](../components/streamevents.md) | :heavy_check_mark: | Union of all possible event types emitted during response streaming | {<br/>"response": {<br/>"created_at": 1704067200,<br/>"error": null,<br/>"id": "resp-abc123",<br/>"incomplete_details": null,<br/>"instructions": null,<br/>"max_output_tokens": null,<br/>"metadata": null,<br/>"model": "gpt-4",<br/>"object": "response",<br/>"output": [],<br/>"parallel_tool_calls": true,<br/>"status": "in_progress",<br/>"temperature": null,<br/>"tool_choice": "auto",<br/>"tools": [],<br/>"top_p": null<br/>},<br/>"sequence_number": 0,<br/>"type": "response.created"<br/>} |
|
||||
@@ -1,47 +0,0 @@
|
||||
# GetGenerationData
|
||||
|
||||
Generation data
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
||||
| `api_type` | [Nullable[operations.APIType]](../operations/apitype.md) | :heavy_check_mark: | Type of API used for the generation | |
|
||||
| `app_id` | *Nullable[int]* | :heavy_check_mark: | ID of the app that made the request | 12345 |
|
||||
| `cache_discount` | *Nullable[float]* | :heavy_check_mark: | Discount applied due to caching | 0.0002 |
|
||||
| `cancelled` | *Nullable[bool]* | :heavy_check_mark: | Whether the generation was cancelled | false |
|
||||
| `created_at` | *str* | :heavy_check_mark: | ISO 8601 timestamp of when the generation was created | 2024-07-15T23:33:19.433273+00:00 |
|
||||
| `external_user` | *Nullable[str]* | :heavy_check_mark: | External user identifier | user-123 |
|
||||
| `finish_reason` | *Nullable[str]* | :heavy_check_mark: | Reason the generation finished | stop |
|
||||
| `generation_time` | *Nullable[float]* | :heavy_check_mark: | Time taken for generation in milliseconds | 1200 |
|
||||
| `http_referer` | *Nullable[str]* | :heavy_check_mark: | Referer header from the request | |
|
||||
| `id` | *str* | :heavy_check_mark: | Unique identifier for the generation | gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG |
|
||||
| `is_byok` | *bool* | :heavy_check_mark: | Whether this used bring-your-own-key | false |
|
||||
| `latency` | *Nullable[float]* | :heavy_check_mark: | Total latency in milliseconds | 1250 |
|
||||
| `model` | *str* | :heavy_check_mark: | Model used for the generation | sao10k/l3-stheno-8b |
|
||||
| `moderation_latency` | *Nullable[float]* | :heavy_check_mark: | Moderation latency in milliseconds | 50 |
|
||||
| `native_finish_reason` | *Nullable[str]* | :heavy_check_mark: | Native finish reason as reported by provider | stop |
|
||||
| `native_tokens_cached` | *Nullable[int]* | :heavy_check_mark: | Native cached tokens as reported by provider | 3 |
|
||||
| `native_tokens_completion` | *Nullable[int]* | :heavy_check_mark: | Native completion tokens as reported by provider | 25 |
|
||||
| `native_tokens_completion_images` | *Nullable[int]* | :heavy_check_mark: | Native completion image tokens as reported by provider | 0 |
|
||||
| `native_tokens_prompt` | *Nullable[int]* | :heavy_check_mark: | Native prompt tokens as reported by provider | 10 |
|
||||
| `native_tokens_reasoning` | *Nullable[int]* | :heavy_check_mark: | Native reasoning tokens as reported by provider | 5 |
|
||||
| `num_input_audio_prompt` | *Nullable[int]* | :heavy_check_mark: | Number of audio inputs in the prompt | 0 |
|
||||
| `num_media_completion` | *Nullable[int]* | :heavy_check_mark: | Number of media items in the completion | 0 |
|
||||
| `num_media_prompt` | *Nullable[int]* | :heavy_check_mark: | Number of media items in the prompt | 1 |
|
||||
| `num_search_results` | *Nullable[int]* | :heavy_check_mark: | Number of search results included | 5 |
|
||||
| `origin` | *str* | :heavy_check_mark: | Origin URL of the request | https://openrouter.ai/ |
|
||||
| `provider_name` | *Nullable[str]* | :heavy_check_mark: | Name of the provider that served the request | Infermatic |
|
||||
| `provider_responses` | List[[components.ProviderResponse](../components/providerresponse.md)] | :heavy_check_mark: | List of provider responses for this generation, including fallback attempts | |
|
||||
| `request_id` | *OptionalNullable[str]* | :heavy_minus_sign: | Unique identifier grouping all generations from a single API request | req-1727282430-aBcDeFgHiJkLmNoPqRsT |
|
||||
| `router` | *Nullable[str]* | :heavy_check_mark: | Router used for the request (e.g., openrouter/auto) | openrouter/auto |
|
||||
| `session_id` | *OptionalNullable[str]* | :heavy_minus_sign: | Session identifier grouping multiple generations in the same session | |
|
||||
| `streamed` | *Nullable[bool]* | :heavy_check_mark: | Whether the response was streamed | true |
|
||||
| `tokens_completion` | *Nullable[int]* | :heavy_check_mark: | Number of tokens in the completion | 25 |
|
||||
| `tokens_prompt` | *Nullable[int]* | :heavy_check_mark: | Number of tokens in the prompt | 10 |
|
||||
| `total_cost` | *float* | :heavy_check_mark: | Total cost of the generation in USD | 0.0015 |
|
||||
| `upstream_id` | *Nullable[str]* | :heavy_check_mark: | Upstream provider's identifier for this generation | chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946 |
|
||||
| `upstream_inference_cost` | *Nullable[float]* | :heavy_check_mark: | Cost charged by the upstream provider | 0.0012 |
|
||||
| `usage` | *float* | :heavy_check_mark: | Usage amount in USD | 0.0015 |
|
||||
| `user_agent` | *Nullable[str]* | :heavy_check_mark: | User-Agent header from the request | |
|
||||
@@ -1,10 +0,0 @@
|
||||
# GetGenerationResponse
|
||||
|
||||
Generation response
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
|
||||
| `data` | [operations.GetGenerationData](../operations/getgenerationdata.md) | :heavy_check_mark: | Generation data |
|
||||
@@ -26,4 +26,5 @@ The API key information
|
||||
| `usage` | *float* | :heavy_check_mark: | Total OpenRouter credit usage (in USD) for the API key | 25.5 |
|
||||
| `usage_daily` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC day | 25.5 |
|
||||
| `usage_monthly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC month | 25.5 |
|
||||
| `usage_weekly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday) | 25.5 |
|
||||
| `usage_weekly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday) | 25.5 |
|
||||
| `workspace_id` | *str* | :heavy_check_mark: | The workspace ID this API key belongs to. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
@@ -5,6 +5,6 @@ API key details
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `data` | [operations.GetKeyData](../operations/getkeydata.md) | :heavy_check_mark: | The API key information | {<br/>"byok_usage": 17.38,<br/>"byok_usage_daily": 17.38,<br/>"byok_usage_monthly": 17.38,<br/>"byok_usage_weekly": 17.38,<br/>"created_at": "2025-08-24T10:30:00Z",<br/>"creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",<br/>"disabled": false,<br/>"expires_at": "2027-12-31T23:59:59Z",<br/>"hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943",<br/>"include_byok_in_limit": false,<br/>"label": "sk-or-v1-0e6...1c96",<br/>"limit": 100,<br/>"limit_remaining": 74.5,<br/>"limit_reset": "monthly",<br/>"name": "My Production Key",<br/>"updated_at": "2025-08-24T15:45:00Z",<br/>"usage": 25.5,<br/>"usage_daily": 25.5,<br/>"usage_monthly": 25.5,<br/>"usage_weekly": 25.5<br/>} |
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `data` | [operations.GetKeyData](../operations/getkeydata.md) | :heavy_check_mark: | The API key information | {<br/>"byok_usage": 17.38,<br/>"byok_usage_daily": 17.38,<br/>"byok_usage_monthly": 17.38,<br/>"byok_usage_weekly": 17.38,<br/>"created_at": "2025-08-24T10:30:00Z",<br/>"creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",<br/>"disabled": false,<br/>"expires_at": "2027-12-31T23:59:59Z",<br/>"hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943",<br/>"include_byok_in_limit": false,<br/>"label": "sk-or-v1-0e6...1c96",<br/>"limit": 100,<br/>"limit_remaining": 74.5,<br/>"limit_reset": "monthly",<br/>"name": "My Production Key",<br/>"updated_at": "2025-08-24T15:45:00Z",<br/>"usage": 25.5,<br/>"usage_daily": 25.5,<br/>"usage_monthly": 25.5,<br/>"usage_weekly": 25.5,<br/>"workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"<br/>} |
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `category` | [Optional[operations.Category]](../operations/category.md) | :heavy_minus_sign: | Filter models by use case category | programming |
|
||||
| `supported_parameters` | *Optional[str]* | :heavy_minus_sign: | Filter models by supported parameter (comma-separated) | temperature |
|
||||
| `output_modalities` | *Optional[str]* | :heavy_minus_sign: | Filter models by output modality. Accepts a comma-separated list of modalities (text, image, audio, embeddings) or "all" to include all models. Defaults to "text". | text |
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `category` | [Optional[operations.GetModelsCategory]](../operations/getmodelscategory.md) | :heavy_minus_sign: | Filter models by use case category | programming |
|
||||
| `supported_parameters` | *Optional[str]* | :heavy_minus_sign: | Filter models by supported parameter (comma-separated) | temperature |
|
||||
| `output_modalities` | *Optional[str]* | :heavy_minus_sign: | Filter models by output modality. Accepts a comma-separated list of modalities (text, image, audio, embeddings) or "all" to include all models. Defaults to "text". | text |
|
||||
| `sort` | [Optional[operations.GetModelsSort]](../operations/getmodelssort.md) | :heavy_minus_sign: | Sort the returned models server-side. Prefer this over fetching the full list and sorting client-side. Options: pricing-low-to-high, pricing-high-to-low (average prompt/completion price), context-high-to-low (context length), throughput-high-to-low, latency-low-to-high (recent median performance), most-popular, top-weekly (tokens processed in the last week), newest (creation date). When omitted, the existing default ordering is preserved. | newest |
|
||||
@@ -24,4 +24,5 @@
|
||||
| `usage` | *float* | :heavy_check_mark: | Total OpenRouter credit usage (in USD) for the API key | 25.5 |
|
||||
| `usage_daily` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC day | 25.5 |
|
||||
| `usage_monthly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC month | 25.5 |
|
||||
| `usage_weekly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday) | 25.5 |
|
||||
| `usage_weekly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday) | 25.5 |
|
||||
| `workspace_id` | *str* | :heavy_check_mark: | The workspace ID this API key belongs to. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
@@ -9,4 +9,5 @@
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `offset` | *Optional[int]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
|
||||
| `limit` | *Optional[int]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
|
||||
| `limit` | *Optional[int]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
|
||||
| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | Filter guardrails by workspace ID. By default, guardrails in the default workspace are returned. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `result` | [components.ListGuardrailsResponse](../components/listguardrailsresponse.md) | :heavy_check_mark: | N/A | {<br/>"data": [<br/>{<br/>"allowed_models": null,<br/>"allowed_providers": [<br/>"openai",<br/>"anthropic",<br/>"google"<br/>],<br/>"created_at": "2025-08-24T10:30:00Z",<br/>"description": "Guardrail for production environment",<br/>"enforce_zdr": false,<br/>"id": "550e8400-e29b-41d4-a716-446655440000",<br/>"ignored_models": null,<br/>"ignored_providers": null,<br/>"limit_usd": 100,<br/>"name": "Production Guardrail",<br/>"reset_interval": "monthly",<br/>"updated_at": "2025-08-24T15:45:00Z"<br/>}<br/>],<br/>"total_count": 1<br/>} |
|
||||
| Field | Type | Required | Description | Example |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `result` | [components.ListGuardrailsResponse](../components/listguardrailsresponse.md) | :heavy_check_mark: | N/A | {<br/>"data": [<br/>{<br/>"allowed_models": null,<br/>"allowed_providers": [<br/>"openai",<br/>"anthropic",<br/>"google"<br/>],<br/>"content_filter_builtins": [<br/>{<br/>"action": "redact",<br/>"label": "[EMAIL]",<br/>"slug": "email"<br/>}<br/>],<br/>"content_filters": null,<br/>"created_at": "2025-08-24T10:30:00Z",<br/>"description": "Guardrail for production environment",<br/>"enforce_zdr": null,<br/>"enforce_zdr_anthropic": true,<br/>"enforce_zdr_google": false,<br/>"enforce_zdr_openai": true,<br/>"enforce_zdr_other": false,<br/>"id": "550e8400-e29b-41d4-a716-446655440000",<br/>"ignored_models": null,<br/>"ignored_providers": null,<br/>"limit_usd": 100,<br/>"name": "Production Guardrail",<br/>"reset_interval": "monthly",<br/>"updated_at": "2025-08-24T15:45:00Z",<br/>"workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"<br/>}<br/>],<br/>"total_count": 1<br/>} |
|
||||
@@ -9,4 +9,5 @@
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `include_disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether to include disabled API keys in the response | false |
|
||||
| `offset` | *Optional[int]* | :heavy_minus_sign: | Number of API keys to skip for pagination | 0 |
|
||||
| `offset` | *Optional[int]* | :heavy_minus_sign: | Number of API keys to skip for pagination | 0 |
|
||||
| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | Filter API keys by workspace ID. By default, keys in the default workspace are returned. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
@@ -8,4 +8,5 @@
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `x_open_router_metadata` | [Optional[components.MetadataLevel]](../components/metadatalevel.md) | :heavy_minus_sign: | Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility. | enabled |
|
||||
| `chat_request` | [components.ChatRequest](../components/chatrequest.md) | :heavy_check_mark: | N/A | {<br/>"max_tokens": 150,<br/>"messages": [<br/>{<br/>"content": "You are a helpful assistant.",<br/>"role": "system"<br/>},<br/>{<br/>"content": "What is the capital of France?",<br/>"role": "user"<br/>}<br/>],<br/>"model": "openai/gpt-4",<br/>"temperature": 0.7<br/>} |
|
||||
@@ -1,10 +0,0 @@
|
||||
# SendChatCompletionRequestResponseBody
|
||||
|
||||
Successful chat completion response
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `data` | [components.ChatStreamChunk](../components/chatstreamchunk.md) | :heavy_check_mark: | Streaming chat completion chunk | {<br/>"choices": [<br/>{<br/>"delta": {<br/>"content": "Hello",<br/>"role": "assistant"<br/>},<br/>"finish_reason": null,<br/>"index": 0<br/>}<br/>],<br/>"created": 1677652288,<br/>"id": "chatcmpl-123",<br/>"model": "openai/gpt-4",<br/>"object": "chat.completion.chunk"<br/>} |
|
||||
@@ -26,4 +26,5 @@ The updated API key information
|
||||
| `usage` | *float* | :heavy_check_mark: | Total OpenRouter credit usage (in USD) for the API key | 25.5 |
|
||||
| `usage_daily` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC day | 25.5 |
|
||||
| `usage_monthly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC month | 25.5 |
|
||||
| `usage_weekly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday) | 25.5 |
|
||||
| `usage_weekly` | *float* | :heavy_check_mark: | OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday) | 25.5 |
|
||||
| `workspace_id` | *str* | :heavy_check_mark: | The workspace ID this API key belongs to. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
@@ -5,6 +5,6 @@ API key updated successfully
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `data` | [operations.UpdateKeysData](../operations/updatekeysdata.md) | :heavy_check_mark: | The updated API key information | {<br/>"byok_usage": 17.38,<br/>"byok_usage_daily": 17.38,<br/>"byok_usage_monthly": 17.38,<br/>"byok_usage_weekly": 17.38,<br/>"created_at": "2025-08-24T10:30:00Z",<br/>"creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",<br/>"disabled": false,<br/>"expires_at": "2027-12-31T23:59:59Z",<br/>"hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943",<br/>"include_byok_in_limit": false,<br/>"label": "sk-or-v1-0e6...1c96",<br/>"limit": 100,<br/>"limit_remaining": 74.5,<br/>"limit_reset": "monthly",<br/>"name": "My Production Key",<br/>"updated_at": "2025-08-24T15:45:00Z",<br/>"usage": 25.5,<br/>"usage_daily": 25.5,<br/>"usage_monthly": 25.5,<br/>"usage_weekly": 25.5<br/>} |
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `data` | [operations.UpdateKeysData](../operations/updatekeysdata.md) | :heavy_check_mark: | The updated API key information | {<br/>"byok_usage": 17.38,<br/>"byok_usage_daily": 17.38,<br/>"byok_usage_monthly": 17.38,<br/>"byok_usage_weekly": 17.38,<br/>"created_at": "2025-08-24T10:30:00Z",<br/>"creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",<br/>"disabled": false,<br/>"expires_at": "2027-12-31T23:59:59Z",<br/>"hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943",<br/>"include_byok_in_limit": false,<br/>"label": "sk-or-v1-0e6...1c96",<br/>"limit": 100,<br/>"limit_remaining": 74.5,<br/>"limit_reset": "monthly",<br/>"name": "My Production Key",<br/>"updated_at": "2025-08-24T15:45:00Z",<br/>"usage": 25.5,<br/>"usage_daily": 25.5,<br/>"usage_monthly": 25.5,<br/>"usage_weekly": 25.5,<br/>"workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"<br/>} |
|
||||
@@ -95,6 +95,7 @@ with OpenRouter(
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `include_disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether to include disabled API keys in the response | false |
|
||||
| `offset` | *Optional[int]* | :heavy_minus_sign: | Number of API keys to skip for pagination | 0 |
|
||||
| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | Filter API keys by workspace ID. By default, keys in the default workspace are returned. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
|
||||
### Response
|
||||
@@ -150,6 +151,7 @@ with OpenRouter(
|
||||
| `include_byok_in_limit` | *Optional[bool]* | :heavy_minus_sign: | Whether to include BYOK usage in the limit | true |
|
||||
| `limit` | *OptionalNullable[float]* | :heavy_minus_sign: | Optional spending limit for the API key in USD | 50 |
|
||||
| `limit_reset` | [OptionalNullable[operations.CreateKeysLimitReset]](../../operations/createkeyslimitreset.md) | :heavy_minus_sign: | Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. | monthly |
|
||||
| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | The workspace to create the API key in. Defaults to the default workspace if not provided. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
|
||||
### Response
|
||||
@@ -162,6 +164,7 @@ with OpenRouter(
|
||||
| ----------------------------------- | ----------------------------------- | ----------------------------------- |
|
||||
| errors.BadRequestResponseError | 400 | application/json |
|
||||
| errors.UnauthorizedResponseError | 401 | application/json |
|
||||
| errors.ForbiddenResponseError | 403 | application/json |
|
||||
| errors.TooManyRequestsResponseError | 429 | application/json |
|
||||
| errors.InternalServerResponseError | 500 | application/json |
|
||||
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |
|
||||
|
||||
+42
-39
@@ -34,7 +34,7 @@ with OpenRouter(
|
||||
"content": "What is the capital of France?",
|
||||
"role": "user",
|
||||
},
|
||||
], max_tokens=150, model="openai/gpt-4", stream=False, temperature=0.7)
|
||||
], x_open_router_metadata="enabled", max_tokens=150, model="openai/gpt-4", stream=False, temperature=0.7)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
@@ -45,44 +45,46 @@ with OpenRouter(
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `messages` | List[[components.ChatMessages](../../components/chatmessages.md)] | :heavy_check_mark: | List of messages for the conversation | [<br/>{<br/>"content": "Hello!",<br/>"role": "user"<br/>}<br/>] |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `cache_control` | [Optional[components.AnthropicCacheControlDirective]](../../components/anthropiccachecontroldirective.md) | :heavy_minus_sign: | N/A | {<br/>"type": "ephemeral"<br/>} |
|
||||
| `debug` | [Optional[components.ChatDebugOptions]](../../components/chatdebugoptions.md) | :heavy_minus_sign: | Debug options for inspecting request transformations (streaming only) | {<br/>"echo_upstream_body": true<br/>} |
|
||||
| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Frequency penalty (-2.0 to 2.0) | 0 |
|
||||
| `image_config` | Dict[str, [components.ImageConfig](../../components/imageconfig.md)] | :heavy_minus_sign: | Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. | {<br/>"aspect_ratio": "16:9",<br/>"quality": "high"<br/>} |
|
||||
| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | Token logit bias adjustments | {<br/>"50256": -100<br/>} |
|
||||
| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | Return log probabilities | false |
|
||||
| `max_completion_tokens` | *OptionalNullable[int]* | :heavy_minus_sign: | Maximum tokens in completion | 100 |
|
||||
| `max_tokens` | *OptionalNullable[int]* | :heavy_minus_sign: | Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16. | 100 |
|
||||
| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | {<br/>"session_id": "session-456",<br/>"user_id": "user-123"<br/>} |
|
||||
| `modalities` | List[[components.Modality](../../components/modality.md)] | :heavy_minus_sign: | Output modalities for the response. Supported values are "text", "image", and "audio". | [<br/>"text",<br/>"image"<br/>] |
|
||||
| `model` | *Optional[str]* | :heavy_minus_sign: | Model to use for completion | openai/gpt-4 |
|
||||
| `models` | List[*str*] | :heavy_minus_sign: | Models to use for completion | [<br/>"openai/gpt-4",<br/>"openai/gpt-4o"<br/>] |
|
||||
| `parallel_tool_calls` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enable parallel function calling during tool use. When true, the model may generate multiple tool calls in a single response. | true |
|
||||
| `plugins` | List[[components.ChatRequestPlugin](../../components/chatrequestplugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
|
||||
| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Presence penalty (-2.0 to 2.0) | 0 |
|
||||
| `provider` | [OptionalNullable[components.ProviderPreferences]](../../components/providerpreferences.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | {<br/>"allow_fallbacks": true<br/>} |
|
||||
| `reasoning` | [Optional[components.Reasoning]](../../components/reasoning.md) | :heavy_minus_sign: | Configuration options for reasoning models | {<br/>"effort": "medium",<br/>"summary": "concise"<br/>} |
|
||||
| `response_format` | [Optional[components.ResponseFormat]](../../components/responseformat.md) | :heavy_minus_sign: | Response format configuration | {<br/>"type": "json_object"<br/>} |
|
||||
| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | Random seed for deterministic outputs | 42 |
|
||||
| `service_tier` | [OptionalNullable[components.ChatRequestServiceTier]](../../components/chatrequestservicetier.md) | :heavy_minus_sign: | The service tier to use for processing this request. | auto |
|
||||
| `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 256 characters. | |
|
||||
| `stop` | [OptionalNullable[components.Stop]](../../components/stop.md) | :heavy_minus_sign: | Stop sequences (up to 4) | [<br/>""<br/>] |
|
||||
| `stream` | *Optional[bool]* | :heavy_minus_sign: | Enable streaming response | false |
|
||||
| `stream_options` | [OptionalNullable[components.ChatStreamOptions]](../../components/chatstreamoptions.md) | :heavy_minus_sign: | Streaming configuration options | {<br/>"include_usage": true<br/>} |
|
||||
| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | Sampling temperature (0-2) | 0.7 |
|
||||
| `tool_choice` | [Optional[components.ChatToolChoice]](../../components/chattoolchoice.md) | :heavy_minus_sign: | Tool choice configuration | auto |
|
||||
| `tools` | List[[components.ChatFunctionTool](../../components/chatfunctiontool.md)] | :heavy_minus_sign: | Available tools for function calling | [<br/>{<br/>"function": {<br/>"description": "Get weather",<br/>"name": "get_weather"<br/>},<br/>"type": "function"<br/>}<br/>] |
|
||||
| `top_logprobs` | *OptionalNullable[int]* | :heavy_minus_sign: | Number of top log probabilities to return (0-20) | 5 |
|
||||
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | Nucleus sampling parameter (0-1) | 1 |
|
||||
| `trace` | [Optional[components.TraceConfig]](../../components/traceconfig.md) | :heavy_minus_sign: | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | {<br/>"trace_id": "trace-abc123",<br/>"trace_name": "my-app-trace"<br/>} |
|
||||
| `user` | *Optional[str]* | :heavy_minus_sign: | Unique user identifier | user-123 |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `messages` | List[[components.ChatMessages](../../components/chatmessages.md)] | :heavy_check_mark: | List of messages for the conversation | [<br/>{<br/>"content": "Hello!",<br/>"role": "user"<br/>}<br/>] |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `x_open_router_metadata` | [Optional[components.MetadataLevel]](../../components/metadatalevel.md) | :heavy_minus_sign: | Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility. | enabled |
|
||||
| `cache_control` | [Optional[components.AnthropicCacheControlDirective]](../../components/anthropiccachecontroldirective.md) | :heavy_minus_sign: | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models. | {<br/>"type": "ephemeral"<br/>} |
|
||||
| `debug` | [Optional[components.ChatDebugOptions]](../../components/chatdebugoptions.md) | :heavy_minus_sign: | Debug options for inspecting request transformations (streaming only) | {<br/>"echo_upstream_body": true<br/>} |
|
||||
| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Frequency penalty (-2.0 to 2.0) | 0 |
|
||||
| `image_config` | Dict[str, [components.ImageConfig](../../components/imageconfig.md)] | :heavy_minus_sign: | Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. | {<br/>"aspect_ratio": "16:9",<br/>"quality": "high"<br/>} |
|
||||
| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | Token logit bias adjustments | {<br/>"50256": -100<br/>} |
|
||||
| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | Return log probabilities | false |
|
||||
| `max_completion_tokens` | *OptionalNullable[int]* | :heavy_minus_sign: | Maximum tokens in completion | 100 |
|
||||
| `max_tokens` | *OptionalNullable[int]* | :heavy_minus_sign: | Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16. | 100 |
|
||||
| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | {<br/>"session_id": "session-456",<br/>"user_id": "user-123"<br/>} |
|
||||
| `modalities` | List[[components.Modality](../../components/modality.md)] | :heavy_minus_sign: | Output modalities for the response. Supported values are "text", "image", and "audio". | [<br/>"text",<br/>"image"<br/>] |
|
||||
| `model` | *Optional[str]* | :heavy_minus_sign: | Model to use for completion | openai/gpt-4 |
|
||||
| `models` | List[*str*] | :heavy_minus_sign: | Models to use for completion | [<br/>"openai/gpt-4",<br/>"openai/gpt-4o"<br/>] |
|
||||
| `parallel_tool_calls` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enable parallel function calling during tool use. When true, the model may generate multiple tool calls in a single response. | true |
|
||||
| `plugins` | List[[components.ChatRequestPlugin](../../components/chatrequestplugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
|
||||
| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Presence penalty (-2.0 to 2.0) | 0 |
|
||||
| `provider` | [OptionalNullable[components.ProviderPreferences]](../../components/providerpreferences.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | {<br/>"allow_fallbacks": true<br/>} |
|
||||
| `reasoning` | [Optional[components.ChatRequestReasoning]](../../components/chatrequestreasoning.md) | :heavy_minus_sign: | Configuration options for reasoning models | {<br/>"effort": "medium",<br/>"summary": "concise"<br/>} |
|
||||
| `response_format` | [Optional[components.ResponseFormat]](../../components/responseformat.md) | :heavy_minus_sign: | Response format configuration | {<br/>"type": "json_object"<br/>} |
|
||||
| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | Random seed for deterministic outputs | 42 |
|
||||
| `service_tier` | [OptionalNullable[components.ChatRequestServiceTier]](../../components/chatrequestservicetier.md) | :heavy_minus_sign: | The service tier to use for processing this request. | auto |
|
||||
| `session_id` | *Optional[str]* | :heavy_minus_sign: | A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. | |
|
||||
| `stop` | [OptionalNullable[components.Stop]](../../components/stop.md) | :heavy_minus_sign: | Stop sequences (up to 4) | [<br/>""<br/>] |
|
||||
| `stop_server_tools_when` | List[[components.StopServerToolsWhenCondition](../../components/stopservertoolswhencondition.md)] | :heavy_minus_sign: | Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. | [<br/>{<br/>"step_count": 5,<br/>"type": "step_count_is"<br/>},<br/>{<br/>"max_cost_in_dollars": 0.5,<br/>"type": "max_cost"<br/>}<br/>] |
|
||||
| `stream` | *Optional[bool]* | :heavy_minus_sign: | Enable streaming response | false |
|
||||
| `stream_options` | [OptionalNullable[components.ChatStreamOptions]](../../components/chatstreamoptions.md) | :heavy_minus_sign: | Streaming configuration options | {<br/>"include_usage": true<br/>} |
|
||||
| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | Sampling temperature (0-2) | 0.7 |
|
||||
| `tool_choice` | [Optional[components.ChatToolChoice]](../../components/chattoolchoice.md) | :heavy_minus_sign: | Tool choice configuration | auto |
|
||||
| `tools` | List[[components.ChatFunctionTool](../../components/chatfunctiontool.md)] | :heavy_minus_sign: | Available tools for function calling | [<br/>{<br/>"function": {<br/>"description": "Get weather",<br/>"name": "get_weather"<br/>},<br/>"type": "function"<br/>}<br/>] |
|
||||
| `top_logprobs` | *OptionalNullable[int]* | :heavy_minus_sign: | Number of top log probabilities to return (0-20) | 5 |
|
||||
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | Nucleus sampling parameter (0-1) | 1 |
|
||||
| `trace` | [Optional[components.TraceConfig]](../../components/traceconfig.md) | :heavy_minus_sign: | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | {<br/>"trace_id": "trace-abc123",<br/>"trace_name": "my-app-trace"<br/>} |
|
||||
| `user` | *Optional[str]* | :heavy_minus_sign: | Unique user identifier | user-123 |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
|
||||
### Response
|
||||
|
||||
@@ -95,6 +97,7 @@ with OpenRouter(
|
||||
| errors.BadRequestResponseError | 400 | application/json |
|
||||
| errors.UnauthorizedResponseError | 401 | application/json |
|
||||
| errors.PaymentRequiredResponseError | 402 | application/json |
|
||||
| errors.ForbiddenResponseError | 403 | application/json |
|
||||
| errors.NotFoundResponseError | 404 | application/json |
|
||||
| errors.RequestTimeoutResponseError | 408 | application/json |
|
||||
| errors.PayloadTooLargeResponseError | 413 | application/json |
|
||||
|
||||
@@ -7,6 +7,7 @@ Generation history endpoints
|
||||
### Available Operations
|
||||
|
||||
* [get_generation](#get_generation) - Get request & usage metadata for a generation
|
||||
* [list_generation_content](#list_generation_content) - Get stored prompt and completion content for a generation
|
||||
|
||||
## get_generation
|
||||
|
||||
@@ -46,7 +47,7 @@ with OpenRouter(
|
||||
|
||||
### Response
|
||||
|
||||
**[operations.GetGenerationResponse](../../operations/getgenerationresponse.md)**
|
||||
**[components.GenerationResponse](../../components/generationresponse.md)**
|
||||
|
||||
### Errors
|
||||
|
||||
@@ -60,4 +61,58 @@ with OpenRouter(
|
||||
| errors.BadGatewayResponseError | 502 | application/json |
|
||||
| errors.EdgeNetworkTimeoutResponseError | 524 | application/json |
|
||||
| errors.ProviderOverloadedResponseError | 529 | application/json |
|
||||
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |
|
||||
|
||||
## list_generation_content
|
||||
|
||||
Get stored prompt and completion content for a generation
|
||||
|
||||
### Example Usage
|
||||
|
||||
<!-- UsageSnippet language="python" operationID="listGenerationContent" method="get" path="/generation/content" -->
|
||||
```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.generations.list_generation_content(id="gen-1234567890")
|
||||
|
||||
# Handle response
|
||||
print(res)
|
||||
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `id` | *str* | :heavy_check_mark: | The generation ID | gen-1234567890 |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
|
||||
### Response
|
||||
|
||||
**[components.GenerationContentResponse](../../components/generationcontentresponse.md)**
|
||||
|
||||
### Errors
|
||||
|
||||
| Error Type | Status Code | Content Type |
|
||||
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
|
||||
| errors.UnauthorizedResponseError | 401 | application/json |
|
||||
| errors.ForbiddenResponseError | 403 | application/json |
|
||||
| errors.NotFoundResponseError | 404 | application/json |
|
||||
| errors.TooManyRequestsResponseError | 429 | application/json |
|
||||
| errors.InternalServerResponseError | 500 | application/json |
|
||||
| errors.BadGatewayResponseError | 502 | application/json |
|
||||
| errors.EdgeNetworkTimeoutResponseError | 524 | application/json |
|
||||
| errors.ProviderOverloadedResponseError | 529 | application/json |
|
||||
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |
|
||||
@@ -57,6 +57,7 @@ with OpenRouter(
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `offset` | *Optional[int]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
|
||||
| `limit` | *Optional[int]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
|
||||
| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | Filter guardrails by workspace ID. By default, guardrails in the default workspace are returned. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
|
||||
### Response
|
||||
@@ -94,7 +95,7 @@ with OpenRouter(
|
||||
"openai",
|
||||
"anthropic",
|
||||
"deepseek",
|
||||
], description="A guardrail for limiting API usage", enforce_zdr=False, ignored_models=None, ignored_providers=None, limit_usd=50, reset_interval="monthly")
|
||||
], description="A guardrail for limiting API usage", enforce_zdr_anthropic=True, enforce_zdr_google=False, enforce_zdr_openai=True, enforce_zdr_other=False, ignored_models=None, ignored_providers=None, limit_usd=50, reset_interval="monthly")
|
||||
|
||||
# Handle response
|
||||
print(res)
|
||||
@@ -103,21 +104,28 @@ with OpenRouter(
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `name` | *str* | :heavy_check_mark: | Name for the new guardrail | My New Guardrail |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `allowed_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers (slug or canonical_slug accepted) | [<br/>"openai/gpt-5.2",<br/>"anthropic/claude-4.5-opus-20251124",<br/>"deepseek/deepseek-r1-0528:free"<br/>] |
|
||||
| `allowed_providers` | List[*str*] | :heavy_minus_sign: | List of allowed provider IDs | [<br/>"openai",<br/>"anthropic",<br/>"deepseek"<br/>] |
|
||||
| `description` | *OptionalNullable[str]* | :heavy_minus_sign: | Description of the guardrail | A guardrail for limiting API usage |
|
||||
| `enforce_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention | false |
|
||||
| `ignored_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers to exclude from routing (slug or canonical_slug accepted) | [<br/>"openai/gpt-4o-mini"<br/>] |
|
||||
| `ignored_providers` | List[*str*] | :heavy_minus_sign: | List of provider IDs to exclude from routing | [<br/>"azure"<br/>] |
|
||||
| `limit_usd` | *OptionalNullable[float]* | :heavy_minus_sign: | Spending limit in USD | 50 |
|
||||
| `reset_interval` | [OptionalNullable[components.GuardrailInterval]](../../components/guardrailinterval.md) | :heavy_minus_sign: | Interval at which the limit resets (daily, weekly, monthly) | monthly |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `name` | *str* | :heavy_check_mark: | Name for the new guardrail | My New Guardrail |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `allowed_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers (slug or canonical_slug accepted) | [<br/>"openai/gpt-5.2",<br/>"anthropic/claude-4.5-opus-20251124",<br/>"deepseek/deepseek-r1-0528:free"<br/>] |
|
||||
| `allowed_providers` | List[*str*] | :heavy_minus_sign: | List of allowed provider IDs | [<br/>"openai",<br/>"anthropic",<br/>"deepseek"<br/>] |
|
||||
| `content_filter_builtins` | List[[components.ContentFilterBuiltinEntryInput](../../components/contentfilterbuiltinentryinput.md)] | :heavy_minus_sign: | Builtin content filters to apply. The "flag" action is only supported for "regex-prompt-injection"; PII slugs (email, phone, ssn, credit-card, ip-address, person-name, address) accept "block" or "redact" only. | [<br/>{<br/>"action": "block",<br/>"slug": "regex-prompt-injection"<br/>}<br/>] |
|
||||
| `content_filters` | List[[components.ContentFilterEntry](../../components/contentfilterentry.md)] | :heavy_minus_sign: | Custom regex content filters to apply to request messages | [<br/>{<br/>"action": "redact",<br/>"label": "[API_KEY]",<br/>"pattern": "\\b(sk-[a-zA-Z0-9]{48})\\b"<br/>}<br/>] |
|
||||
| `description` | *OptionalNullable[str]* | :heavy_minus_sign: | Description of the guardrail | A guardrail for limiting API usage |
|
||||
| `enforce_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.<br/><br/>Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, and enforce_zdr_other instead. When provided, its value is copied into any of those per-provider fields that are not explicitly specified on the request. | false |
|
||||
| `enforce_zdr_anthropic` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided. | false |
|
||||
| `enforce_zdr_google` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided. | false |
|
||||
| `enforce_zdr_openai` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided. | false |
|
||||
| `enforce_zdr_other` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, or Google. Falls back to enforce_zdr when not provided. | false |
|
||||
| `ignored_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers to exclude from routing (slug or canonical_slug accepted) | [<br/>"openai/gpt-4o-mini"<br/>] |
|
||||
| `ignored_providers` | List[*str*] | :heavy_minus_sign: | List of provider IDs to exclude from routing | [<br/>"azure"<br/>] |
|
||||
| `limit_usd` | *OptionalNullable[float]* | :heavy_minus_sign: | Spending limit in USD | 50 |
|
||||
| `reset_interval` | [OptionalNullable[components.GuardrailInterval]](../../components/guardrailinterval.md) | :heavy_minus_sign: | Interval at which the limit resets (daily, weekly, monthly) | monthly |
|
||||
| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | The workspace to create the guardrail in. Defaults to the default workspace if not provided. | 0df9e665-d932-5740-b2c7-b52af166bc11 |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
|
||||
### Response
|
||||
|
||||
@@ -129,6 +137,7 @@ with OpenRouter(
|
||||
| ---------------------------------- | ---------------------------------- | ---------------------------------- |
|
||||
| errors.BadRequestResponseError | 400 | application/json |
|
||||
| errors.UnauthorizedResponseError | 401 | application/json |
|
||||
| errors.ForbiddenResponseError | 403 | application/json |
|
||||
| errors.InternalServerResponseError | 500 | application/json |
|
||||
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |
|
||||
|
||||
@@ -258,22 +267,28 @@ with OpenRouter(
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail to update | 550e8400-e29b-41d4-a716-446655440000 |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `allowed_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers (slug or canonical_slug accepted) | [<br/>"openai/gpt-5.2"<br/>] |
|
||||
| `allowed_providers` | List[*str*] | :heavy_minus_sign: | New list of allowed provider IDs | [<br/>"openai",<br/>"anthropic",<br/>"deepseek"<br/>] |
|
||||
| `description` | *OptionalNullable[str]* | :heavy_minus_sign: | New description for the guardrail | Updated description |
|
||||
| `enforce_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention | true |
|
||||
| `ignored_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers to exclude from routing (slug or canonical_slug accepted) | [<br/>"openai/gpt-4o-mini"<br/>] |
|
||||
| `ignored_providers` | List[*str*] | :heavy_minus_sign: | List of provider IDs to exclude from routing | [<br/>"azure"<br/>] |
|
||||
| `limit_usd` | *OptionalNullable[float]* | :heavy_minus_sign: | New spending limit in USD | 75 |
|
||||
| `name` | *Optional[str]* | :heavy_minus_sign: | New name for the guardrail | Updated Guardrail Name |
|
||||
| `reset_interval` | [OptionalNullable[components.GuardrailInterval]](../../components/guardrailinterval.md) | :heavy_minus_sign: | Interval at which the limit resets (daily, weekly, monthly) | monthly |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail to update | 550e8400-e29b-41d4-a716-446655440000 |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `allowed_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers (slug or canonical_slug accepted) | [<br/>"openai/gpt-5.2"<br/>] |
|
||||
| `allowed_providers` | List[*str*] | :heavy_minus_sign: | New list of allowed provider IDs | [<br/>"openai",<br/>"anthropic",<br/>"deepseek"<br/>] |
|
||||
| `content_filter_builtins` | List[[components.ContentFilterBuiltinEntryInput](../../components/contentfilterbuiltinentryinput.md)] | :heavy_minus_sign: | Builtin content filters to apply. Set to null to remove. The "flag" action is only supported for "regex-prompt-injection"; PII slugs (email, phone, ssn, credit-card, ip-address, person-name, address) accept "block" or "redact" only. | [<br/>{<br/>"action": "block",<br/>"slug": "regex-prompt-injection"<br/>}<br/>] |
|
||||
| `content_filters` | List[[components.ContentFilterEntry](../../components/contentfilterentry.md)] | :heavy_minus_sign: | Custom regex content filters to apply. Set to null to remove. | <nil> |
|
||||
| `description` | *OptionalNullable[str]* | :heavy_minus_sign: | New description for the guardrail | Updated description |
|
||||
| `enforce_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.<br/><br/>Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, and enforce_zdr_other instead. When provided, its value is copied into any of those per-provider fields that are not explicitly specified on the request. | true |
|
||||
| `enforce_zdr_anthropic` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided. | true |
|
||||
| `enforce_zdr_google` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided. | true |
|
||||
| `enforce_zdr_openai` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided. | true |
|
||||
| `enforce_zdr_other` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, or Google. Falls back to enforce_zdr when not provided. | true |
|
||||
| `ignored_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers to exclude from routing (slug or canonical_slug accepted) | [<br/>"openai/gpt-4o-mini"<br/>] |
|
||||
| `ignored_providers` | List[*str*] | :heavy_minus_sign: | List of provider IDs to exclude from routing | [<br/>"azure"<br/>] |
|
||||
| `limit_usd` | *OptionalNullable[float]* | :heavy_minus_sign: | New spending limit in USD | 75 |
|
||||
| `name` | *Optional[str]* | :heavy_minus_sign: | New name for the guardrail | Updated Guardrail Name |
|
||||
| `reset_interval` | [OptionalNullable[components.GuardrailInterval]](../../components/guardrailinterval.md) | :heavy_minus_sign: | Interval at which the limit resets (daily, weekly, monthly) | monthly |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
|
||||
### Response
|
||||
|
||||
|
||||
@@ -38,15 +38,16 @@ with OpenRouter(
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `category` | [Optional[operations.Category]](../../operations/category.md) | :heavy_minus_sign: | Filter models by use case category | programming |
|
||||
| `supported_parameters` | *Optional[str]* | :heavy_minus_sign: | Filter models by supported parameter (comma-separated) | temperature |
|
||||
| `output_modalities` | *Optional[str]* | :heavy_minus_sign: | Filter models by output modality. Accepts a comma-separated list of modalities (text, image, audio, embeddings) or "all" to include all models. Defaults to "text". | text |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `category` | [Optional[operations.GetModelsCategory]](../../operations/getmodelscategory.md) | :heavy_minus_sign: | Filter models by use case category | programming |
|
||||
| `supported_parameters` | *Optional[str]* | :heavy_minus_sign: | Filter models by supported parameter (comma-separated) | temperature |
|
||||
| `output_modalities` | *Optional[str]* | :heavy_minus_sign: | Filter models by output modality. Accepts a comma-separated list of modalities (text, image, audio, embeddings) or "all" to include all models. Defaults to "text". | text |
|
||||
| `sort` | [Optional[operations.GetModelsSort]](../../operations/getmodelssort.md) | :heavy_minus_sign: | Sort the returned models server-side. Prefer this over fetching the full list and sorting client-side. Options: pricing-low-to-high, pricing-high-to-low (average prompt/completion price), context-high-to-low (context length), throughput-high-to-low, latency-low-to-high (recent median performance), most-popular, top-weekly (tokens processed in the last week), newest (creation date). When omitted, the existing default ordering is preserved. | newest |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
|
||||
### Response
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.beta.responses.send(input="Tell me a joke", model="openai/gpt-4o", service_tier="auto", stream=False)
|
||||
res = open_router.beta.responses.send(x_open_router_metadata="enabled", input="Tell me a joke", model="openai/gpt-4o", service_tier="auto", stream=False)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
@@ -38,46 +38,49 @@ with OpenRouter(
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `background` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | |
|
||||
| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | |
|
||||
| `image_config` | Dict[str, [components.ImageConfig](../../components/imageconfig.md)] | :heavy_minus_sign: | Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. | {<br/>"aspect_ratio": "16:9",<br/>"quality": "high"<br/>} |
|
||||
| `include` | List[[components.ResponseIncludesEnum](../../components/responseincludesenum.md)] | :heavy_minus_sign: | N/A | |
|
||||
| `input` | [Optional[components.InputsUnion]](../../components/inputsunion.md) | :heavy_minus_sign: | Input for a response request - can be a string or array of items | [<br/>{<br/>"content": "What is the weather today?",<br/>"role": "user"<br/>}<br/>] |
|
||||
| `instructions` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `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_minus_sign: | 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. | {<br/>"session_id": "abc-def-ghi",<br/>"user_id": "123"<br/>} |
|
||||
| `modalities` | List[[components.OutputModalityEnum](../../components/outputmodalityenum.md)] | :heavy_minus_sign: | Output modalities for the response. Supported values are "text" and "image". | [<br/>"text",<br/>"image"<br/>] |
|
||||
| `model` | *Optional[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `models` | List[*str*] | :heavy_minus_sign: | N/A | |
|
||||
| `parallel_tool_calls` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | |
|
||||
| `plugins` | List[[components.ResponsesRequestPlugin](../../components/responsesrequestplugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
|
||||
| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | |
|
||||
| `previous_response_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `prompt` | [OptionalNullable[components.StoredPromptTemplate]](../../components/storedprompttemplate.md) | :heavy_minus_sign: | N/A | {<br/>"id": "prompt-abc123",<br/>"variables": {<br/>"name": "John"<br/>}<br/>} |
|
||||
| `prompt_cache_key` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `provider` | [OptionalNullable[components.ProviderPreferences]](../../components/providerpreferences.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | {<br/>"allow_fallbacks": true<br/>} |
|
||||
| `reasoning` | [OptionalNullable[components.ReasoningConfig]](../../components/reasoningconfig.md) | :heavy_minus_sign: | Configuration for reasoning mode in the response | {<br/>"effort": "medium",<br/>"summary": "auto"<br/>} |
|
||||
| `safety_identifier` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `service_tier` | [OptionalNullable[components.ResponsesRequestServiceTier]](../../components/responsesrequestservicetier.md) | :heavy_minus_sign: | N/A | |
|
||||
| `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 256 characters. | |
|
||||
| `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A | |
|
||||
| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | |
|
||||
| `text` | [Optional[components.TextExtendedConfig]](../../components/textextendedconfig.md) | :heavy_minus_sign: | Text output configuration including format and verbosity | {<br/>"format": {<br/>"type": "text"<br/>},<br/>"verbosity": "medium"<br/>} |
|
||||
| `tool_choice` | [Optional[components.OpenAIResponsesToolChoiceUnion]](../../components/openairesponsestoolchoiceunion.md) | :heavy_minus_sign: | N/A | auto |
|
||||
| `tools` | List[[components.ResponsesRequestToolUnion](../../components/responsesrequesttoolunion.md)] | :heavy_minus_sign: | N/A | |
|
||||
| `top_k` | *Optional[int]* | :heavy_minus_sign: | N/A | |
|
||||
| `top_logprobs` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A | |
|
||||
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | |
|
||||
| `trace` | [Optional[components.TraceConfig]](../../components/traceconfig.md) | :heavy_minus_sign: | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | {<br/>"trace_id": "trace-abc123",<br/>"trace_name": "my-app-trace"<br/>} |
|
||||
| `truncation` | [OptionalNullable[components.OpenAIResponsesTruncation]](../../components/openairesponsestruncation.md) | :heavy_minus_sign: | N/A | auto |
|
||||
| `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 256 characters. | |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
|
||||
| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
|
||||
| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br/> | |
|
||||
| `x_open_router_metadata` | [Optional[components.MetadataLevel]](../../components/metadatalevel.md) | :heavy_minus_sign: | Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility. | enabled |
|
||||
| `background` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | |
|
||||
| `cache_control` | [Optional[components.AnthropicCacheControlDirective]](../../components/anthropiccachecontroldirective.md) | :heavy_minus_sign: | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models. | {<br/>"type": "ephemeral"<br/>} |
|
||||
| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | |
|
||||
| `image_config` | Dict[str, [components.ImageConfig](../../components/imageconfig.md)] | :heavy_minus_sign: | Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. | {<br/>"aspect_ratio": "16:9",<br/>"quality": "high"<br/>} |
|
||||
| `include` | List[[components.ResponseIncludesEnum](../../components/responseincludesenum.md)] | :heavy_minus_sign: | N/A | |
|
||||
| `input` | [Optional[components.InputsUnion]](../../components/inputsunion.md) | :heavy_minus_sign: | Input for a response request - can be a string or array of items | [<br/>{<br/>"content": "What is the weather today?",<br/>"role": "user"<br/>}<br/>] |
|
||||
| `instructions` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `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_minus_sign: | 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. | {<br/>"session_id": "abc-def-ghi",<br/>"user_id": "123"<br/>} |
|
||||
| `modalities` | List[[components.OutputModalityEnum](../../components/outputmodalityenum.md)] | :heavy_minus_sign: | Output modalities for the response. Supported values are "text" and "image". | [<br/>"text",<br/>"image"<br/>] |
|
||||
| `model` | *Optional[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `models` | List[*str*] | :heavy_minus_sign: | N/A | |
|
||||
| `parallel_tool_calls` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | |
|
||||
| `plugins` | List[[components.ResponsesRequestPlugin](../../components/responsesrequestplugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
|
||||
| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | |
|
||||
| `previous_response_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `prompt` | [OptionalNullable[components.StoredPromptTemplate]](../../components/storedprompttemplate.md) | :heavy_minus_sign: | N/A | {<br/>"id": "prompt-abc123",<br/>"variables": {<br/>"name": "John"<br/>}<br/>} |
|
||||
| `prompt_cache_key` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `provider` | [OptionalNullable[components.ProviderPreferences]](../../components/providerpreferences.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | {<br/>"allow_fallbacks": true<br/>} |
|
||||
| `reasoning` | [OptionalNullable[components.ReasoningConfig]](../../components/reasoningconfig.md) | :heavy_minus_sign: | Configuration for reasoning mode in the response | {<br/>"effort": "medium",<br/>"summary": "auto"<br/>} |
|
||||
| `safety_identifier` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `service_tier` | [OptionalNullable[components.ResponsesRequestServiceTier]](../../components/responsesrequestservicetier.md) | :heavy_minus_sign: | N/A | |
|
||||
| `session_id` | *Optional[str]* | :heavy_minus_sign: | A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. | |
|
||||
| `stop_server_tools_when` | List[[components.StopServerToolsWhenCondition](../../components/stopservertoolswhencondition.md)] | :heavy_minus_sign: | Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. | [<br/>{<br/>"step_count": 5,<br/>"type": "step_count_is"<br/>},<br/>{<br/>"max_cost_in_dollars": 0.5,<br/>"type": "max_cost"<br/>}<br/>] |
|
||||
| `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A | |
|
||||
| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | |
|
||||
| `text` | [Optional[components.TextExtendedConfig]](../../components/textextendedconfig.md) | :heavy_minus_sign: | Text output configuration including format and verbosity | {<br/>"format": {<br/>"type": "text"<br/>},<br/>"verbosity": "medium"<br/>} |
|
||||
| `tool_choice` | [Optional[components.OpenAIResponsesToolChoiceUnion]](../../components/openairesponsestoolchoiceunion.md) | :heavy_minus_sign: | N/A | auto |
|
||||
| `tools` | List[[components.ResponsesRequestToolUnion](../../components/responsesrequesttoolunion.md)] | :heavy_minus_sign: | N/A | |
|
||||
| `top_k` | *Optional[int]* | :heavy_minus_sign: | N/A | |
|
||||
| `top_logprobs` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A | |
|
||||
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | |
|
||||
| `trace` | [Optional[components.TraceConfig]](../../components/traceconfig.md) | :heavy_minus_sign: | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | {<br/>"trace_id": "trace-abc123",<br/>"trace_name": "my-app-trace"<br/>} |
|
||||
| `truncation` | [OptionalNullable[components.OpenAIResponsesTruncation]](../../components/openairesponsestruncation.md) | :heavy_minus_sign: | N/A | auto |
|
||||
| `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 256 characters. | |
|
||||
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
||||
|
||||
### Response
|
||||
|
||||
@@ -90,6 +93,7 @@ with OpenRouter(
|
||||
| errors.BadRequestResponseError | 400 | application/json |
|
||||
| errors.UnauthorizedResponseError | 401 | application/json |
|
||||
| errors.PaymentRequiredResponseError | 402 | application/json |
|
||||
| errors.ForbiddenResponseError | 403 | application/json |
|
||||
| errors.NotFoundResponseError | 404 | application/json |
|
||||
| errors.RequestTimeoutResponseError | 408 | application/json |
|
||||
| errors.PayloadTooLargeResponseError | 413 | application/json |
|
||||
|
||||
+3
-2
@@ -1,9 +1,9 @@
|
||||
[project]
|
||||
name = "openrouter"
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
description = "Official Python Client SDK for OpenRouter."
|
||||
authors = [{ name = "OpenRouter" },]
|
||||
readme = "README.md"
|
||||
readme = "README-PYPI.md"
|
||||
requires-python = ">=3.9.2"
|
||||
dependencies = [
|
||||
"httpcore >=1.0.9",
|
||||
@@ -11,6 +11,7 @@ dependencies = [
|
||||
"jsonpath-python >=1.0.6",
|
||||
"pydantic >=2.11.2",
|
||||
]
|
||||
urls.repository = "https://github.com/OpenRouterTeam/python-sdk.git"
|
||||
license = { text = "Apache-2.0" }
|
||||
|
||||
[dependency-groups]
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
uv run python scripts/prepare_readme.py
|
||||
|
||||
uv build
|
||||
uv publish --token $PYPI_TOKEN
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
import importlib.metadata
|
||||
|
||||
__title__: str = "openrouter"
|
||||
__version__: str = "0.9.1"
|
||||
__version__: str = "0.9.2"
|
||||
__openapi_doc_version__: str = "1.0.0"
|
||||
__gen_version__: str = "2.788.4"
|
||||
__user_agent__: str = "speakeasy-sdk/python 0.9.1 2.788.4 1.0.0 openrouter"
|
||||
__user_agent__: str = "speakeasy-sdk/python 0.9.2 2.788.4 1.0.0 openrouter"
|
||||
|
||||
try:
|
||||
if __package__ is not None:
|
||||
|
||||
@@ -257,6 +257,7 @@ class APIKeys(BaseSDK):
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
include_disabled: Optional[bool] = None,
|
||||
offset: Optional[int] = None,
|
||||
workspace_id: Optional[str] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -275,6 +276,7 @@ class APIKeys(BaseSDK):
|
||||
|
||||
:param include_disabled: Whether to include disabled API keys in the response
|
||||
:param offset: Number of API keys to skip for pagination
|
||||
:param workspace_id: Filter API keys by workspace ID. By default, keys in the default workspace are returned.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -296,6 +298,7 @@ class APIKeys(BaseSDK):
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
include_disabled=include_disabled,
|
||||
offset=offset,
|
||||
workspace_id=workspace_id,
|
||||
)
|
||||
|
||||
req = self._build_request(
|
||||
@@ -386,6 +389,7 @@ class APIKeys(BaseSDK):
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
include_disabled: Optional[bool] = None,
|
||||
offset: Optional[int] = None,
|
||||
workspace_id: Optional[str] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -404,6 +408,7 @@ class APIKeys(BaseSDK):
|
||||
|
||||
:param include_disabled: Whether to include disabled API keys in the response
|
||||
:param offset: Number of API keys to skip for pagination
|
||||
:param workspace_id: Filter API keys by workspace ID. By default, keys in the default workspace are returned.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -425,6 +430,7 @@ class APIKeys(BaseSDK):
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
include_disabled=include_disabled,
|
||||
offset=offset,
|
||||
workspace_id=workspace_id,
|
||||
)
|
||||
|
||||
req = self._build_request_async(
|
||||
@@ -519,6 +525,7 @@ class APIKeys(BaseSDK):
|
||||
include_byok_in_limit: Optional[bool] = None,
|
||||
limit: OptionalNullable[float] = UNSET,
|
||||
limit_reset: OptionalNullable[operations.CreateKeysLimitReset] = UNSET,
|
||||
workspace_id: Optional[str] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -541,6 +548,7 @@ class APIKeys(BaseSDK):
|
||||
:param include_byok_in_limit: Whether to include BYOK usage in the limit
|
||||
:param limit: Optional spending limit for the API key in USD
|
||||
:param limit_reset: Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday.
|
||||
:param workspace_id: The workspace to create the API key in. Defaults to the default workspace if not provided.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -567,6 +575,7 @@ class APIKeys(BaseSDK):
|
||||
limit=limit,
|
||||
limit_reset=limit_reset,
|
||||
name=name,
|
||||
workspace_id=workspace_id,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -622,7 +631,7 @@ class APIKeys(BaseSDK):
|
||||
),
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "429", "4XX", "500", "5XX"],
|
||||
error_status_codes=["400", "401", "403", "429", "4XX", "500", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
@@ -639,6 +648,11 @@ class APIKeys(BaseSDK):
|
||||
errors.UnauthorizedResponseErrorData, http_res
|
||||
)
|
||||
raise errors.UnauthorizedResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "403", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.ForbiddenResponseErrorData, http_res
|
||||
)
|
||||
raise errors.ForbiddenResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "429", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.TooManyRequestsResponseErrorData, http_res
|
||||
@@ -674,6 +688,7 @@ class APIKeys(BaseSDK):
|
||||
include_byok_in_limit: Optional[bool] = None,
|
||||
limit: OptionalNullable[float] = UNSET,
|
||||
limit_reset: OptionalNullable[operations.CreateKeysLimitReset] = UNSET,
|
||||
workspace_id: Optional[str] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -696,6 +711,7 @@ class APIKeys(BaseSDK):
|
||||
:param include_byok_in_limit: Whether to include BYOK usage in the limit
|
||||
:param limit: Optional spending limit for the API key in USD
|
||||
:param limit_reset: Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday.
|
||||
:param workspace_id: The workspace to create the API key in. Defaults to the default workspace if not provided.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -722,6 +738,7 @@ class APIKeys(BaseSDK):
|
||||
limit=limit,
|
||||
limit_reset=limit_reset,
|
||||
name=name,
|
||||
workspace_id=workspace_id,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -777,7 +794,7 @@ class APIKeys(BaseSDK):
|
||||
),
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "429", "4XX", "500", "5XX"],
|
||||
error_status_codes=["400", "401", "403", "429", "4XX", "500", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
@@ -794,6 +811,11 @@ class APIKeys(BaseSDK):
|
||||
errors.UnauthorizedResponseErrorData, http_res
|
||||
)
|
||||
raise errors.UnauthorizedResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "403", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.ForbiddenResponseErrorData, http_res
|
||||
)
|
||||
raise errors.ForbiddenResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "429", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.TooManyRequestsResponseErrorData, http_res
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
from .basesdk import BaseSDK
|
||||
from .sdkconfiguration import SDKConfiguration
|
||||
from openrouter.beta_analytics import BetaAnalytics
|
||||
from openrouter.responses import Responses
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class Beta(BaseSDK):
|
||||
analytics: BetaAnalytics
|
||||
r"""beta.Analytics endpoints"""
|
||||
responses: Responses
|
||||
r"""beta.responses endpoints"""
|
||||
|
||||
@@ -18,4 +21,7 @@ class Beta(BaseSDK):
|
||||
self._init_sdks()
|
||||
|
||||
def _init_sdks(self):
|
||||
self.analytics = BetaAnalytics(
|
||||
self.sdk_configuration, parent_ref=self.parent_ref
|
||||
)
|
||||
self.responses = Responses(self.sdk_configuration, parent_ref=self.parent_ref)
|
||||
|
||||
@@ -0,0 +1,619 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from .basesdk import BaseSDK
|
||||
from openrouter import components, errors, operations, utils
|
||||
from openrouter._hooks import HookContext
|
||||
from openrouter.types import OptionalNullable, UNSET
|
||||
from openrouter.utils import get_security_from_env
|
||||
from openrouter.utils.unmarshal_json_response import unmarshal_json_response
|
||||
from typing import Any, List, Mapping, Optional, Union
|
||||
|
||||
|
||||
class BetaAnalytics(BaseSDK):
|
||||
r"""beta.Analytics endpoints"""
|
||||
|
||||
def get_analytics_meta(
|
||||
self,
|
||||
*,
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> operations.GetAnalyticsMetaResponse:
|
||||
r"""Get available analytics metrics and dimensions
|
||||
|
||||
Returns the available metrics, dimensions, filter operators, and granularities for the analytics query endpoint. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
||||
|
||||
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
This is used to track API usage per application.
|
||||
|
||||
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
:param http_headers: Additional headers to set or replace on requests.
|
||||
"""
|
||||
base_url = None
|
||||
url_variables = None
|
||||
if timeout_ms is None:
|
||||
timeout_ms = self.sdk_configuration.timeout_ms
|
||||
|
||||
if server_url is not None:
|
||||
base_url = server_url
|
||||
else:
|
||||
base_url = self._get_url(base_url, url_variables)
|
||||
|
||||
request = operations.GetAnalyticsMetaRequest(
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
)
|
||||
|
||||
req = self._build_request(
|
||||
method="GET",
|
||||
path="/analytics/meta",
|
||||
base_url=base_url,
|
||||
url_variables=url_variables,
|
||||
request=request,
|
||||
request_body_required=False,
|
||||
request_has_path_params=False,
|
||||
request_has_query_params=True,
|
||||
user_agent_header="user-agent",
|
||||
accept_header_value="application/json",
|
||||
http_headers=http_headers,
|
||||
_globals=operations.GetAnalyticsMetaGlobals(
|
||||
http_referer=self.sdk_configuration.globals.http_referer,
|
||||
x_open_router_title=self.sdk_configuration.globals.x_open_router_title,
|
||||
x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories,
|
||||
),
|
||||
security=self.sdk_configuration.security,
|
||||
allow_empty_value=None,
|
||||
timeout_ms=timeout_ms,
|
||||
)
|
||||
|
||||
if retries == UNSET:
|
||||
if self.sdk_configuration.retry_config is not UNSET:
|
||||
retries = self.sdk_configuration.retry_config
|
||||
else:
|
||||
retries = utils.RetryConfig(
|
||||
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
||||
)
|
||||
|
||||
retry_config = None
|
||||
if isinstance(retries, utils.RetryConfig):
|
||||
retry_config = (retries, ["5XX"])
|
||||
|
||||
http_res = self.do_request(
|
||||
hook_ctx=HookContext(
|
||||
config=self.sdk_configuration,
|
||||
base_url=base_url or "",
|
||||
operation_id="getAnalyticsMeta",
|
||||
oauth2_scopes=None,
|
||||
security_source=get_security_from_env(
|
||||
self.sdk_configuration.security, components.Security
|
||||
),
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["401", "403", "4XX", "500", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(
|
||||
operations.GetAnalyticsMetaResponse, http_res
|
||||
)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.UnauthorizedResponseErrorData, http_res
|
||||
)
|
||||
raise errors.UnauthorizedResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "403", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.ForbiddenResponseErrorData, http_res
|
||||
)
|
||||
raise errors.ForbiddenResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "500", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.InternalServerResponseErrorData, http_res
|
||||
)
|
||||
raise errors.InternalServerResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "4XX", "*"):
|
||||
http_res_text = utils.stream_to_text(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
if utils.match_response(http_res, "5XX", "*"):
|
||||
http_res_text = utils.stream_to_text(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
|
||||
raise errors.OpenRouterDefaultError("Unexpected response received", http_res)
|
||||
|
||||
async def get_analytics_meta_async(
|
||||
self,
|
||||
*,
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> operations.GetAnalyticsMetaResponse:
|
||||
r"""Get available analytics metrics and dimensions
|
||||
|
||||
Returns the available metrics, dimensions, filter operators, and granularities for the analytics query endpoint. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
||||
|
||||
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
This is used to track API usage per application.
|
||||
|
||||
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
:param http_headers: Additional headers to set or replace on requests.
|
||||
"""
|
||||
base_url = None
|
||||
url_variables = None
|
||||
if timeout_ms is None:
|
||||
timeout_ms = self.sdk_configuration.timeout_ms
|
||||
|
||||
if server_url is not None:
|
||||
base_url = server_url
|
||||
else:
|
||||
base_url = self._get_url(base_url, url_variables)
|
||||
|
||||
request = operations.GetAnalyticsMetaRequest(
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
)
|
||||
|
||||
req = self._build_request_async(
|
||||
method="GET",
|
||||
path="/analytics/meta",
|
||||
base_url=base_url,
|
||||
url_variables=url_variables,
|
||||
request=request,
|
||||
request_body_required=False,
|
||||
request_has_path_params=False,
|
||||
request_has_query_params=True,
|
||||
user_agent_header="user-agent",
|
||||
accept_header_value="application/json",
|
||||
http_headers=http_headers,
|
||||
_globals=operations.GetAnalyticsMetaGlobals(
|
||||
http_referer=self.sdk_configuration.globals.http_referer,
|
||||
x_open_router_title=self.sdk_configuration.globals.x_open_router_title,
|
||||
x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories,
|
||||
),
|
||||
security=self.sdk_configuration.security,
|
||||
allow_empty_value=None,
|
||||
timeout_ms=timeout_ms,
|
||||
)
|
||||
|
||||
if retries == UNSET:
|
||||
if self.sdk_configuration.retry_config is not UNSET:
|
||||
retries = self.sdk_configuration.retry_config
|
||||
else:
|
||||
retries = utils.RetryConfig(
|
||||
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
||||
)
|
||||
|
||||
retry_config = None
|
||||
if isinstance(retries, utils.RetryConfig):
|
||||
retry_config = (retries, ["5XX"])
|
||||
|
||||
http_res = await self.do_request_async(
|
||||
hook_ctx=HookContext(
|
||||
config=self.sdk_configuration,
|
||||
base_url=base_url or "",
|
||||
operation_id="getAnalyticsMeta",
|
||||
oauth2_scopes=None,
|
||||
security_source=get_security_from_env(
|
||||
self.sdk_configuration.security, components.Security
|
||||
),
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["401", "403", "4XX", "500", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(
|
||||
operations.GetAnalyticsMetaResponse, http_res
|
||||
)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.UnauthorizedResponseErrorData, http_res
|
||||
)
|
||||
raise errors.UnauthorizedResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "403", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.ForbiddenResponseErrorData, http_res
|
||||
)
|
||||
raise errors.ForbiddenResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "500", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.InternalServerResponseErrorData, http_res
|
||||
)
|
||||
raise errors.InternalServerResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "4XX", "*"):
|
||||
http_res_text = await utils.stream_to_text_async(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
if utils.match_response(http_res, "5XX", "*"):
|
||||
http_res_text = await utils.stream_to_text_async(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
|
||||
raise errors.OpenRouterDefaultError("Unexpected response received", http_res)
|
||||
|
||||
def query_analytics(
|
||||
self,
|
||||
*,
|
||||
metrics: List[str],
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
dimensions: Optional[List[str]] = None,
|
||||
filters: Optional[
|
||||
Union[List[operations.Filter], List[operations.FilterTypedDict]]
|
||||
] = None,
|
||||
granularity: Optional[str] = None,
|
||||
group_limit: Optional[int] = None,
|
||||
limit: Optional[int] = None,
|
||||
order_by: Optional[
|
||||
Union[operations.OrderBy, operations.OrderByTypedDict]
|
||||
] = None,
|
||||
time_range: Optional[
|
||||
Union[operations.TimeRange, operations.TimeRangeTypedDict]
|
||||
] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> operations.QueryAnalyticsResponse:
|
||||
r"""Query analytics data
|
||||
|
||||
Execute an analytics query with specified metrics, dimensions, filters, and time range. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
||||
|
||||
:param metrics:
|
||||
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
This is used to track API usage per application.
|
||||
|
||||
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param dimensions:
|
||||
:param filters:
|
||||
:param granularity: Time granularity
|
||||
:param group_limit: Maximum rows per distinct combination of dimensions (ClickHouse LIMIT n BY). When omitted on time-series queries (granularity + dimensions), auto-computed to avoid truncating time windows. Explicit values override the default and may truncate time buckets if set lower than the number of buckets in the range. Ignored when no dimensions are specified.
|
||||
:param limit: Maximum total rows returned. Defaults to 1000. On time-series queries with dimensions and no explicit group_limit, the server may raise this to accommodate the expected number of unique time-bucket/dimension combinations.
|
||||
:param order_by:
|
||||
:param time_range:
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
:param http_headers: Additional headers to set or replace on requests.
|
||||
"""
|
||||
base_url = None
|
||||
url_variables = None
|
||||
if timeout_ms is None:
|
||||
timeout_ms = self.sdk_configuration.timeout_ms
|
||||
|
||||
if server_url is not None:
|
||||
base_url = server_url
|
||||
else:
|
||||
base_url = self._get_url(base_url, url_variables)
|
||||
|
||||
request = operations.QueryAnalyticsRequest(
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
request_body=operations.QueryAnalyticsRequestBody(
|
||||
dimensions=dimensions,
|
||||
filters=utils.get_pydantic_model(
|
||||
filters, Optional[List[operations.Filter]]
|
||||
),
|
||||
granularity=granularity,
|
||||
group_limit=group_limit,
|
||||
limit=limit,
|
||||
metrics=metrics,
|
||||
order_by=utils.get_pydantic_model(
|
||||
order_by, Optional[operations.OrderBy]
|
||||
),
|
||||
time_range=utils.get_pydantic_model(
|
||||
time_range, Optional[operations.TimeRange]
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
req = self._build_request(
|
||||
method="POST",
|
||||
path="/analytics/query",
|
||||
base_url=base_url,
|
||||
url_variables=url_variables,
|
||||
request=request,
|
||||
request_body_required=True,
|
||||
request_has_path_params=False,
|
||||
request_has_query_params=True,
|
||||
user_agent_header="user-agent",
|
||||
accept_header_value="application/json",
|
||||
http_headers=http_headers,
|
||||
_globals=operations.QueryAnalyticsGlobals(
|
||||
http_referer=self.sdk_configuration.globals.http_referer,
|
||||
x_open_router_title=self.sdk_configuration.globals.x_open_router_title,
|
||||
x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories,
|
||||
),
|
||||
security=self.sdk_configuration.security,
|
||||
get_serialized_body=lambda: utils.serialize_request_body(
|
||||
request.request_body,
|
||||
False,
|
||||
False,
|
||||
"json",
|
||||
operations.QueryAnalyticsRequestBody,
|
||||
),
|
||||
allow_empty_value=None,
|
||||
timeout_ms=timeout_ms,
|
||||
)
|
||||
|
||||
if retries == UNSET:
|
||||
if self.sdk_configuration.retry_config is not UNSET:
|
||||
retries = self.sdk_configuration.retry_config
|
||||
else:
|
||||
retries = utils.RetryConfig(
|
||||
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
||||
)
|
||||
|
||||
retry_config = None
|
||||
if isinstance(retries, utils.RetryConfig):
|
||||
retry_config = (retries, ["5XX"])
|
||||
|
||||
http_res = self.do_request(
|
||||
hook_ctx=HookContext(
|
||||
config=self.sdk_configuration,
|
||||
base_url=base_url or "",
|
||||
operation_id="queryAnalytics",
|
||||
oauth2_scopes=None,
|
||||
security_source=get_security_from_env(
|
||||
self.sdk_configuration.security, components.Security
|
||||
),
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "403", "408", "4XX", "500", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(operations.QueryAnalyticsResponse, http_res)
|
||||
if utils.match_response(http_res, "400", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.BadRequestResponseErrorData, http_res
|
||||
)
|
||||
raise errors.BadRequestResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.UnauthorizedResponseErrorData, http_res
|
||||
)
|
||||
raise errors.UnauthorizedResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "403", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.ForbiddenResponseErrorData, http_res
|
||||
)
|
||||
raise errors.ForbiddenResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "408", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.RequestTimeoutResponseErrorData, http_res
|
||||
)
|
||||
raise errors.RequestTimeoutResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "500", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.InternalServerResponseErrorData, http_res
|
||||
)
|
||||
raise errors.InternalServerResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "4XX", "*"):
|
||||
http_res_text = utils.stream_to_text(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
if utils.match_response(http_res, "5XX", "*"):
|
||||
http_res_text = utils.stream_to_text(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
|
||||
raise errors.OpenRouterDefaultError("Unexpected response received", http_res)
|
||||
|
||||
async def query_analytics_async(
|
||||
self,
|
||||
*,
|
||||
metrics: List[str],
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
dimensions: Optional[List[str]] = None,
|
||||
filters: Optional[
|
||||
Union[List[operations.Filter], List[operations.FilterTypedDict]]
|
||||
] = None,
|
||||
granularity: Optional[str] = None,
|
||||
group_limit: Optional[int] = None,
|
||||
limit: Optional[int] = None,
|
||||
order_by: Optional[
|
||||
Union[operations.OrderBy, operations.OrderByTypedDict]
|
||||
] = None,
|
||||
time_range: Optional[
|
||||
Union[operations.TimeRange, operations.TimeRangeTypedDict]
|
||||
] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> operations.QueryAnalyticsResponse:
|
||||
r"""Query analytics data
|
||||
|
||||
Execute an analytics query with specified metrics, dimensions, filters, and time range. [Management key](/docs/guides/overview/auth/management-api-keys) required.
|
||||
|
||||
:param metrics:
|
||||
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
This is used to track API usage per application.
|
||||
|
||||
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param dimensions:
|
||||
:param filters:
|
||||
:param granularity: Time granularity
|
||||
:param group_limit: Maximum rows per distinct combination of dimensions (ClickHouse LIMIT n BY). When omitted on time-series queries (granularity + dimensions), auto-computed to avoid truncating time windows. Explicit values override the default and may truncate time buckets if set lower than the number of buckets in the range. Ignored when no dimensions are specified.
|
||||
:param limit: Maximum total rows returned. Defaults to 1000. On time-series queries with dimensions and no explicit group_limit, the server may raise this to accommodate the expected number of unique time-bucket/dimension combinations.
|
||||
:param order_by:
|
||||
:param time_range:
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
:param http_headers: Additional headers to set or replace on requests.
|
||||
"""
|
||||
base_url = None
|
||||
url_variables = None
|
||||
if timeout_ms is None:
|
||||
timeout_ms = self.sdk_configuration.timeout_ms
|
||||
|
||||
if server_url is not None:
|
||||
base_url = server_url
|
||||
else:
|
||||
base_url = self._get_url(base_url, url_variables)
|
||||
|
||||
request = operations.QueryAnalyticsRequest(
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
request_body=operations.QueryAnalyticsRequestBody(
|
||||
dimensions=dimensions,
|
||||
filters=utils.get_pydantic_model(
|
||||
filters, Optional[List[operations.Filter]]
|
||||
),
|
||||
granularity=granularity,
|
||||
group_limit=group_limit,
|
||||
limit=limit,
|
||||
metrics=metrics,
|
||||
order_by=utils.get_pydantic_model(
|
||||
order_by, Optional[operations.OrderBy]
|
||||
),
|
||||
time_range=utils.get_pydantic_model(
|
||||
time_range, Optional[operations.TimeRange]
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
req = self._build_request_async(
|
||||
method="POST",
|
||||
path="/analytics/query",
|
||||
base_url=base_url,
|
||||
url_variables=url_variables,
|
||||
request=request,
|
||||
request_body_required=True,
|
||||
request_has_path_params=False,
|
||||
request_has_query_params=True,
|
||||
user_agent_header="user-agent",
|
||||
accept_header_value="application/json",
|
||||
http_headers=http_headers,
|
||||
_globals=operations.QueryAnalyticsGlobals(
|
||||
http_referer=self.sdk_configuration.globals.http_referer,
|
||||
x_open_router_title=self.sdk_configuration.globals.x_open_router_title,
|
||||
x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories,
|
||||
),
|
||||
security=self.sdk_configuration.security,
|
||||
get_serialized_body=lambda: utils.serialize_request_body(
|
||||
request.request_body,
|
||||
False,
|
||||
False,
|
||||
"json",
|
||||
operations.QueryAnalyticsRequestBody,
|
||||
),
|
||||
allow_empty_value=None,
|
||||
timeout_ms=timeout_ms,
|
||||
)
|
||||
|
||||
if retries == UNSET:
|
||||
if self.sdk_configuration.retry_config is not UNSET:
|
||||
retries = self.sdk_configuration.retry_config
|
||||
else:
|
||||
retries = utils.RetryConfig(
|
||||
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
||||
)
|
||||
|
||||
retry_config = None
|
||||
if isinstance(retries, utils.RetryConfig):
|
||||
retry_config = (retries, ["5XX"])
|
||||
|
||||
http_res = await self.do_request_async(
|
||||
hook_ctx=HookContext(
|
||||
config=self.sdk_configuration,
|
||||
base_url=base_url or "",
|
||||
operation_id="queryAnalytics",
|
||||
oauth2_scopes=None,
|
||||
security_source=get_security_from_env(
|
||||
self.sdk_configuration.security, components.Security
|
||||
),
|
||||
),
|
||||
request=req,
|
||||
error_status_codes=["400", "401", "403", "408", "4XX", "500", "5XX"],
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(operations.QueryAnalyticsResponse, http_res)
|
||||
if utils.match_response(http_res, "400", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.BadRequestResponseErrorData, http_res
|
||||
)
|
||||
raise errors.BadRequestResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.UnauthorizedResponseErrorData, http_res
|
||||
)
|
||||
raise errors.UnauthorizedResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "403", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.ForbiddenResponseErrorData, http_res
|
||||
)
|
||||
raise errors.ForbiddenResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "408", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.RequestTimeoutResponseErrorData, http_res
|
||||
)
|
||||
raise errors.RequestTimeoutResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "500", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.InternalServerResponseErrorData, http_res
|
||||
)
|
||||
raise errors.InternalServerResponseError(response_data, http_res)
|
||||
if utils.match_response(http_res, "4XX", "*"):
|
||||
http_res_text = await utils.stream_to_text_async(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
if utils.match_response(http_res, "5XX", "*"):
|
||||
http_res_text = await utils.stream_to_text_async(http_res)
|
||||
raise errors.OpenRouterDefaultError(
|
||||
"API error occurred", http_res, http_res_text
|
||||
)
|
||||
|
||||
raise errors.OpenRouterDefaultError("Unexpected response received", http_res)
|
||||
File diff suppressed because it is too large
Load Diff
+118
-22
@@ -26,6 +26,7 @@ class Chat(BaseSDK):
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
x_open_router_metadata: Optional[components.MetadataLevel] = None,
|
||||
cache_control: Optional[
|
||||
Union[
|
||||
components.AnthropicCacheControlDirective,
|
||||
@@ -64,7 +65,10 @@ class Chat(BaseSDK):
|
||||
]
|
||||
] = UNSET,
|
||||
reasoning: Optional[
|
||||
Union[components.Reasoning, components.ReasoningTypedDict]
|
||||
Union[
|
||||
components.ChatRequestReasoning,
|
||||
components.ChatRequestReasoningTypedDict,
|
||||
]
|
||||
] = None,
|
||||
response_format: Optional[
|
||||
Union[components.ResponseFormat, components.ResponseFormatTypedDict]
|
||||
@@ -75,6 +79,12 @@ class Chat(BaseSDK):
|
||||
stop: OptionalNullable[
|
||||
Union[components.Stop, components.StopTypedDict]
|
||||
] = UNSET,
|
||||
stop_server_tools_when: Optional[
|
||||
Union[
|
||||
List[components.StopServerToolsWhenCondition],
|
||||
List[components.StopServerToolsWhenConditionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
stream: Union[Literal[False], None] = None,
|
||||
stream_options: OptionalNullable[
|
||||
Union[components.ChatStreamOptions, components.ChatStreamOptionsTypedDict]
|
||||
@@ -112,7 +122,8 @@ class Chat(BaseSDK):
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param cache_control:
|
||||
:param x_open_router_metadata: Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility.
|
||||
:param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
|
||||
:param debug: Debug options for inspecting request transformations (streaming only)
|
||||
:param frequency_penalty: Frequency penalty (-2.0 to 2.0)
|
||||
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
|
||||
@@ -132,8 +143,9 @@ class Chat(BaseSDK):
|
||||
:param response_format: Response format configuration
|
||||
:param seed: Random seed for deterministic outputs
|
||||
:param service_tier: The service tier to use for processing this request.
|
||||
:param session_id: 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 256 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
|
||||
:param stop: Stop sequences (up to 4)
|
||||
:param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`.
|
||||
:param stream: Enable streaming response
|
||||
:param stream_options: Streaming configuration options
|
||||
:param temperature: Sampling temperature (0-2)
|
||||
@@ -160,6 +172,7 @@ class Chat(BaseSDK):
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
x_open_router_metadata: Optional[components.MetadataLevel] = None,
|
||||
cache_control: Optional[
|
||||
Union[
|
||||
components.AnthropicCacheControlDirective,
|
||||
@@ -198,7 +211,10 @@ class Chat(BaseSDK):
|
||||
]
|
||||
] = UNSET,
|
||||
reasoning: Optional[
|
||||
Union[components.Reasoning, components.ReasoningTypedDict]
|
||||
Union[
|
||||
components.ChatRequestReasoning,
|
||||
components.ChatRequestReasoningTypedDict,
|
||||
]
|
||||
] = None,
|
||||
response_format: Optional[
|
||||
Union[components.ResponseFormat, components.ResponseFormatTypedDict]
|
||||
@@ -209,6 +225,12 @@ class Chat(BaseSDK):
|
||||
stop: OptionalNullable[
|
||||
Union[components.Stop, components.StopTypedDict]
|
||||
] = UNSET,
|
||||
stop_server_tools_when: Optional[
|
||||
Union[
|
||||
List[components.StopServerToolsWhenCondition],
|
||||
List[components.StopServerToolsWhenConditionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
stream: Literal[True],
|
||||
stream_options: OptionalNullable[
|
||||
Union[components.ChatStreamOptions, components.ChatStreamOptionsTypedDict]
|
||||
@@ -246,7 +268,8 @@ class Chat(BaseSDK):
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param cache_control:
|
||||
:param x_open_router_metadata: Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility.
|
||||
:param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
|
||||
:param debug: Debug options for inspecting request transformations (streaming only)
|
||||
:param frequency_penalty: Frequency penalty (-2.0 to 2.0)
|
||||
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
|
||||
@@ -266,8 +289,9 @@ class Chat(BaseSDK):
|
||||
:param response_format: Response format configuration
|
||||
:param seed: Random seed for deterministic outputs
|
||||
:param service_tier: The service tier to use for processing this request.
|
||||
:param session_id: 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 256 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
|
||||
:param stop: Stop sequences (up to 4)
|
||||
:param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`.
|
||||
:param stream: Enable streaming response
|
||||
:param stream_options: Streaming configuration options
|
||||
:param temperature: Sampling temperature (0-2)
|
||||
@@ -293,6 +317,7 @@ class Chat(BaseSDK):
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
x_open_router_metadata: Optional[components.MetadataLevel] = None,
|
||||
cache_control: Optional[
|
||||
Union[
|
||||
components.AnthropicCacheControlDirective,
|
||||
@@ -331,7 +356,10 @@ class Chat(BaseSDK):
|
||||
]
|
||||
] = UNSET,
|
||||
reasoning: Optional[
|
||||
Union[components.Reasoning, components.ReasoningTypedDict]
|
||||
Union[
|
||||
components.ChatRequestReasoning,
|
||||
components.ChatRequestReasoningTypedDict,
|
||||
]
|
||||
] = None,
|
||||
response_format: Optional[
|
||||
Union[components.ResponseFormat, components.ResponseFormatTypedDict]
|
||||
@@ -342,6 +370,12 @@ class Chat(BaseSDK):
|
||||
stop: OptionalNullable[
|
||||
Union[components.Stop, components.StopTypedDict]
|
||||
] = UNSET,
|
||||
stop_server_tools_when: Optional[
|
||||
Union[
|
||||
List[components.StopServerToolsWhenCondition],
|
||||
List[components.StopServerToolsWhenConditionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
stream: Optional[bool] = False,
|
||||
stream_options: OptionalNullable[
|
||||
Union[components.ChatStreamOptions, components.ChatStreamOptionsTypedDict]
|
||||
@@ -379,7 +413,8 @@ class Chat(BaseSDK):
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param cache_control:
|
||||
:param x_open_router_metadata: Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility.
|
||||
:param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
|
||||
:param debug: Debug options for inspecting request transformations (streaming only)
|
||||
:param frequency_penalty: Frequency penalty (-2.0 to 2.0)
|
||||
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
|
||||
@@ -399,8 +434,9 @@ class Chat(BaseSDK):
|
||||
:param response_format: Response format configuration
|
||||
:param seed: Random seed for deterministic outputs
|
||||
:param service_tier: The service tier to use for processing this request.
|
||||
:param session_id: 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 256 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
|
||||
:param stop: Stop sequences (up to 4)
|
||||
:param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`.
|
||||
:param stream: Enable streaming response
|
||||
:param stream_options: Streaming configuration options
|
||||
:param temperature: Sampling temperature (0-2)
|
||||
@@ -430,6 +466,7 @@ class Chat(BaseSDK):
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
x_open_router_metadata=x_open_router_metadata,
|
||||
chat_request=components.ChatRequest(
|
||||
cache_control=utils.get_pydantic_model(
|
||||
cache_control, Optional[components.AnthropicCacheControlDirective]
|
||||
@@ -459,7 +496,7 @@ class Chat(BaseSDK):
|
||||
provider, OptionalNullable[components.ProviderPreferences]
|
||||
),
|
||||
reasoning=utils.get_pydantic_model(
|
||||
reasoning, Optional[components.Reasoning]
|
||||
reasoning, Optional[components.ChatRequestReasoning]
|
||||
),
|
||||
response_format=utils.get_pydantic_model(
|
||||
response_format, Optional[components.ResponseFormat]
|
||||
@@ -468,6 +505,10 @@ class Chat(BaseSDK):
|
||||
service_tier=service_tier,
|
||||
session_id=session_id,
|
||||
stop=stop,
|
||||
stop_server_tools_when=utils.get_pydantic_model(
|
||||
stop_server_tools_when,
|
||||
Optional[List[components.StopServerToolsWhenCondition]],
|
||||
),
|
||||
stream=stream,
|
||||
stream_options=utils.get_pydantic_model(
|
||||
stream_options, OptionalNullable[components.ChatStreamOptions]
|
||||
@@ -538,6 +579,7 @@ class Chat(BaseSDK):
|
||||
"400",
|
||||
"401",
|
||||
"402",
|
||||
"403",
|
||||
"404",
|
||||
"408",
|
||||
"413",
|
||||
@@ -565,7 +607,7 @@ class Chat(BaseSDK):
|
||||
return eventstreaming.EventStream(
|
||||
http_res,
|
||||
lambda raw: utils.unmarshal_json(
|
||||
raw, operations.SendChatCompletionRequestResponseBody
|
||||
raw, components.ChatStreamingResponse
|
||||
).data,
|
||||
sentinel="[DONE]",
|
||||
client_ref=self,
|
||||
@@ -592,6 +634,12 @@ class Chat(BaseSDK):
|
||||
raise errors.PaymentRequiredResponseError(
|
||||
response_data, http_res, http_res_text
|
||||
)
|
||||
if utils.match_response(http_res, "403", "application/json"):
|
||||
http_res_text = utils.stream_to_text(http_res)
|
||||
response_data = unmarshal_json_response(
|
||||
errors.ForbiddenResponseErrorData, http_res, http_res_text
|
||||
)
|
||||
raise errors.ForbiddenResponseError(response_data, http_res, http_res_text)
|
||||
if utils.match_response(http_res, "404", "application/json"):
|
||||
http_res_text = utils.stream_to_text(http_res)
|
||||
response_data = unmarshal_json_response(
|
||||
@@ -694,6 +742,7 @@ class Chat(BaseSDK):
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
x_open_router_metadata: Optional[components.MetadataLevel] = None,
|
||||
cache_control: Optional[
|
||||
Union[
|
||||
components.AnthropicCacheControlDirective,
|
||||
@@ -732,7 +781,10 @@ class Chat(BaseSDK):
|
||||
]
|
||||
] = UNSET,
|
||||
reasoning: Optional[
|
||||
Union[components.Reasoning, components.ReasoningTypedDict]
|
||||
Union[
|
||||
components.ChatRequestReasoning,
|
||||
components.ChatRequestReasoningTypedDict,
|
||||
]
|
||||
] = None,
|
||||
response_format: Optional[
|
||||
Union[components.ResponseFormat, components.ResponseFormatTypedDict]
|
||||
@@ -743,6 +795,12 @@ class Chat(BaseSDK):
|
||||
stop: OptionalNullable[
|
||||
Union[components.Stop, components.StopTypedDict]
|
||||
] = UNSET,
|
||||
stop_server_tools_when: Optional[
|
||||
Union[
|
||||
List[components.StopServerToolsWhenCondition],
|
||||
List[components.StopServerToolsWhenConditionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
stream: Union[Literal[False], None] = None,
|
||||
stream_options: OptionalNullable[
|
||||
Union[components.ChatStreamOptions, components.ChatStreamOptionsTypedDict]
|
||||
@@ -780,7 +838,8 @@ class Chat(BaseSDK):
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param cache_control:
|
||||
:param x_open_router_metadata: Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility.
|
||||
:param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
|
||||
:param debug: Debug options for inspecting request transformations (streaming only)
|
||||
:param frequency_penalty: Frequency penalty (-2.0 to 2.0)
|
||||
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
|
||||
@@ -800,8 +859,9 @@ class Chat(BaseSDK):
|
||||
:param response_format: Response format configuration
|
||||
:param seed: Random seed for deterministic outputs
|
||||
:param service_tier: The service tier to use for processing this request.
|
||||
:param session_id: 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 256 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
|
||||
:param stop: Stop sequences (up to 4)
|
||||
:param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`.
|
||||
:param stream: Enable streaming response
|
||||
:param stream_options: Streaming configuration options
|
||||
:param temperature: Sampling temperature (0-2)
|
||||
@@ -828,6 +888,7 @@ class Chat(BaseSDK):
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
x_open_router_metadata: Optional[components.MetadataLevel] = None,
|
||||
cache_control: Optional[
|
||||
Union[
|
||||
components.AnthropicCacheControlDirective,
|
||||
@@ -866,7 +927,10 @@ class Chat(BaseSDK):
|
||||
]
|
||||
] = UNSET,
|
||||
reasoning: Optional[
|
||||
Union[components.Reasoning, components.ReasoningTypedDict]
|
||||
Union[
|
||||
components.ChatRequestReasoning,
|
||||
components.ChatRequestReasoningTypedDict,
|
||||
]
|
||||
] = None,
|
||||
response_format: Optional[
|
||||
Union[components.ResponseFormat, components.ResponseFormatTypedDict]
|
||||
@@ -877,6 +941,12 @@ class Chat(BaseSDK):
|
||||
stop: OptionalNullable[
|
||||
Union[components.Stop, components.StopTypedDict]
|
||||
] = UNSET,
|
||||
stop_server_tools_when: Optional[
|
||||
Union[
|
||||
List[components.StopServerToolsWhenCondition],
|
||||
List[components.StopServerToolsWhenConditionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
stream: Literal[True],
|
||||
stream_options: OptionalNullable[
|
||||
Union[components.ChatStreamOptions, components.ChatStreamOptionsTypedDict]
|
||||
@@ -914,7 +984,8 @@ class Chat(BaseSDK):
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param cache_control:
|
||||
:param x_open_router_metadata: Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility.
|
||||
:param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
|
||||
:param debug: Debug options for inspecting request transformations (streaming only)
|
||||
:param frequency_penalty: Frequency penalty (-2.0 to 2.0)
|
||||
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
|
||||
@@ -934,8 +1005,9 @@ class Chat(BaseSDK):
|
||||
:param response_format: Response format configuration
|
||||
:param seed: Random seed for deterministic outputs
|
||||
:param service_tier: The service tier to use for processing this request.
|
||||
:param session_id: 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 256 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
|
||||
:param stop: Stop sequences (up to 4)
|
||||
:param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`.
|
||||
:param stream: Enable streaming response
|
||||
:param stream_options: Streaming configuration options
|
||||
:param temperature: Sampling temperature (0-2)
|
||||
@@ -961,6 +1033,7 @@ class Chat(BaseSDK):
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
x_open_router_metadata: Optional[components.MetadataLevel] = None,
|
||||
cache_control: Optional[
|
||||
Union[
|
||||
components.AnthropicCacheControlDirective,
|
||||
@@ -999,7 +1072,10 @@ class Chat(BaseSDK):
|
||||
]
|
||||
] = UNSET,
|
||||
reasoning: Optional[
|
||||
Union[components.Reasoning, components.ReasoningTypedDict]
|
||||
Union[
|
||||
components.ChatRequestReasoning,
|
||||
components.ChatRequestReasoningTypedDict,
|
||||
]
|
||||
] = None,
|
||||
response_format: Optional[
|
||||
Union[components.ResponseFormat, components.ResponseFormatTypedDict]
|
||||
@@ -1010,6 +1086,12 @@ class Chat(BaseSDK):
|
||||
stop: OptionalNullable[
|
||||
Union[components.Stop, components.StopTypedDict]
|
||||
] = UNSET,
|
||||
stop_server_tools_when: Optional[
|
||||
Union[
|
||||
List[components.StopServerToolsWhenCondition],
|
||||
List[components.StopServerToolsWhenConditionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
stream: Optional[bool] = False,
|
||||
stream_options: OptionalNullable[
|
||||
Union[components.ChatStreamOptions, components.ChatStreamOptionsTypedDict]
|
||||
@@ -1047,7 +1129,8 @@ class Chat(BaseSDK):
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param cache_control:
|
||||
:param x_open_router_metadata: Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility.
|
||||
:param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
|
||||
:param debug: Debug options for inspecting request transformations (streaming only)
|
||||
:param frequency_penalty: Frequency penalty (-2.0 to 2.0)
|
||||
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
|
||||
@@ -1067,8 +1150,9 @@ class Chat(BaseSDK):
|
||||
:param response_format: Response format configuration
|
||||
:param seed: Random seed for deterministic outputs
|
||||
:param service_tier: The service tier to use for processing this request.
|
||||
:param session_id: 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 256 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
|
||||
:param stop: Stop sequences (up to 4)
|
||||
:param stop_server_tools_when: Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`.
|
||||
:param stream: Enable streaming response
|
||||
:param stream_options: Streaming configuration options
|
||||
:param temperature: Sampling temperature (0-2)
|
||||
@@ -1098,6 +1182,7 @@ class Chat(BaseSDK):
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
x_open_router_metadata=x_open_router_metadata,
|
||||
chat_request=components.ChatRequest(
|
||||
cache_control=utils.get_pydantic_model(
|
||||
cache_control, Optional[components.AnthropicCacheControlDirective]
|
||||
@@ -1127,7 +1212,7 @@ class Chat(BaseSDK):
|
||||
provider, OptionalNullable[components.ProviderPreferences]
|
||||
),
|
||||
reasoning=utils.get_pydantic_model(
|
||||
reasoning, Optional[components.Reasoning]
|
||||
reasoning, Optional[components.ChatRequestReasoning]
|
||||
),
|
||||
response_format=utils.get_pydantic_model(
|
||||
response_format, Optional[components.ResponseFormat]
|
||||
@@ -1136,6 +1221,10 @@ class Chat(BaseSDK):
|
||||
service_tier=service_tier,
|
||||
session_id=session_id,
|
||||
stop=stop,
|
||||
stop_server_tools_when=utils.get_pydantic_model(
|
||||
stop_server_tools_when,
|
||||
Optional[List[components.StopServerToolsWhenCondition]],
|
||||
),
|
||||
stream=stream,
|
||||
stream_options=utils.get_pydantic_model(
|
||||
stream_options, OptionalNullable[components.ChatStreamOptions]
|
||||
@@ -1206,6 +1295,7 @@ class Chat(BaseSDK):
|
||||
"400",
|
||||
"401",
|
||||
"402",
|
||||
"403",
|
||||
"404",
|
||||
"408",
|
||||
"413",
|
||||
@@ -1233,7 +1323,7 @@ class Chat(BaseSDK):
|
||||
return eventstreaming.EventStreamAsync(
|
||||
http_res,
|
||||
lambda raw: utils.unmarshal_json(
|
||||
raw, operations.SendChatCompletionRequestResponseBody
|
||||
raw, components.ChatStreamingResponse
|
||||
).data,
|
||||
sentinel="[DONE]",
|
||||
client_ref=self,
|
||||
@@ -1260,6 +1350,12 @@ class Chat(BaseSDK):
|
||||
raise errors.PaymentRequiredResponseError(
|
||||
response_data, http_res, http_res_text
|
||||
)
|
||||
if utils.match_response(http_res, "403", "application/json"):
|
||||
http_res_text = await utils.stream_to_text_async(http_res)
|
||||
response_data = unmarshal_json_response(
|
||||
errors.ForbiddenResponseErrorData, http_res, http_res_text
|
||||
)
|
||||
raise errors.ForbiddenResponseError(response_data, http_res, http_res_text)
|
||||
if utils.match_response(http_res, "404", "application/json"):
|
||||
http_res_text = await utils.stream_to_text_async(http_res)
|
||||
response_data = unmarshal_json_response(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable
|
||||
import pydantic
|
||||
from pydantic import ConfigDict
|
||||
from typing import Any, Dict, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class AdvisorNestedToolTypedDict(TypedDict):
|
||||
r"""A tool made available to the advisor sub-agent. Accepts function tools and OpenRouter server tools (e.g. openrouter:web_search). The advisor tool may not list itself."""
|
||||
|
||||
type: str
|
||||
function: NotRequired[Dict[str, Nullable[Any]]]
|
||||
parameters: NotRequired[Dict[str, Nullable[Any]]]
|
||||
|
||||
|
||||
class AdvisorNestedTool(BaseModel):
|
||||
r"""A tool made available to the advisor sub-agent. Accepts function tools and OpenRouter server tools (e.g. openrouter:web_search). The advisor tool may not list itself."""
|
||||
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
|
||||
)
|
||||
__pydantic_extra__: Dict[str, Nullable[Any]] = pydantic.Field(init=False)
|
||||
|
||||
type: str
|
||||
|
||||
function: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
parameters: Optional[Dict[str, Nullable[Any]]] = None
|
||||
|
||||
@property
|
||||
def additional_properties(self):
|
||||
return self.__pydantic_extra__
|
||||
|
||||
@additional_properties.setter
|
||||
def additional_properties(self, value):
|
||||
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
|
||||
@@ -0,0 +1,43 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
AdvisorReasoningEffort = Union[
|
||||
Literal[
|
||||
"xhigh",
|
||||
"high",
|
||||
"medium",
|
||||
"low",
|
||||
"minimal",
|
||||
"none",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Reasoning effort level for the advisor call."""
|
||||
|
||||
|
||||
class AdvisorReasoningTypedDict(TypedDict):
|
||||
r"""Reasoning configuration forwarded to the advisor call. Use this to control reasoning effort and token budget for models that support extended thinking."""
|
||||
|
||||
effort: NotRequired[AdvisorReasoningEffort]
|
||||
r"""Reasoning effort level for the advisor call."""
|
||||
max_tokens: NotRequired[int]
|
||||
r"""Maximum number of reasoning tokens the advisor may use."""
|
||||
|
||||
|
||||
class AdvisorReasoning(BaseModel):
|
||||
r"""Reasoning configuration forwarded to the advisor call. Use this to control reasoning effort and token budget for models that support extended thinking."""
|
||||
|
||||
effort: Annotated[
|
||||
Optional[AdvisorReasoningEffort], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""Reasoning effort level for the advisor call."""
|
||||
|
||||
max_tokens: Optional[int] = None
|
||||
r"""Maximum number of reasoning tokens the advisor may use."""
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .advisorservertoolconfig import (
|
||||
AdvisorServerToolConfig,
|
||||
AdvisorServerToolConfigTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
AdvisorServerToolOpenRouterType = Literal["openrouter:advisor",]
|
||||
|
||||
|
||||
class AdvisorServerToolOpenRouterTypedDict(TypedDict):
|
||||
r"""OpenRouter built-in server tool: consults a higher-intelligence advisor model (any OpenRouter model) for guidance mid-generation and returns its response. The advisor may run as a sub-agent with its own tools. Include multiple entries to offer several named advisors; at most one entry may omit `name` to act as the default advisor."""
|
||||
|
||||
type: AdvisorServerToolOpenRouterType
|
||||
parameters: NotRequired[AdvisorServerToolConfigTypedDict]
|
||||
r"""Configuration for one openrouter:advisor server tool entry."""
|
||||
|
||||
|
||||
class AdvisorServerToolOpenRouter(BaseModel):
|
||||
r"""OpenRouter built-in server tool: consults a higher-intelligence advisor model (any OpenRouter model) for guidance mid-generation and returns its response. The advisor may run as a sub-agent with its own tools. Include multiple entries to offer several named advisors; at most one entry may omit `name` to act as the default advisor."""
|
||||
|
||||
type: AdvisorServerToolOpenRouterType
|
||||
|
||||
parameters: Optional[AdvisorServerToolConfig] = None
|
||||
r"""Configuration for one openrouter:advisor server tool entry."""
|
||||
@@ -0,0 +1,67 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .advisornestedtool import AdvisorNestedTool, AdvisorNestedToolTypedDict
|
||||
from .advisorreasoning import AdvisorReasoning, AdvisorReasoningTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class AdvisorServerToolConfigTypedDict(TypedDict):
|
||||
r"""Configuration for one openrouter:advisor server tool entry."""
|
||||
|
||||
forward_transcript: NotRequired[bool]
|
||||
r"""When true, the full parent conversation is forwarded to the advisor so it sees the same context the executor does (and the tool-call `prompt`, if given, is appended as a final user turn). When false or omitted, the advisor receives only the `prompt` the executor passes in the tool call."""
|
||||
instructions: NotRequired[str]
|
||||
r"""System instructions for the advisor sub-agent. When omitted, the advisor responds with no system prompt of its own."""
|
||||
max_completion_tokens: NotRequired[int]
|
||||
r"""Maximum number of output tokens (including reasoning) the advisor may produce. When omitted, the provider's default applies."""
|
||||
max_tool_calls: NotRequired[int]
|
||||
r"""Maximum number of tool-calling steps the advisor sub-agent may take during its agentic loop. Capped at 25. Only relevant when the advisor is given tools."""
|
||||
model: NotRequired[str]
|
||||
r"""Slug of the advisor model to consult (any OpenRouter model). When omitted, the executor can choose it via the tool call's `model` argument; if neither is set, the model from the outer API request is used. The advisor tool itself cannot be the advisor model."""
|
||||
name: NotRequired[str]
|
||||
r"""Optional name for this advisor. The model sees one tool per named advisor (and one default for an unnamed entry). Names must be unique across advisor entries. Letters, digits, spaces, underscores, and dashes; trimmed; 1–64 chars."""
|
||||
reasoning: NotRequired[AdvisorReasoningTypedDict]
|
||||
r"""Reasoning configuration forwarded to the advisor call. Use this to control reasoning effort and token budget for models that support extended thinking."""
|
||||
stream: NotRequired[bool]
|
||||
r"""When true, the advisor's advice streams incrementally as it is produced. In the Responses API this emits `response.output_text.delta` events targeting the advisor output item; the final `advice` field is still set on the completed item. Has no effect on the Chat Completions API (where the advice arrives only as the final tool result). When false or omitted, the advice arrives only as the final result."""
|
||||
temperature: NotRequired[float]
|
||||
r"""Sampling temperature forwarded to the advisor call. When omitted, the provider's default applies."""
|
||||
tools: NotRequired[List[AdvisorNestedToolTypedDict]]
|
||||
r"""Tools the advisor sub-agent may use while forming its advice. The advisor runs as an agentic sub-agent over these tools, then returns its text. Must not include the advisor tool itself."""
|
||||
|
||||
|
||||
class AdvisorServerToolConfig(BaseModel):
|
||||
r"""Configuration for one openrouter:advisor server tool entry."""
|
||||
|
||||
forward_transcript: Optional[bool] = None
|
||||
r"""When true, the full parent conversation is forwarded to the advisor so it sees the same context the executor does (and the tool-call `prompt`, if given, is appended as a final user turn). When false or omitted, the advisor receives only the `prompt` the executor passes in the tool call."""
|
||||
|
||||
instructions: Optional[str] = None
|
||||
r"""System instructions for the advisor sub-agent. When omitted, the advisor responds with no system prompt of its own."""
|
||||
|
||||
max_completion_tokens: Optional[int] = None
|
||||
r"""Maximum number of output tokens (including reasoning) the advisor may produce. When omitted, the provider's default applies."""
|
||||
|
||||
max_tool_calls: Optional[int] = None
|
||||
r"""Maximum number of tool-calling steps the advisor sub-agent may take during its agentic loop. Capped at 25. Only relevant when the advisor is given tools."""
|
||||
|
||||
model: Optional[str] = None
|
||||
r"""Slug of the advisor model to consult (any OpenRouter model). When omitted, the executor can choose it via the tool call's `model` argument; if neither is set, the model from the outer API request is used. The advisor tool itself cannot be the advisor model."""
|
||||
|
||||
name: Optional[str] = None
|
||||
r"""Optional name for this advisor. The model sees one tool per named advisor (and one default for an unnamed entry). Names must be unique across advisor entries. Letters, digits, spaces, underscores, and dashes; trimmed; 1–64 chars."""
|
||||
|
||||
reasoning: Optional[AdvisorReasoning] = None
|
||||
r"""Reasoning configuration forwarded to the advisor call. Use this to control reasoning effort and token budget for models that support extended thinking."""
|
||||
|
||||
stream: Optional[bool] = None
|
||||
r"""When true, the advisor's advice streams incrementally as it is produced. In the Responses API this emits `response.output_text.delta` events targeting the advisor output item; the final `advice` field is still set on the completed item. Has no effect on the Chat Completions API (where the advice arrives only as the final tool result). When false or omitted, the advice arrives only as the final result."""
|
||||
|
||||
temperature: Optional[float] = None
|
||||
r"""Sampling temperature forwarded to the advisor call. When omitted, the provider's default applies."""
|
||||
|
||||
tools: Optional[List[AdvisorNestedTool]] = None
|
||||
r"""Tools the advisor sub-agent may use while forming its advice. The advisor runs as an agentic sub-agent over these tools, then returns its text. Must not include the advisor tool itself."""
|
||||
@@ -0,0 +1,15 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
AnthropicAllowedCallers = Union[
|
||||
Literal[
|
||||
"direct",
|
||||
"code_execution_20250825",
|
||||
"code_execution_20260120",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .anthropicimagemimetype import AnthropicImageMimeType
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
AnthropicBase64ImageSourceType = Literal["base64",]
|
||||
|
||||
|
||||
class AnthropicBase64ImageSourceTypedDict(TypedDict):
|
||||
data: str
|
||||
media_type: AnthropicImageMimeType
|
||||
type: AnthropicBase64ImageSourceType
|
||||
|
||||
|
||||
class AnthropicBase64ImageSource(BaseModel):
|
||||
data: str
|
||||
|
||||
media_type: Annotated[
|
||||
AnthropicImageMimeType, PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
|
||||
type: AnthropicBase64ImageSourceType
|
||||
@@ -0,0 +1,26 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicBase64PdfSourceMediaType = Literal["application/pdf",]
|
||||
|
||||
|
||||
AnthropicBase64PdfSourceType = Literal["base64",]
|
||||
|
||||
|
||||
class AnthropicBase64PdfSourceTypedDict(TypedDict):
|
||||
data: str
|
||||
media_type: AnthropicBase64PdfSourceMediaType
|
||||
type: AnthropicBase64PdfSourceType
|
||||
|
||||
|
||||
class AnthropicBase64PdfSource(BaseModel):
|
||||
data: str
|
||||
|
||||
media_type: AnthropicBase64PdfSourceMediaType
|
||||
|
||||
type: AnthropicBase64PdfSourceType
|
||||
@@ -13,14 +13,14 @@ AnthropicCacheControlDirectiveType = Literal["ephemeral",]
|
||||
|
||||
|
||||
class AnthropicCacheControlDirectiveTypedDict(TypedDict):
|
||||
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
type: AnthropicCacheControlDirectiveType
|
||||
ttl: NotRequired[AnthropicCacheControlTTL]
|
||||
|
||||
|
||||
class AnthropicCacheControlDirective(BaseModel):
|
||||
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
type: AnthropicCacheControlDirectiveType
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicCitationCharLocationParamType = Literal["char_location",]
|
||||
|
||||
|
||||
class AnthropicCitationCharLocationParamTypedDict(TypedDict):
|
||||
cited_text: str
|
||||
document_index: int
|
||||
document_title: Nullable[str]
|
||||
end_char_index: int
|
||||
start_char_index: int
|
||||
type: AnthropicCitationCharLocationParamType
|
||||
|
||||
|
||||
class AnthropicCitationCharLocationParam(BaseModel):
|
||||
cited_text: str
|
||||
|
||||
document_index: int
|
||||
|
||||
document_title: Nullable[str]
|
||||
|
||||
end_char_index: int
|
||||
|
||||
start_char_index: int
|
||||
|
||||
type: AnthropicCitationCharLocationParamType
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["document_title"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,63 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicCitationContentBlockLocationParamType = Literal["content_block_location",]
|
||||
|
||||
|
||||
class AnthropicCitationContentBlockLocationParamTypedDict(TypedDict):
|
||||
cited_text: str
|
||||
document_index: int
|
||||
document_title: Nullable[str]
|
||||
end_block_index: int
|
||||
start_block_index: int
|
||||
type: AnthropicCitationContentBlockLocationParamType
|
||||
|
||||
|
||||
class AnthropicCitationContentBlockLocationParam(BaseModel):
|
||||
cited_text: str
|
||||
|
||||
document_index: int
|
||||
|
||||
document_title: Nullable[str]
|
||||
|
||||
end_block_index: int
|
||||
|
||||
start_block_index: int
|
||||
|
||||
type: AnthropicCitationContentBlockLocationParamType
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["document_title"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,63 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicCitationPageLocationParamType = Literal["page_location",]
|
||||
|
||||
|
||||
class AnthropicCitationPageLocationParamTypedDict(TypedDict):
|
||||
cited_text: str
|
||||
document_index: int
|
||||
document_title: Nullable[str]
|
||||
end_page_number: int
|
||||
start_page_number: int
|
||||
type: AnthropicCitationPageLocationParamType
|
||||
|
||||
|
||||
class AnthropicCitationPageLocationParam(BaseModel):
|
||||
cited_text: str
|
||||
|
||||
document_index: int
|
||||
|
||||
document_title: Nullable[str]
|
||||
|
||||
end_page_number: int
|
||||
|
||||
start_page_number: int
|
||||
|
||||
type: AnthropicCitationPageLocationParamType
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["document_title"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,66 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicCitationSearchResultLocationType = Literal["search_result_location",]
|
||||
|
||||
|
||||
class AnthropicCitationSearchResultLocationTypedDict(TypedDict):
|
||||
cited_text: str
|
||||
end_block_index: int
|
||||
search_result_index: int
|
||||
source: str
|
||||
start_block_index: int
|
||||
title: Nullable[str]
|
||||
type: AnthropicCitationSearchResultLocationType
|
||||
|
||||
|
||||
class AnthropicCitationSearchResultLocation(BaseModel):
|
||||
cited_text: str
|
||||
|
||||
end_block_index: int
|
||||
|
||||
search_result_index: int
|
||||
|
||||
source: str
|
||||
|
||||
start_block_index: int
|
||||
|
||||
title: Nullable[str]
|
||||
|
||||
type: AnthropicCitationSearchResultLocationType
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["title"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,60 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicCitationWebSearchResultLocationType = Literal["web_search_result_location",]
|
||||
|
||||
|
||||
class AnthropicCitationWebSearchResultLocationTypedDict(TypedDict):
|
||||
cited_text: str
|
||||
encrypted_index: str
|
||||
title: Nullable[str]
|
||||
type: AnthropicCitationWebSearchResultLocationType
|
||||
url: str
|
||||
|
||||
|
||||
class AnthropicCitationWebSearchResultLocation(BaseModel):
|
||||
cited_text: str
|
||||
|
||||
encrypted_index: str
|
||||
|
||||
title: Nullable[str]
|
||||
|
||||
type: AnthropicCitationWebSearchResultLocationType
|
||||
|
||||
url: str
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["title"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,164 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .anthropicbase64pdfsource import (
|
||||
AnthropicBase64PdfSource,
|
||||
AnthropicBase64PdfSourceTypedDict,
|
||||
)
|
||||
from .anthropiccachecontroldirective import (
|
||||
AnthropicCacheControlDirective,
|
||||
AnthropicCacheControlDirectiveTypedDict,
|
||||
)
|
||||
from .anthropicimageblockparam import (
|
||||
AnthropicImageBlockParam,
|
||||
AnthropicImageBlockParamTypedDict,
|
||||
)
|
||||
from .anthropicplaintextsource import (
|
||||
AnthropicPlainTextSource,
|
||||
AnthropicPlainTextSourceTypedDict,
|
||||
)
|
||||
from .anthropictextblockparam import (
|
||||
AnthropicTextBlockParam,
|
||||
AnthropicTextBlockParamTypedDict,
|
||||
)
|
||||
from .anthropicurlpdfsource import AnthropicURLPdfSource, AnthropicURLPdfSourceTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class AnthropicDocumentBlockParamCitationsTypedDict(TypedDict):
|
||||
enabled: NotRequired[bool]
|
||||
|
||||
|
||||
class AnthropicDocumentBlockParamCitations(BaseModel):
|
||||
enabled: Optional[bool] = None
|
||||
|
||||
|
||||
AnthropicDocumentBlockParamContent1TypedDict = TypeAliasType(
|
||||
"AnthropicDocumentBlockParamContent1TypedDict",
|
||||
Union[AnthropicImageBlockParamTypedDict, AnthropicTextBlockParamTypedDict],
|
||||
)
|
||||
|
||||
|
||||
AnthropicDocumentBlockParamContent1 = Annotated[
|
||||
Union[
|
||||
Annotated[AnthropicImageBlockParam, Tag("image")],
|
||||
Annotated[AnthropicTextBlockParam, Tag("text")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
AnthropicDocumentBlockParamContent2TypedDict = TypeAliasType(
|
||||
"AnthropicDocumentBlockParamContent2TypedDict",
|
||||
Union[str, List[AnthropicDocumentBlockParamContent1TypedDict]],
|
||||
)
|
||||
|
||||
|
||||
AnthropicDocumentBlockParamContent2 = TypeAliasType(
|
||||
"AnthropicDocumentBlockParamContent2",
|
||||
Union[str, List[AnthropicDocumentBlockParamContent1]],
|
||||
)
|
||||
|
||||
|
||||
SourceType = Literal["content",]
|
||||
|
||||
|
||||
class SourceContentTypedDict(TypedDict):
|
||||
content: AnthropicDocumentBlockParamContent2TypedDict
|
||||
type: SourceType
|
||||
|
||||
|
||||
class SourceContent(BaseModel):
|
||||
content: AnthropicDocumentBlockParamContent2
|
||||
|
||||
type: SourceType
|
||||
|
||||
|
||||
AnthropicDocumentBlockParamSourceUnionTypedDict = TypeAliasType(
|
||||
"AnthropicDocumentBlockParamSourceUnionTypedDict",
|
||||
Union[
|
||||
SourceContentTypedDict,
|
||||
AnthropicURLPdfSourceTypedDict,
|
||||
AnthropicBase64PdfSourceTypedDict,
|
||||
AnthropicPlainTextSourceTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
AnthropicDocumentBlockParamSourceUnion = Annotated[
|
||||
Union[
|
||||
Annotated[AnthropicBase64PdfSource, Tag("base64")],
|
||||
Annotated[AnthropicPlainTextSource, Tag("text")],
|
||||
Annotated[SourceContent, Tag("content")],
|
||||
Annotated[AnthropicURLPdfSource, Tag("url")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
TypeDocument = Literal["document",]
|
||||
|
||||
|
||||
class AnthropicDocumentBlockParamTypedDict(TypedDict):
|
||||
source: AnthropicDocumentBlockParamSourceUnionTypedDict
|
||||
type: TypeDocument
|
||||
cache_control: NotRequired[AnthropicCacheControlDirectiveTypedDict]
|
||||
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
citations: NotRequired[Nullable[AnthropicDocumentBlockParamCitationsTypedDict]]
|
||||
context: NotRequired[Nullable[str]]
|
||||
title: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class AnthropicDocumentBlockParam(BaseModel):
|
||||
source: AnthropicDocumentBlockParamSourceUnion
|
||||
|
||||
type: TypeDocument
|
||||
|
||||
cache_control: Optional[AnthropicCacheControlDirective] = None
|
||||
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
citations: OptionalNullable[AnthropicDocumentBlockParamCitations] = UNSET
|
||||
|
||||
context: OptionalNullable[str] = UNSET
|
||||
|
||||
title: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["cache_control", "citations", "context", "title"]
|
||||
nullable_fields = ["citations", "context", "title"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .anthropicbase64imagesource import (
|
||||
AnthropicBase64ImageSource,
|
||||
AnthropicBase64ImageSourceTypedDict,
|
||||
)
|
||||
from .anthropiccachecontroldirective import (
|
||||
AnthropicCacheControlDirective,
|
||||
AnthropicCacheControlDirectiveTypedDict,
|
||||
)
|
||||
from .anthropicurlimagesource import (
|
||||
AnthropicURLImageSource,
|
||||
AnthropicURLImageSourceTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
AnthropicImageBlockParamSourceTypedDict = TypeAliasType(
|
||||
"AnthropicImageBlockParamSourceTypedDict",
|
||||
Union[AnthropicURLImageSourceTypedDict, AnthropicBase64ImageSourceTypedDict],
|
||||
)
|
||||
|
||||
|
||||
AnthropicImageBlockParamSource = Annotated[
|
||||
Union[
|
||||
Annotated[AnthropicBase64ImageSource, Tag("base64")],
|
||||
Annotated[AnthropicURLImageSource, Tag("url")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
AnthropicImageBlockParamType = Literal["image",]
|
||||
|
||||
|
||||
class AnthropicImageBlockParamTypedDict(TypedDict):
|
||||
source: AnthropicImageBlockParamSourceTypedDict
|
||||
type: AnthropicImageBlockParamType
|
||||
cache_control: NotRequired[AnthropicCacheControlDirectiveTypedDict]
|
||||
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
|
||||
class AnthropicImageBlockParam(BaseModel):
|
||||
source: AnthropicImageBlockParamSource
|
||||
|
||||
type: AnthropicImageBlockParamType
|
||||
|
||||
cache_control: Optional[AnthropicCacheControlDirective] = None
|
||||
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
@@ -0,0 +1,16 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
AnthropicImageMimeType = Union[
|
||||
Literal[
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/gif",
|
||||
"image/webp",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicInputTokensClearAtLeastType = Literal["input_tokens",]
|
||||
|
||||
|
||||
class AnthropicInputTokensClearAtLeastTypedDict(TypedDict):
|
||||
type: AnthropicInputTokensClearAtLeastType
|
||||
value: int
|
||||
|
||||
|
||||
class AnthropicInputTokensClearAtLeast(BaseModel):
|
||||
type: AnthropicInputTokensClearAtLeastType
|
||||
|
||||
value: int
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicInputTokensTriggerType = Literal["input_tokens",]
|
||||
|
||||
|
||||
class AnthropicInputTokensTriggerTypedDict(TypedDict):
|
||||
type: AnthropicInputTokensTriggerType
|
||||
value: int
|
||||
|
||||
|
||||
class AnthropicInputTokensTrigger(BaseModel):
|
||||
type: AnthropicInputTokensTriggerType
|
||||
|
||||
value: int
|
||||
@@ -0,0 +1,26 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicPlainTextSourceMediaType = Literal["text/plain",]
|
||||
|
||||
|
||||
AnthropicPlainTextSourceType = Literal["text",]
|
||||
|
||||
|
||||
class AnthropicPlainTextSourceTypedDict(TypedDict):
|
||||
data: str
|
||||
media_type: AnthropicPlainTextSourceMediaType
|
||||
type: AnthropicPlainTextSourceType
|
||||
|
||||
|
||||
class AnthropicPlainTextSource(BaseModel):
|
||||
data: str
|
||||
|
||||
media_type: AnthropicPlainTextSourceMediaType
|
||||
|
||||
type: AnthropicPlainTextSourceType
|
||||
@@ -0,0 +1,50 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .anthropiccachecontroldirective import (
|
||||
AnthropicCacheControlDirective,
|
||||
AnthropicCacheControlDirectiveTypedDict,
|
||||
)
|
||||
from .anthropictextblockparam import (
|
||||
AnthropicTextBlockParam,
|
||||
AnthropicTextBlockParamTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class AnthropicSearchResultBlockParamCitationsTypedDict(TypedDict):
|
||||
enabled: NotRequired[bool]
|
||||
|
||||
|
||||
class AnthropicSearchResultBlockParamCitations(BaseModel):
|
||||
enabled: Optional[bool] = None
|
||||
|
||||
|
||||
AnthropicSearchResultBlockParamType = Literal["search_result",]
|
||||
|
||||
|
||||
class AnthropicSearchResultBlockParamTypedDict(TypedDict):
|
||||
content: List[AnthropicTextBlockParamTypedDict]
|
||||
source: str
|
||||
title: str
|
||||
type: AnthropicSearchResultBlockParamType
|
||||
cache_control: NotRequired[AnthropicCacheControlDirectiveTypedDict]
|
||||
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
citations: NotRequired[AnthropicSearchResultBlockParamCitationsTypedDict]
|
||||
|
||||
|
||||
class AnthropicSearchResultBlockParam(BaseModel):
|
||||
content: List[AnthropicTextBlockParam]
|
||||
|
||||
source: str
|
||||
|
||||
title: str
|
||||
|
||||
type: AnthropicSearchResultBlockParamType
|
||||
|
||||
cache_control: Optional[AnthropicCacheControlDirective] = None
|
||||
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
citations: Optional[AnthropicSearchResultBlockParamCitations] = None
|
||||
@@ -0,0 +1,118 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .anthropiccachecontroldirective import (
|
||||
AnthropicCacheControlDirective,
|
||||
AnthropicCacheControlDirectiveTypedDict,
|
||||
)
|
||||
from .anthropiccitationcharlocationparam import (
|
||||
AnthropicCitationCharLocationParam,
|
||||
AnthropicCitationCharLocationParamTypedDict,
|
||||
)
|
||||
from .anthropiccitationcontentblocklocationparam import (
|
||||
AnthropicCitationContentBlockLocationParam,
|
||||
AnthropicCitationContentBlockLocationParamTypedDict,
|
||||
)
|
||||
from .anthropiccitationpagelocationparam import (
|
||||
AnthropicCitationPageLocationParam,
|
||||
AnthropicCitationPageLocationParamTypedDict,
|
||||
)
|
||||
from .anthropiccitationsearchresultlocation import (
|
||||
AnthropicCitationSearchResultLocation,
|
||||
AnthropicCitationSearchResultLocationTypedDict,
|
||||
)
|
||||
from .anthropiccitationwebsearchresultlocation import (
|
||||
AnthropicCitationWebSearchResultLocation,
|
||||
AnthropicCitationWebSearchResultLocationTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
CitationTypedDict = TypeAliasType(
|
||||
"CitationTypedDict",
|
||||
Union[
|
||||
AnthropicCitationWebSearchResultLocationTypedDict,
|
||||
AnthropicCitationCharLocationParamTypedDict,
|
||||
AnthropicCitationPageLocationParamTypedDict,
|
||||
AnthropicCitationContentBlockLocationParamTypedDict,
|
||||
AnthropicCitationSearchResultLocationTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Citation = Annotated[
|
||||
Union[
|
||||
Annotated[AnthropicCitationCharLocationParam, Tag("char_location")],
|
||||
Annotated[
|
||||
AnthropicCitationContentBlockLocationParam, Tag("content_block_location")
|
||||
],
|
||||
Annotated[AnthropicCitationPageLocationParam, Tag("page_location")],
|
||||
Annotated[AnthropicCitationSearchResultLocation, Tag("search_result_location")],
|
||||
Annotated[
|
||||
AnthropicCitationWebSearchResultLocation, Tag("web_search_result_location")
|
||||
],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
AnthropicTextBlockParamType = Literal["text",]
|
||||
|
||||
|
||||
class AnthropicTextBlockParamTypedDict(TypedDict):
|
||||
text: str
|
||||
type: AnthropicTextBlockParamType
|
||||
cache_control: NotRequired[AnthropicCacheControlDirectiveTypedDict]
|
||||
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
citations: NotRequired[Nullable[List[CitationTypedDict]]]
|
||||
|
||||
|
||||
class AnthropicTextBlockParam(BaseModel):
|
||||
text: str
|
||||
|
||||
type: AnthropicTextBlockParamType
|
||||
|
||||
cache_control: Optional[AnthropicCacheControlDirective] = None
|
||||
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
citations: OptionalNullable[List[Citation]] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["cache_control", "citations"]
|
||||
nullable_fields = ["citations"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,14 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
AnthropicThinkingDisplay = Union[
|
||||
Literal[
|
||||
"summarized",
|
||||
"omitted",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicThinkingTurnsType = Literal["thinking_turns",]
|
||||
|
||||
|
||||
class AnthropicThinkingTurnsTypedDict(TypedDict):
|
||||
type: AnthropicThinkingTurnsType
|
||||
value: int
|
||||
|
||||
|
||||
class AnthropicThinkingTurns(BaseModel):
|
||||
type: AnthropicThinkingTurnsType
|
||||
|
||||
value: int
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicToolUsesKeepType = Literal["tool_uses",]
|
||||
|
||||
|
||||
class AnthropicToolUsesKeepTypedDict(TypedDict):
|
||||
type: AnthropicToolUsesKeepType
|
||||
value: int
|
||||
|
||||
|
||||
class AnthropicToolUsesKeep(BaseModel):
|
||||
type: AnthropicToolUsesKeepType
|
||||
|
||||
value: int
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicToolUsesTriggerType = Literal["tool_uses",]
|
||||
|
||||
|
||||
class AnthropicToolUsesTriggerTypedDict(TypedDict):
|
||||
type: AnthropicToolUsesTriggerType
|
||||
value: int
|
||||
|
||||
|
||||
class AnthropicToolUsesTrigger(BaseModel):
|
||||
type: AnthropicToolUsesTriggerType
|
||||
|
||||
value: int
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicURLImageSourceType = Literal["url",]
|
||||
|
||||
|
||||
class AnthropicURLImageSourceTypedDict(TypedDict):
|
||||
type: AnthropicURLImageSourceType
|
||||
url: str
|
||||
|
||||
|
||||
class AnthropicURLImageSource(BaseModel):
|
||||
type: AnthropicURLImageSourceType
|
||||
|
||||
url: str
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
AnthropicURLPdfSourceType = Literal["url",]
|
||||
|
||||
|
||||
class AnthropicURLPdfSourceTypedDict(TypedDict):
|
||||
type: AnthropicURLPdfSourceType
|
||||
url: str
|
||||
|
||||
|
||||
class AnthropicURLPdfSource(BaseModel):
|
||||
type: AnthropicURLPdfSourceType
|
||||
|
||||
url: str
|
||||
@@ -0,0 +1,66 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
AnthropicWebSearchResultBlockParamType = Literal["web_search_result",]
|
||||
|
||||
|
||||
class AnthropicWebSearchResultBlockParamTypedDict(TypedDict):
|
||||
encrypted_content: str
|
||||
title: str
|
||||
type: AnthropicWebSearchResultBlockParamType
|
||||
url: str
|
||||
page_age: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class AnthropicWebSearchResultBlockParam(BaseModel):
|
||||
encrypted_content: str
|
||||
|
||||
title: str
|
||||
|
||||
type: AnthropicWebSearchResultBlockParamType
|
||||
|
||||
url: str
|
||||
|
||||
page_age: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["page_age"]
|
||||
nullable_fields = ["page_age"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,66 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
AnthropicWebSearchToolUserLocationType = Literal["approximate",]
|
||||
|
||||
|
||||
class AnthropicWebSearchToolUserLocationTypedDict(TypedDict):
|
||||
type: AnthropicWebSearchToolUserLocationType
|
||||
city: NotRequired[Nullable[str]]
|
||||
country: NotRequired[Nullable[str]]
|
||||
region: NotRequired[Nullable[str]]
|
||||
timezone: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class AnthropicWebSearchToolUserLocation(BaseModel):
|
||||
type: AnthropicWebSearchToolUserLocationType
|
||||
|
||||
city: OptionalNullable[str] = UNSET
|
||||
|
||||
country: OptionalNullable[str] = UNSET
|
||||
|
||||
region: OptionalNullable[str] = UNSET
|
||||
|
||||
timezone: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["city", "country", "region", "timezone"]
|
||||
nullable_fields = ["city", "country", "region", "timezone"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,81 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .applypatchcalloperation import (
|
||||
ApplyPatchCallOperation,
|
||||
ApplyPatchCallOperationTypedDict,
|
||||
)
|
||||
from .applypatchcallstatus import ApplyPatchCallStatus
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
ApplyPatchCallItemType = Literal["apply_patch_call",]
|
||||
|
||||
|
||||
class ApplyPatchCallItemTypedDict(TypedDict):
|
||||
r"""A tool call emitted by the model requesting a V4A patch operation. The client applies the patch and echoes an `apply_patch_call_output` on the next turn."""
|
||||
|
||||
call_id: str
|
||||
operation: ApplyPatchCallOperationTypedDict
|
||||
r"""The patch operation requested by an `apply_patch_call`. `create_file` and `update_file` carry a V4A diff; `delete_file` omits it."""
|
||||
status: ApplyPatchCallStatus
|
||||
r"""Lifecycle state of an `apply_patch_call` output item."""
|
||||
type: ApplyPatchCallItemType
|
||||
id: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class ApplyPatchCallItem(BaseModel):
|
||||
r"""A tool call emitted by the model requesting a V4A patch operation. The client applies the patch and echoes an `apply_patch_call_output` on the next turn."""
|
||||
|
||||
call_id: str
|
||||
|
||||
operation: ApplyPatchCallOperation
|
||||
r"""The patch operation requested by an `apply_patch_call`. `create_file` and `update_file` carry a V4A diff; `delete_file` omits it."""
|
||||
|
||||
status: Annotated[ApplyPatchCallStatus, PlainValidator(validate_open_enum(False))]
|
||||
r"""Lifecycle state of an `apply_patch_call` output item."""
|
||||
|
||||
type: ApplyPatchCallItemType
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["id"]
|
||||
nullable_fields = ["id"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,41 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .applypatchcreatefileoperation import (
|
||||
ApplyPatchCreateFileOperation,
|
||||
ApplyPatchCreateFileOperationTypedDict,
|
||||
)
|
||||
from .applypatchdeletefileoperation import (
|
||||
ApplyPatchDeleteFileOperation,
|
||||
ApplyPatchDeleteFileOperationTypedDict,
|
||||
)
|
||||
from .applypatchupdatefileoperation import (
|
||||
ApplyPatchUpdateFileOperation,
|
||||
ApplyPatchUpdateFileOperationTypedDict,
|
||||
)
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import Union
|
||||
from typing_extensions import Annotated, TypeAliasType
|
||||
|
||||
|
||||
ApplyPatchCallOperationTypedDict = TypeAliasType(
|
||||
"ApplyPatchCallOperationTypedDict",
|
||||
Union[
|
||||
ApplyPatchDeleteFileOperationTypedDict,
|
||||
ApplyPatchCreateFileOperationTypedDict,
|
||||
ApplyPatchUpdateFileOperationTypedDict,
|
||||
],
|
||||
)
|
||||
r"""The patch operation requested by an `apply_patch_call`. `create_file` and `update_file` carry a V4A diff; `delete_file` omits it."""
|
||||
|
||||
|
||||
ApplyPatchCallOperation = Annotated[
|
||||
Union[
|
||||
Annotated[ApplyPatchCreateFileOperation, Tag("create_file")],
|
||||
Annotated[ApplyPatchDeleteFileOperation, Tag("delete_file")],
|
||||
Annotated[ApplyPatchUpdateFileOperation, Tag("update_file")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
r"""The patch operation requested by an `apply_patch_call`. `create_file` and `update_file` carry a V4A diff; `delete_file` omits it."""
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user