mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-08-08 11:22:59 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf339d9530 |
+6
-4
@@ -1,12 +1,12 @@
|
|||||||
lockVersion: 2.0.0
|
lockVersion: 2.0.0
|
||||||
id: cfd52247-6a25-4c6d-bbce-fe6fce0cd69d
|
id: cfd52247-6a25-4c6d-bbce-fe6fce0cd69d
|
||||||
management:
|
management:
|
||||||
docChecksum: 342e7e8ea9cb2b7ff1c1860e18d58822
|
docChecksum: b46bf86766cf18470329da1fb2271f4e
|
||||||
docVersion: 1.0.0
|
docVersion: 1.0.0
|
||||||
speakeasyVersion: 1.666.0
|
speakeasyVersion: 1.666.0
|
||||||
generationVersion: 2.768.0
|
generationVersion: 2.768.0
|
||||||
releaseVersion: 0.3.0
|
releaseVersion: 0.3.2
|
||||||
configChecksum: 987e66c3a2350c79a554bfc232ca4961
|
configChecksum: 684039465cd4c6f0105466ef2833908d
|
||||||
repoURL: https://github.com/OpenRouterTeam/python-sdk.git
|
repoURL: https://github.com/OpenRouterTeam/python-sdk.git
|
||||||
installationURL: https://github.com/OpenRouterTeam/python-sdk.git
|
installationURL: https://github.com/OpenRouterTeam/python-sdk.git
|
||||||
published: true
|
published: true
|
||||||
@@ -593,6 +593,8 @@ generatedFiles:
|
|||||||
- docs/operations/metadata.md
|
- docs/operations/metadata.md
|
||||||
- docs/operations/object.md
|
- docs/operations/object.md
|
||||||
- docs/operations/objectembedding.md
|
- docs/operations/objectembedding.md
|
||||||
|
- docs/operations/providername.md
|
||||||
|
- docs/operations/providerresponse.md
|
||||||
- docs/operations/ratelimit.md
|
- docs/operations/ratelimit.md
|
||||||
- docs/operations/sendchatcompletionrequestresponse.md
|
- docs/operations/sendchatcompletionrequestresponse.md
|
||||||
- docs/operations/transferintent.md
|
- docs/operations/transferintent.md
|
||||||
@@ -1001,7 +1003,7 @@ examples:
|
|||||||
id: "<id>"
|
id: "<id>"
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
application/json: {"data": {"id": "gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG", "upstream_id": "chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946", "total_cost": 0.0015, "cache_discount": 0.0002, "upstream_inference_cost": 0.0012, "created_at": "2024-07-15T23:33:19.433273+00:00", "model": "sao10k/l3-stheno-8b", "app_id": 12345, "streamed": true, "cancelled": false, "provider_name": "Infermatic", "latency": 1250, "moderation_latency": 50, "generation_time": 1200, "finish_reason": "stop", "tokens_prompt": 10, "tokens_completion": 25, "native_tokens_prompt": 10, "native_tokens_completion": 25, "native_tokens_completion_images": 0, "native_tokens_reasoning": 5, "native_tokens_cached": 3, "num_media_prompt": 1, "num_input_audio_prompt": 0, "num_media_completion": 0, "num_search_results": 5, "origin": "https://openrouter.ai/", "usage": 0.0015, "is_byok": false, "native_finish_reason": "stop", "external_user": "user-123", "api_type": "completions", "router": "openrouter/auto"}}
|
application/json: {"data": {"id": "gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG", "upstream_id": "chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946", "total_cost": 0.0015, "cache_discount": 0.0002, "upstream_inference_cost": 0.0012, "created_at": "2024-07-15T23:33:19.433273+00:00", "model": "sao10k/l3-stheno-8b", "app_id": 12345, "streamed": true, "cancelled": false, "provider_name": "Infermatic", "latency": 1250, "moderation_latency": 50, "generation_time": 1200, "finish_reason": "stop", "tokens_prompt": 10, "tokens_completion": 25, "native_tokens_prompt": 10, "native_tokens_completion": 25, "native_tokens_completion_images": 0, "native_tokens_reasoning": 5, "native_tokens_cached": 3, "num_media_prompt": 1, "num_input_audio_prompt": 0, "num_media_completion": 0, "num_search_results": 5, "origin": "https://openrouter.ai/", "usage": 0.0015, "is_byok": false, "native_finish_reason": "stop", "external_user": "user-123", "api_type": "completions", "router": "openrouter/auto", "provider_responses": []}}
|
||||||
"401":
|
"401":
|
||||||
application/json: {"error": {"code": 401, "message": "Missing Authentication header"}}
|
application/json: {"error": {"code": 401, "message": "Missing Authentication header"}}
|
||||||
"402":
|
"402":
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ generation:
|
|||||||
skipResponseBodyAssertions: false
|
skipResponseBodyAssertions: false
|
||||||
preApplyUnionDiscriminators: true
|
preApplyUnionDiscriminators: true
|
||||||
python:
|
python:
|
||||||
version: 0.3.0
|
version: 0.3.2
|
||||||
additionalDependencies:
|
additionalDependencies:
|
||||||
dev: {}
|
dev: {}
|
||||||
main: {}
|
main: {}
|
||||||
|
|||||||
@@ -3542,6 +3542,7 @@ components:
|
|||||||
- AI21
|
- AI21
|
||||||
- AionLabs
|
- AionLabs
|
||||||
- Alibaba
|
- Alibaba
|
||||||
|
- Ambient
|
||||||
- Amazon Bedrock
|
- Amazon Bedrock
|
||||||
- Amazon Nova
|
- Amazon Nova
|
||||||
- Anthropic
|
- Anthropic
|
||||||
@@ -8110,6 +8111,7 @@ components:
|
|||||||
- AI21
|
- AI21
|
||||||
- AionLabs
|
- AionLabs
|
||||||
- Alibaba
|
- Alibaba
|
||||||
|
- Ambient
|
||||||
- Amazon Bedrock
|
- Amazon Bedrock
|
||||||
- Amazon Nova
|
- Amazon Nova
|
||||||
- Anthropic
|
- Anthropic
|
||||||
@@ -10355,6 +10357,130 @@ paths:
|
|||||||
nullable: true
|
nullable: true
|
||||||
description: Router used for the request (e.g., openrouter/auto)
|
description: Router used for the request (e.g., openrouter/auto)
|
||||||
example: openrouter/auto
|
example: openrouter/auto
|
||||||
|
provider_responses:
|
||||||
|
type: array
|
||||||
|
nullable: true
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
endpoint_id:
|
||||||
|
type: string
|
||||||
|
model_permaslug:
|
||||||
|
type: string
|
||||||
|
provider_name:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- AnyScale
|
||||||
|
- Atoma
|
||||||
|
- Cent-ML
|
||||||
|
- CrofAI
|
||||||
|
- Enfer
|
||||||
|
- GoPomelo
|
||||||
|
- HuggingFace
|
||||||
|
- Hyperbolic 2
|
||||||
|
- InoCloud
|
||||||
|
- Kluster
|
||||||
|
- Lambda
|
||||||
|
- Lepton
|
||||||
|
- Lynn 2
|
||||||
|
- Lynn
|
||||||
|
- Mancer
|
||||||
|
- Meta
|
||||||
|
- Modal
|
||||||
|
- Nineteen
|
||||||
|
- OctoAI
|
||||||
|
- Recursal
|
||||||
|
- Reflection
|
||||||
|
- Replicate
|
||||||
|
- SambaNova 2
|
||||||
|
- SF Compute
|
||||||
|
- Targon
|
||||||
|
- Together 2
|
||||||
|
- Ubicloud
|
||||||
|
- 01.AI
|
||||||
|
- AI21
|
||||||
|
- AionLabs
|
||||||
|
- Alibaba
|
||||||
|
- Ambient
|
||||||
|
- Amazon Bedrock
|
||||||
|
- Amazon Nova
|
||||||
|
- Anthropic
|
||||||
|
- Arcee AI
|
||||||
|
- AtlasCloud
|
||||||
|
- Avian
|
||||||
|
- Azure
|
||||||
|
- BaseTen
|
||||||
|
- BytePlus
|
||||||
|
- Black Forest Labs
|
||||||
|
- Cerebras
|
||||||
|
- Chutes
|
||||||
|
- Cirrascale
|
||||||
|
- Clarifai
|
||||||
|
- Cloudflare
|
||||||
|
- Cohere
|
||||||
|
- Crusoe
|
||||||
|
- DeepInfra
|
||||||
|
- DeepSeek
|
||||||
|
- Featherless
|
||||||
|
- Fireworks
|
||||||
|
- Friendli
|
||||||
|
- GMICloud
|
||||||
|
- Google
|
||||||
|
- Google AI Studio
|
||||||
|
- Groq
|
||||||
|
- Hyperbolic
|
||||||
|
- Inception
|
||||||
|
- Inceptron
|
||||||
|
- InferenceNet
|
||||||
|
- Infermatic
|
||||||
|
- Inflection
|
||||||
|
- Liquid
|
||||||
|
- Mara
|
||||||
|
- Mancer 2
|
||||||
|
- Minimax
|
||||||
|
- ModelRun
|
||||||
|
- Mistral
|
||||||
|
- Modular
|
||||||
|
- Moonshot AI
|
||||||
|
- Morph
|
||||||
|
- NCompass
|
||||||
|
- Nebius
|
||||||
|
- NextBit
|
||||||
|
- Novita
|
||||||
|
- Nvidia
|
||||||
|
- OpenAI
|
||||||
|
- OpenInference
|
||||||
|
- Parasail
|
||||||
|
- Perplexity
|
||||||
|
- Phala
|
||||||
|
- Relace
|
||||||
|
- SambaNova
|
||||||
|
- Seed
|
||||||
|
- SiliconFlow
|
||||||
|
- Sourceful
|
||||||
|
- Stealth
|
||||||
|
- StreamLake
|
||||||
|
- Switchpoint
|
||||||
|
- Together
|
||||||
|
- Upstage
|
||||||
|
- Venice
|
||||||
|
- WandB
|
||||||
|
- Xiaomi
|
||||||
|
- xAI
|
||||||
|
- Z.AI
|
||||||
|
- FakeProvider
|
||||||
|
status:
|
||||||
|
type: number
|
||||||
|
nullable: true
|
||||||
|
latency:
|
||||||
|
type: number
|
||||||
|
is_byok:
|
||||||
|
type: boolean
|
||||||
|
required:
|
||||||
|
- status
|
||||||
|
description: List of provider responses for this generation, including fallback attempts
|
||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
- upstream_id
|
- upstream_id
|
||||||
@@ -10389,6 +10515,7 @@ paths:
|
|||||||
- external_user
|
- external_user
|
||||||
- api_type
|
- api_type
|
||||||
- router
|
- router
|
||||||
|
- provider_responses
|
||||||
description: Generation data
|
description: Generation data
|
||||||
required:
|
required:
|
||||||
- data
|
- data
|
||||||
|
|||||||
@@ -3561,6 +3561,7 @@ components:
|
|||||||
- AI21
|
- AI21
|
||||||
- AionLabs
|
- AionLabs
|
||||||
- Alibaba
|
- Alibaba
|
||||||
|
- Ambient
|
||||||
- Amazon Bedrock
|
- Amazon Bedrock
|
||||||
- Amazon Nova
|
- Amazon Nova
|
||||||
- Anthropic
|
- Anthropic
|
||||||
@@ -8124,6 +8125,7 @@ components:
|
|||||||
- AI21
|
- AI21
|
||||||
- AionLabs
|
- AionLabs
|
||||||
- Alibaba
|
- Alibaba
|
||||||
|
- Ambient
|
||||||
- Amazon Bedrock
|
- Amazon Bedrock
|
||||||
- Amazon Nova
|
- Amazon Nova
|
||||||
- Anthropic
|
- Anthropic
|
||||||
@@ -10363,6 +10365,131 @@ paths:
|
|||||||
nullable: true
|
nullable: true
|
||||||
description: Router used for the request (e.g., openrouter/auto)
|
description: Router used for the request (e.g., openrouter/auto)
|
||||||
example: openrouter/auto
|
example: openrouter/auto
|
||||||
|
provider_responses:
|
||||||
|
type: array
|
||||||
|
nullable: true
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
endpoint_id:
|
||||||
|
type: string
|
||||||
|
model_permaslug:
|
||||||
|
type: string
|
||||||
|
provider_name:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- AnyScale
|
||||||
|
- Atoma
|
||||||
|
- Cent-ML
|
||||||
|
- CrofAI
|
||||||
|
- Enfer
|
||||||
|
- GoPomelo
|
||||||
|
- HuggingFace
|
||||||
|
- Hyperbolic 2
|
||||||
|
- InoCloud
|
||||||
|
- Kluster
|
||||||
|
- Lambda
|
||||||
|
- Lepton
|
||||||
|
- Lynn 2
|
||||||
|
- Lynn
|
||||||
|
- Mancer
|
||||||
|
- Meta
|
||||||
|
- Modal
|
||||||
|
- Nineteen
|
||||||
|
- OctoAI
|
||||||
|
- Recursal
|
||||||
|
- Reflection
|
||||||
|
- Replicate
|
||||||
|
- SambaNova 2
|
||||||
|
- SF Compute
|
||||||
|
- Targon
|
||||||
|
- Together 2
|
||||||
|
- Ubicloud
|
||||||
|
- 01.AI
|
||||||
|
- AI21
|
||||||
|
- AionLabs
|
||||||
|
- Alibaba
|
||||||
|
- Ambient
|
||||||
|
- Amazon Bedrock
|
||||||
|
- Amazon Nova
|
||||||
|
- Anthropic
|
||||||
|
- Arcee AI
|
||||||
|
- AtlasCloud
|
||||||
|
- Avian
|
||||||
|
- Azure
|
||||||
|
- BaseTen
|
||||||
|
- BytePlus
|
||||||
|
- Black Forest Labs
|
||||||
|
- Cerebras
|
||||||
|
- Chutes
|
||||||
|
- Cirrascale
|
||||||
|
- Clarifai
|
||||||
|
- Cloudflare
|
||||||
|
- Cohere
|
||||||
|
- Crusoe
|
||||||
|
- DeepInfra
|
||||||
|
- DeepSeek
|
||||||
|
- Featherless
|
||||||
|
- Fireworks
|
||||||
|
- Friendli
|
||||||
|
- GMICloud
|
||||||
|
- Google
|
||||||
|
- Google AI Studio
|
||||||
|
- Groq
|
||||||
|
- Hyperbolic
|
||||||
|
- Inception
|
||||||
|
- Inceptron
|
||||||
|
- InferenceNet
|
||||||
|
- Infermatic
|
||||||
|
- Inflection
|
||||||
|
- Liquid
|
||||||
|
- Mara
|
||||||
|
- Mancer 2
|
||||||
|
- Minimax
|
||||||
|
- ModelRun
|
||||||
|
- Mistral
|
||||||
|
- Modular
|
||||||
|
- Moonshot AI
|
||||||
|
- Morph
|
||||||
|
- NCompass
|
||||||
|
- Nebius
|
||||||
|
- NextBit
|
||||||
|
- Novita
|
||||||
|
- Nvidia
|
||||||
|
- OpenAI
|
||||||
|
- OpenInference
|
||||||
|
- Parasail
|
||||||
|
- Perplexity
|
||||||
|
- Phala
|
||||||
|
- Relace
|
||||||
|
- SambaNova
|
||||||
|
- Seed
|
||||||
|
- SiliconFlow
|
||||||
|
- Sourceful
|
||||||
|
- Stealth
|
||||||
|
- StreamLake
|
||||||
|
- Switchpoint
|
||||||
|
- Together
|
||||||
|
- Upstage
|
||||||
|
- Venice
|
||||||
|
- WandB
|
||||||
|
- Xiaomi
|
||||||
|
- xAI
|
||||||
|
- Z.AI
|
||||||
|
- FakeProvider
|
||||||
|
x-speakeasy-unknown-values: allow
|
||||||
|
status:
|
||||||
|
type: number
|
||||||
|
nullable: true
|
||||||
|
latency:
|
||||||
|
type: number
|
||||||
|
is_byok:
|
||||||
|
type: boolean
|
||||||
|
required:
|
||||||
|
- status
|
||||||
|
description: List of provider responses for this generation, including fallback attempts
|
||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
- upstream_id
|
- upstream_id
|
||||||
@@ -10397,6 +10524,7 @@ paths:
|
|||||||
- external_user
|
- external_user
|
||||||
- api_type
|
- api_type
|
||||||
- router
|
- router
|
||||||
|
- provider_responses
|
||||||
description: Generation data
|
description: Generation data
|
||||||
required:
|
required:
|
||||||
- data
|
- data
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ sources:
|
|||||||
- latest
|
- latest
|
||||||
OpenRouter API:
|
OpenRouter API:
|
||||||
sourceNamespace: open-router-chat-completions-api
|
sourceNamespace: open-router-chat-completions-api
|
||||||
sourceRevisionDigest: sha256:5ba48c1ff7f13c2c5d9ab558e9ecd4638b65c12dd9c4e0cff7fb337674e94ceb
|
sourceRevisionDigest: sha256:6e8165360ec62cc8b776111afb2e6d8c17e5dd46f2be6e124138a8296e2c7046
|
||||||
sourceBlobDigest: sha256:082db9694677b85116bda99811c8b957f96d1c493a3c606643479a65dad79730
|
sourceBlobDigest: sha256:373dfa5b56ef18b9cdc55a2ad1a5d8b377deabfcc028ab7f940f525b3a3ca9c9
|
||||||
tags:
|
tags:
|
||||||
- latest
|
- latest
|
||||||
- main
|
- main
|
||||||
@@ -18,10 +18,10 @@ targets:
|
|||||||
open-router:
|
open-router:
|
||||||
source: OpenRouter API
|
source: OpenRouter API
|
||||||
sourceNamespace: open-router-chat-completions-api
|
sourceNamespace: open-router-chat-completions-api
|
||||||
sourceRevisionDigest: sha256:5ba48c1ff7f13c2c5d9ab558e9ecd4638b65c12dd9c4e0cff7fb337674e94ceb
|
sourceRevisionDigest: sha256:6e8165360ec62cc8b776111afb2e6d8c17e5dd46f2be6e124138a8296e2c7046
|
||||||
sourceBlobDigest: sha256:082db9694677b85116bda99811c8b957f96d1c493a3c606643479a65dad79730
|
sourceBlobDigest: sha256:373dfa5b56ef18b9cdc55a2ad1a5d8b377deabfcc028ab7f940f525b3a3ca9c9
|
||||||
codeSamplesNamespace: open-router-python-code-samples
|
codeSamplesNamespace: open-router-python-code-samples
|
||||||
codeSamplesRevisionDigest: sha256:edf48a4b247040d1d03e08ea515577092801ecddf188310752b8fc11ee23a360
|
codeSamplesRevisionDigest: sha256:0441c6e25f98818e2b2398041d3a974e3f26897c151a3fabfccbc2206640751a
|
||||||
workflow:
|
workflow:
|
||||||
workflowVersion: 1.0.0
|
workflowVersion: 1.0.0
|
||||||
speakeasyVersion: 1.666.0
|
speakeasyVersion: 1.666.0
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
| `AI21` | AI21 |
|
| `AI21` | AI21 |
|
||||||
| `AION_LABS` | AionLabs |
|
| `AION_LABS` | AionLabs |
|
||||||
| `ALIBABA` | Alibaba |
|
| `ALIBABA` | Alibaba |
|
||||||
|
| `AMBIENT` | Ambient |
|
||||||
| `AMAZON_BEDROCK` | Amazon Bedrock |
|
| `AMAZON_BEDROCK` | Amazon Bedrock |
|
||||||
| `AMAZON_NOVA` | Amazon Nova |
|
| `AMAZON_NOVA` | Amazon Nova |
|
||||||
| `ANTHROPIC` | Anthropic |
|
| `ANTHROPIC` | Anthropic |
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
| `AI21` | AI21 |
|
| `AI21` | AI21 |
|
||||||
| `AION_LABS` | AionLabs |
|
| `AION_LABS` | AionLabs |
|
||||||
| `ALIBABA` | Alibaba |
|
| `ALIBABA` | Alibaba |
|
||||||
|
| `AMBIENT` | Ambient |
|
||||||
| `AMAZON_BEDROCK` | Amazon Bedrock |
|
| `AMAZON_BEDROCK` | Amazon Bedrock |
|
||||||
| `AMAZON_NOVA` | Amazon Nova |
|
| `AMAZON_NOVA` | Amazon Nova |
|
||||||
| `ANTHROPIC` | Anthropic |
|
| `ANTHROPIC` | Anthropic |
|
||||||
|
|||||||
@@ -5,38 +5,39 @@ Generation data
|
|||||||
|
|
||||||
## Fields
|
## Fields
|
||||||
|
|
||||||
| Field | Type | Required | Description | Example |
|
| Field | Type | Required | Description | Example |
|
||||||
| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- |
|
| --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
||||||
| `id` | *str* | :heavy_check_mark: | Unique identifier for the generation | gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG |
|
| `id` | *str* | :heavy_check_mark: | Unique identifier for the generation | gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG |
|
||||||
| `upstream_id` | *Nullable[str]* | :heavy_check_mark: | Upstream provider's identifier for this generation | chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946 |
|
| `upstream_id` | *Nullable[str]* | :heavy_check_mark: | Upstream provider's identifier for this generation | chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946 |
|
||||||
| `total_cost` | *float* | :heavy_check_mark: | Total cost of the generation in USD | 0.0015 |
|
| `total_cost` | *float* | :heavy_check_mark: | Total cost of the generation in USD | 0.0015 |
|
||||||
| `cache_discount` | *Nullable[float]* | :heavy_check_mark: | Discount applied due to caching | 0.0002 |
|
| `cache_discount` | *Nullable[float]* | :heavy_check_mark: | Discount applied due to caching | 0.0002 |
|
||||||
| `upstream_inference_cost` | *Nullable[float]* | :heavy_check_mark: | Cost charged by the upstream provider | 0.0012 |
|
| `upstream_inference_cost` | *Nullable[float]* | :heavy_check_mark: | Cost charged by the upstream provider | 0.0012 |
|
||||||
| `created_at` | *str* | :heavy_check_mark: | ISO 8601 timestamp of when the generation was created | 2024-07-15T23:33:19.433273+00:00 |
|
| `created_at` | *str* | :heavy_check_mark: | ISO 8601 timestamp of when the generation was created | 2024-07-15T23:33:19.433273+00:00 |
|
||||||
| `model` | *str* | :heavy_check_mark: | Model used for the generation | sao10k/l3-stheno-8b |
|
| `model` | *str* | :heavy_check_mark: | Model used for the generation | sao10k/l3-stheno-8b |
|
||||||
| `app_id` | *Nullable[float]* | :heavy_check_mark: | ID of the app that made the request | 12345 |
|
| `app_id` | *Nullable[float]* | :heavy_check_mark: | ID of the app that made the request | 12345 |
|
||||||
| `streamed` | *Nullable[bool]* | :heavy_check_mark: | Whether the response was streamed | true |
|
| `streamed` | *Nullable[bool]* | :heavy_check_mark: | Whether the response was streamed | true |
|
||||||
| `cancelled` | *Nullable[bool]* | :heavy_check_mark: | Whether the generation was cancelled | false |
|
| `cancelled` | *Nullable[bool]* | :heavy_check_mark: | Whether the generation was cancelled | false |
|
||||||
| `provider_name` | *Nullable[str]* | :heavy_check_mark: | Name of the provider that served the request | Infermatic |
|
| `provider_name` | *Nullable[str]* | :heavy_check_mark: | Name of the provider that served the request | Infermatic |
|
||||||
| `latency` | *Nullable[float]* | :heavy_check_mark: | Total latency in milliseconds | 1250 |
|
| `latency` | *Nullable[float]* | :heavy_check_mark: | Total latency in milliseconds | 1250 |
|
||||||
| `moderation_latency` | *Nullable[float]* | :heavy_check_mark: | Moderation latency in milliseconds | 50 |
|
| `moderation_latency` | *Nullable[float]* | :heavy_check_mark: | Moderation latency in milliseconds | 50 |
|
||||||
| `generation_time` | *Nullable[float]* | :heavy_check_mark: | Time taken for generation in milliseconds | 1200 |
|
| `generation_time` | *Nullable[float]* | :heavy_check_mark: | Time taken for generation in milliseconds | 1200 |
|
||||||
| `finish_reason` | *Nullable[str]* | :heavy_check_mark: | Reason the generation finished | stop |
|
| `finish_reason` | *Nullable[str]* | :heavy_check_mark: | Reason the generation finished | stop |
|
||||||
| `tokens_prompt` | *Nullable[float]* | :heavy_check_mark: | Number of tokens in the prompt | 10 |
|
| `tokens_prompt` | *Nullable[float]* | :heavy_check_mark: | Number of tokens in the prompt | 10 |
|
||||||
| `tokens_completion` | *Nullable[float]* | :heavy_check_mark: | Number of tokens in the completion | 25 |
|
| `tokens_completion` | *Nullable[float]* | :heavy_check_mark: | Number of tokens in the completion | 25 |
|
||||||
| `native_tokens_prompt` | *Nullable[float]* | :heavy_check_mark: | Native prompt tokens as reported by provider | 10 |
|
| `native_tokens_prompt` | *Nullable[float]* | :heavy_check_mark: | Native prompt tokens as reported by provider | 10 |
|
||||||
| `native_tokens_completion` | *Nullable[float]* | :heavy_check_mark: | Native completion tokens as reported by provider | 25 |
|
| `native_tokens_completion` | *Nullable[float]* | :heavy_check_mark: | Native completion tokens as reported by provider | 25 |
|
||||||
| `native_tokens_completion_images` | *Nullable[float]* | :heavy_check_mark: | Native completion image tokens as reported by provider | 0 |
|
| `native_tokens_completion_images` | *Nullable[float]* | :heavy_check_mark: | Native completion image tokens as reported by provider | 0 |
|
||||||
| `native_tokens_reasoning` | *Nullable[float]* | :heavy_check_mark: | Native reasoning tokens as reported by provider | 5 |
|
| `native_tokens_reasoning` | *Nullable[float]* | :heavy_check_mark: | Native reasoning tokens as reported by provider | 5 |
|
||||||
| `native_tokens_cached` | *Nullable[float]* | :heavy_check_mark: | Native cached tokens as reported by provider | 3 |
|
| `native_tokens_cached` | *Nullable[float]* | :heavy_check_mark: | Native cached tokens as reported by provider | 3 |
|
||||||
| `num_media_prompt` | *Nullable[float]* | :heavy_check_mark: | Number of media items in the prompt | 1 |
|
| `num_media_prompt` | *Nullable[float]* | :heavy_check_mark: | Number of media items in the prompt | 1 |
|
||||||
| `num_input_audio_prompt` | *Nullable[float]* | :heavy_check_mark: | Number of audio inputs in the prompt | 0 |
|
| `num_input_audio_prompt` | *Nullable[float]* | :heavy_check_mark: | Number of audio inputs in the prompt | 0 |
|
||||||
| `num_media_completion` | *Nullable[float]* | :heavy_check_mark: | Number of media items in the completion | 0 |
|
| `num_media_completion` | *Nullable[float]* | :heavy_check_mark: | Number of media items in the completion | 0 |
|
||||||
| `num_search_results` | *Nullable[float]* | :heavy_check_mark: | Number of search results included | 5 |
|
| `num_search_results` | *Nullable[float]* | :heavy_check_mark: | Number of search results included | 5 |
|
||||||
| `origin` | *str* | :heavy_check_mark: | Origin URL of the request | https://openrouter.ai/ |
|
| `origin` | *str* | :heavy_check_mark: | Origin URL of the request | https://openrouter.ai/ |
|
||||||
| `usage` | *float* | :heavy_check_mark: | Usage amount in USD | 0.0015 |
|
| `usage` | *float* | :heavy_check_mark: | Usage amount in USD | 0.0015 |
|
||||||
| `is_byok` | *bool* | :heavy_check_mark: | Whether this used bring-your-own-key | false |
|
| `is_byok` | *bool* | :heavy_check_mark: | Whether this used bring-your-own-key | false |
|
||||||
| `native_finish_reason` | *Nullable[str]* | :heavy_check_mark: | Native finish reason as reported by provider | stop |
|
| `native_finish_reason` | *Nullable[str]* | :heavy_check_mark: | Native finish reason as reported by provider | stop |
|
||||||
| `external_user` | *Nullable[str]* | :heavy_check_mark: | External user identifier | user-123 |
|
| `external_user` | *Nullable[str]* | :heavy_check_mark: | External user identifier | user-123 |
|
||||||
| `api_type` | [Nullable[operations.APIType]](../operations/apitype.md) | :heavy_check_mark: | Type of API used for the generation | |
|
| `api_type` | [Nullable[operations.APIType]](../operations/apitype.md) | :heavy_check_mark: | Type of API used for the generation | |
|
||||||
| `router` | *Nullable[str]* | :heavy_check_mark: | Router used for the request (e.g., openrouter/auto) | openrouter/auto |
|
| `router` | *Nullable[str]* | :heavy_check_mark: | Router used for the request (e.g., openrouter/auto) | openrouter/auto |
|
||||||
|
| `provider_responses` | List[[operations.ProviderResponse](../operations/providerresponse.md)] | :heavy_check_mark: | List of provider responses for this generation, including fallback attempts | |
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
# ProviderName
|
||||||
|
|
||||||
|
|
||||||
|
## Values
|
||||||
|
|
||||||
|
| Name | Value |
|
||||||
|
| ------------------- | ------------------- |
|
||||||
|
| `ANY_SCALE` | AnyScale |
|
||||||
|
| `ATOMA` | Atoma |
|
||||||
|
| `CENT_ML` | Cent-ML |
|
||||||
|
| `CROF_AI` | CrofAI |
|
||||||
|
| `ENFER` | Enfer |
|
||||||
|
| `GO_POMELO` | GoPomelo |
|
||||||
|
| `HUGGING_FACE` | HuggingFace |
|
||||||
|
| `HYPERBOLIC_2` | Hyperbolic 2 |
|
||||||
|
| `INO_CLOUD` | InoCloud |
|
||||||
|
| `KLUSTER` | Kluster |
|
||||||
|
| `LAMBDA` | Lambda |
|
||||||
|
| `LEPTON` | Lepton |
|
||||||
|
| `LYNN_2` | Lynn 2 |
|
||||||
|
| `LYNN` | Lynn |
|
||||||
|
| `MANCER` | Mancer |
|
||||||
|
| `META` | Meta |
|
||||||
|
| `MODAL` | Modal |
|
||||||
|
| `NINETEEN` | Nineteen |
|
||||||
|
| `OCTO_AI` | OctoAI |
|
||||||
|
| `RECURSAL` | Recursal |
|
||||||
|
| `REFLECTION` | Reflection |
|
||||||
|
| `REPLICATE` | Replicate |
|
||||||
|
| `SAMBA_NOVA_2` | SambaNova 2 |
|
||||||
|
| `SF_COMPUTE` | SF Compute |
|
||||||
|
| `TARGON` | Targon |
|
||||||
|
| `TOGETHER_2` | Together 2 |
|
||||||
|
| `UBICLOUD` | Ubicloud |
|
||||||
|
| `ONE_DOT_AI` | 01.AI |
|
||||||
|
| `AI21` | AI21 |
|
||||||
|
| `AION_LABS` | AionLabs |
|
||||||
|
| `ALIBABA` | Alibaba |
|
||||||
|
| `AMBIENT` | Ambient |
|
||||||
|
| `AMAZON_BEDROCK` | Amazon Bedrock |
|
||||||
|
| `AMAZON_NOVA` | Amazon Nova |
|
||||||
|
| `ANTHROPIC` | Anthropic |
|
||||||
|
| `ARCEE_AI` | Arcee AI |
|
||||||
|
| `ATLAS_CLOUD` | AtlasCloud |
|
||||||
|
| `AVIAN` | Avian |
|
||||||
|
| `AZURE` | Azure |
|
||||||
|
| `BASE_TEN` | BaseTen |
|
||||||
|
| `BYTE_PLUS` | BytePlus |
|
||||||
|
| `BLACK_FOREST_LABS` | Black Forest Labs |
|
||||||
|
| `CEREBRAS` | Cerebras |
|
||||||
|
| `CHUTES` | Chutes |
|
||||||
|
| `CIRRASCALE` | Cirrascale |
|
||||||
|
| `CLARIFAI` | Clarifai |
|
||||||
|
| `CLOUDFLARE` | Cloudflare |
|
||||||
|
| `COHERE` | Cohere |
|
||||||
|
| `CRUSOE` | Crusoe |
|
||||||
|
| `DEEP_INFRA` | DeepInfra |
|
||||||
|
| `DEEP_SEEK` | DeepSeek |
|
||||||
|
| `FEATHERLESS` | Featherless |
|
||||||
|
| `FIREWORKS` | Fireworks |
|
||||||
|
| `FRIENDLI` | Friendli |
|
||||||
|
| `GMI_CLOUD` | GMICloud |
|
||||||
|
| `GOOGLE` | Google |
|
||||||
|
| `GOOGLE_AI_STUDIO` | Google AI Studio |
|
||||||
|
| `GROQ` | Groq |
|
||||||
|
| `HYPERBOLIC` | Hyperbolic |
|
||||||
|
| `INCEPTION` | Inception |
|
||||||
|
| `INCEPTRON` | Inceptron |
|
||||||
|
| `INFERENCE_NET` | InferenceNet |
|
||||||
|
| `INFERMATIC` | Infermatic |
|
||||||
|
| `INFLECTION` | Inflection |
|
||||||
|
| `LIQUID` | Liquid |
|
||||||
|
| `MARA` | Mara |
|
||||||
|
| `MANCER_2` | Mancer 2 |
|
||||||
|
| `MINIMAX` | Minimax |
|
||||||
|
| `MODEL_RUN` | ModelRun |
|
||||||
|
| `MISTRAL` | Mistral |
|
||||||
|
| `MODULAR` | Modular |
|
||||||
|
| `MOONSHOT_AI` | Moonshot AI |
|
||||||
|
| `MORPH` | Morph |
|
||||||
|
| `N_COMPASS` | NCompass |
|
||||||
|
| `NEBIUS` | Nebius |
|
||||||
|
| `NEXT_BIT` | NextBit |
|
||||||
|
| `NOVITA` | Novita |
|
||||||
|
| `NVIDIA` | Nvidia |
|
||||||
|
| `OPEN_AI` | OpenAI |
|
||||||
|
| `OPEN_INFERENCE` | OpenInference |
|
||||||
|
| `PARASAIL` | Parasail |
|
||||||
|
| `PERPLEXITY` | Perplexity |
|
||||||
|
| `PHALA` | Phala |
|
||||||
|
| `RELACE` | Relace |
|
||||||
|
| `SAMBA_NOVA` | SambaNova |
|
||||||
|
| `SEED` | Seed |
|
||||||
|
| `SILICON_FLOW` | SiliconFlow |
|
||||||
|
| `SOURCEFUL` | Sourceful |
|
||||||
|
| `STEALTH` | Stealth |
|
||||||
|
| `STREAM_LAKE` | StreamLake |
|
||||||
|
| `SWITCHPOINT` | Switchpoint |
|
||||||
|
| `TOGETHER` | Together |
|
||||||
|
| `UPSTAGE` | Upstage |
|
||||||
|
| `VENICE` | Venice |
|
||||||
|
| `WAND_B` | WandB |
|
||||||
|
| `XIAOMI` | Xiaomi |
|
||||||
|
| `X_AI` | xAI |
|
||||||
|
| `Z_AI` | Z.AI |
|
||||||
|
| `FAKE_PROVIDER` | FakeProvider |
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# ProviderResponse
|
||||||
|
|
||||||
|
|
||||||
|
## Fields
|
||||||
|
|
||||||
|
| Field | Type | Required | Description |
|
||||||
|
| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
|
||||||
|
| `id` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||||
|
| `endpoint_id` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||||
|
| `model_permaslug` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||||
|
| `provider_name` | [Optional[operations.ProviderName]](../operations/providername.md) | :heavy_minus_sign: | N/A |
|
||||||
|
| `status` | *Nullable[float]* | :heavy_check_mark: | N/A |
|
||||||
|
| `latency` | *Optional[float]* | :heavy_minus_sign: | N/A |
|
||||||
|
| `is_byok` | *Optional[bool]* | :heavy_minus_sign: | N/A |
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "openrouter"
|
name = "openrouter"
|
||||||
version = "0.3.0"
|
version = "0.3.2"
|
||||||
description = "Official Python Client SDK for OpenRouter."
|
description = "Official Python Client SDK for OpenRouter."
|
||||||
authors = [{ name = "OpenRouter" },]
|
authors = [{ name = "OpenRouter" },]
|
||||||
readme = "README-PYPI.md"
|
readme = "README-PYPI.md"
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
import importlib.metadata
|
import importlib.metadata
|
||||||
|
|
||||||
__title__: str = "openrouter"
|
__title__: str = "openrouter"
|
||||||
__version__: str = "0.3.0"
|
__version__: str = "0.3.2"
|
||||||
__openapi_doc_version__: str = "1.0.0"
|
__openapi_doc_version__: str = "1.0.0"
|
||||||
__gen_version__: str = "2.768.0"
|
__gen_version__: str = "2.768.0"
|
||||||
__user_agent__: str = "speakeasy-sdk/python 0.3.0 2.768.0 1.0.0 openrouter"
|
__user_agent__: str = "speakeasy-sdk/python 0.3.2 2.768.0 1.0.0 openrouter"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if __package__ is not None:
|
if __package__ is not None:
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Schema0Enum = Union[
|
|||||||
"AI21",
|
"AI21",
|
||||||
"AionLabs",
|
"AionLabs",
|
||||||
"Alibaba",
|
"Alibaba",
|
||||||
|
"Ambient",
|
||||||
"Amazon Bedrock",
|
"Amazon Bedrock",
|
||||||
"Amazon Nova",
|
"Amazon Nova",
|
||||||
"Anthropic",
|
"Anthropic",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ ProviderName = Union[
|
|||||||
"AI21",
|
"AI21",
|
||||||
"AionLabs",
|
"AionLabs",
|
||||||
"Alibaba",
|
"Alibaba",
|
||||||
|
"Ambient",
|
||||||
"Amazon Bedrock",
|
"Amazon Bedrock",
|
||||||
"Amazon Nova",
|
"Amazon Nova",
|
||||||
"Anthropic",
|
"Anthropic",
|
||||||
|
|||||||
@@ -160,6 +160,9 @@ if TYPE_CHECKING:
|
|||||||
GetGenerationRequestTypedDict,
|
GetGenerationRequestTypedDict,
|
||||||
GetGenerationResponse,
|
GetGenerationResponse,
|
||||||
GetGenerationResponseTypedDict,
|
GetGenerationResponseTypedDict,
|
||||||
|
ProviderName,
|
||||||
|
ProviderResponse,
|
||||||
|
ProviderResponseTypedDict,
|
||||||
)
|
)
|
||||||
from .getguardrail import (
|
from .getguardrail import (
|
||||||
GetGuardrailData,
|
GetGuardrailData,
|
||||||
@@ -462,6 +465,9 @@ __all__ = [
|
|||||||
"MetadataTypedDict",
|
"MetadataTypedDict",
|
||||||
"Object",
|
"Object",
|
||||||
"ObjectEmbedding",
|
"ObjectEmbedding",
|
||||||
|
"ProviderName",
|
||||||
|
"ProviderResponse",
|
||||||
|
"ProviderResponseTypedDict",
|
||||||
"RateLimit",
|
"RateLimit",
|
||||||
"RateLimitTypedDict",
|
"RateLimitTypedDict",
|
||||||
"SendChatCompletionRequestResponse",
|
"SendChatCompletionRequestResponse",
|
||||||
@@ -619,6 +625,9 @@ _dynamic_imports: dict[str, str] = {
|
|||||||
"GetGenerationRequestTypedDict": ".getgeneration",
|
"GetGenerationRequestTypedDict": ".getgeneration",
|
||||||
"GetGenerationResponse": ".getgeneration",
|
"GetGenerationResponse": ".getgeneration",
|
||||||
"GetGenerationResponseTypedDict": ".getgeneration",
|
"GetGenerationResponseTypedDict": ".getgeneration",
|
||||||
|
"ProviderName": ".getgeneration",
|
||||||
|
"ProviderResponse": ".getgeneration",
|
||||||
|
"ProviderResponseTypedDict": ".getgeneration",
|
||||||
"GetGuardrailData": ".getguardrail",
|
"GetGuardrailData": ".getguardrail",
|
||||||
"GetGuardrailDataTypedDict": ".getguardrail",
|
"GetGuardrailDataTypedDict": ".getguardrail",
|
||||||
"GetGuardrailRequest": ".getguardrail",
|
"GetGuardrailRequest": ".getguardrail",
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedSt
|
|||||||
from openrouter.utils import FieldMetadata, QueryParamMetadata, validate_open_enum
|
from openrouter.utils import FieldMetadata, QueryParamMetadata, validate_open_enum
|
||||||
from pydantic import model_serializer
|
from pydantic import model_serializer
|
||||||
from pydantic.functional_validators import PlainValidator
|
from pydantic.functional_validators import PlainValidator
|
||||||
from typing import Literal, Union
|
from typing import List, Literal, Optional, Union
|
||||||
from typing_extensions import Annotated, TypedDict
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||||
|
|
||||||
|
|
||||||
class GetGenerationRequestTypedDict(TypedDict):
|
class GetGenerationRequestTypedDict(TypedDict):
|
||||||
@@ -29,6 +29,177 @@ APIType = Union[
|
|||||||
r"""Type of API used for the generation"""
|
r"""Type of API used for the generation"""
|
||||||
|
|
||||||
|
|
||||||
|
ProviderName = Union[
|
||||||
|
Literal[
|
||||||
|
"AnyScale",
|
||||||
|
"Atoma",
|
||||||
|
"Cent-ML",
|
||||||
|
"CrofAI",
|
||||||
|
"Enfer",
|
||||||
|
"GoPomelo",
|
||||||
|
"HuggingFace",
|
||||||
|
"Hyperbolic 2",
|
||||||
|
"InoCloud",
|
||||||
|
"Kluster",
|
||||||
|
"Lambda",
|
||||||
|
"Lepton",
|
||||||
|
"Lynn 2",
|
||||||
|
"Lynn",
|
||||||
|
"Mancer",
|
||||||
|
"Meta",
|
||||||
|
"Modal",
|
||||||
|
"Nineteen",
|
||||||
|
"OctoAI",
|
||||||
|
"Recursal",
|
||||||
|
"Reflection",
|
||||||
|
"Replicate",
|
||||||
|
"SambaNova 2",
|
||||||
|
"SF Compute",
|
||||||
|
"Targon",
|
||||||
|
"Together 2",
|
||||||
|
"Ubicloud",
|
||||||
|
"01.AI",
|
||||||
|
"AI21",
|
||||||
|
"AionLabs",
|
||||||
|
"Alibaba",
|
||||||
|
"Ambient",
|
||||||
|
"Amazon Bedrock",
|
||||||
|
"Amazon Nova",
|
||||||
|
"Anthropic",
|
||||||
|
"Arcee AI",
|
||||||
|
"AtlasCloud",
|
||||||
|
"Avian",
|
||||||
|
"Azure",
|
||||||
|
"BaseTen",
|
||||||
|
"BytePlus",
|
||||||
|
"Black Forest Labs",
|
||||||
|
"Cerebras",
|
||||||
|
"Chutes",
|
||||||
|
"Cirrascale",
|
||||||
|
"Clarifai",
|
||||||
|
"Cloudflare",
|
||||||
|
"Cohere",
|
||||||
|
"Crusoe",
|
||||||
|
"DeepInfra",
|
||||||
|
"DeepSeek",
|
||||||
|
"Featherless",
|
||||||
|
"Fireworks",
|
||||||
|
"Friendli",
|
||||||
|
"GMICloud",
|
||||||
|
"Google",
|
||||||
|
"Google AI Studio",
|
||||||
|
"Groq",
|
||||||
|
"Hyperbolic",
|
||||||
|
"Inception",
|
||||||
|
"Inceptron",
|
||||||
|
"InferenceNet",
|
||||||
|
"Infermatic",
|
||||||
|
"Inflection",
|
||||||
|
"Liquid",
|
||||||
|
"Mara",
|
||||||
|
"Mancer 2",
|
||||||
|
"Minimax",
|
||||||
|
"ModelRun",
|
||||||
|
"Mistral",
|
||||||
|
"Modular",
|
||||||
|
"Moonshot AI",
|
||||||
|
"Morph",
|
||||||
|
"NCompass",
|
||||||
|
"Nebius",
|
||||||
|
"NextBit",
|
||||||
|
"Novita",
|
||||||
|
"Nvidia",
|
||||||
|
"OpenAI",
|
||||||
|
"OpenInference",
|
||||||
|
"Parasail",
|
||||||
|
"Perplexity",
|
||||||
|
"Phala",
|
||||||
|
"Relace",
|
||||||
|
"SambaNova",
|
||||||
|
"Seed",
|
||||||
|
"SiliconFlow",
|
||||||
|
"Sourceful",
|
||||||
|
"Stealth",
|
||||||
|
"StreamLake",
|
||||||
|
"Switchpoint",
|
||||||
|
"Together",
|
||||||
|
"Upstage",
|
||||||
|
"Venice",
|
||||||
|
"WandB",
|
||||||
|
"Xiaomi",
|
||||||
|
"xAI",
|
||||||
|
"Z.AI",
|
||||||
|
"FakeProvider",
|
||||||
|
],
|
||||||
|
UnrecognizedStr,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class ProviderResponseTypedDict(TypedDict):
|
||||||
|
status: Nullable[float]
|
||||||
|
id: NotRequired[str]
|
||||||
|
endpoint_id: NotRequired[str]
|
||||||
|
model_permaslug: NotRequired[str]
|
||||||
|
provider_name: NotRequired[ProviderName]
|
||||||
|
latency: NotRequired[float]
|
||||||
|
is_byok: NotRequired[bool]
|
||||||
|
|
||||||
|
|
||||||
|
class ProviderResponse(BaseModel):
|
||||||
|
status: Nullable[float]
|
||||||
|
|
||||||
|
id: Optional[str] = None
|
||||||
|
|
||||||
|
endpoint_id: Optional[str] = None
|
||||||
|
|
||||||
|
model_permaslug: Optional[str] = None
|
||||||
|
|
||||||
|
provider_name: Annotated[
|
||||||
|
Optional[ProviderName], PlainValidator(validate_open_enum(False))
|
||||||
|
] = None
|
||||||
|
|
||||||
|
latency: Optional[float] = None
|
||||||
|
|
||||||
|
is_byok: Optional[bool] = None
|
||||||
|
|
||||||
|
@model_serializer(mode="wrap")
|
||||||
|
def serialize_model(self, handler):
|
||||||
|
optional_fields = [
|
||||||
|
"id",
|
||||||
|
"endpoint_id",
|
||||||
|
"model_permaslug",
|
||||||
|
"provider_name",
|
||||||
|
"latency",
|
||||||
|
"is_byok",
|
||||||
|
]
|
||||||
|
nullable_fields = ["status"]
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
class GetGenerationDataTypedDict(TypedDict):
|
class GetGenerationDataTypedDict(TypedDict):
|
||||||
r"""Generation data"""
|
r"""Generation data"""
|
||||||
|
|
||||||
@@ -98,6 +269,8 @@ class GetGenerationDataTypedDict(TypedDict):
|
|||||||
r"""Type of API used for the generation"""
|
r"""Type of API used for the generation"""
|
||||||
router: Nullable[str]
|
router: Nullable[str]
|
||||||
r"""Router used for the request (e.g., openrouter/auto)"""
|
r"""Router used for the request (e.g., openrouter/auto)"""
|
||||||
|
provider_responses: Nullable[List[ProviderResponseTypedDict]]
|
||||||
|
r"""List of provider responses for this generation, including fallback attempts"""
|
||||||
|
|
||||||
|
|
||||||
class GetGenerationData(BaseModel):
|
class GetGenerationData(BaseModel):
|
||||||
@@ -202,6 +375,9 @@ class GetGenerationData(BaseModel):
|
|||||||
router: Nullable[str]
|
router: Nullable[str]
|
||||||
r"""Router used for the request (e.g., openrouter/auto)"""
|
r"""Router used for the request (e.g., openrouter/auto)"""
|
||||||
|
|
||||||
|
provider_responses: Nullable[List[ProviderResponse]]
|
||||||
|
r"""List of provider responses for this generation, including fallback attempts"""
|
||||||
|
|
||||||
@model_serializer(mode="wrap")
|
@model_serializer(mode="wrap")
|
||||||
def serialize_model(self, handler):
|
def serialize_model(self, handler):
|
||||||
optional_fields = []
|
optional_fields = []
|
||||||
@@ -232,6 +408,7 @@ class GetGenerationData(BaseModel):
|
|||||||
"external_user",
|
"external_user",
|
||||||
"api_type",
|
"api_type",
|
||||||
"router",
|
"router",
|
||||||
|
"provider_responses",
|
||||||
]
|
]
|
||||||
null_default_fields = []
|
null_default_fields = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user