mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-31 12:30:30 +08:00
fix: add overlay to remove nullable from pagination offset params (#121)
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr
|
||||
from openrouter.components import providerresponse as components_providerresponse
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import (
|
||||
FieldMetadata,
|
||||
HeaderMetadata,
|
||||
@@ -63,6 +71,7 @@ class GetGenerationGlobals(BaseModel):
|
||||
|
||||
class GetGenerationRequestTypedDict(TypedDict):
|
||||
id: str
|
||||
r"""The generation ID"""
|
||||
http_referer: NotRequired[str]
|
||||
r"""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.
|
||||
@@ -82,6 +91,7 @@ class GetGenerationRequest(BaseModel):
|
||||
id: Annotated[
|
||||
str, FieldMetadata(query=QueryParamMetadata(style="form", explode=True))
|
||||
]
|
||||
r"""The generation ID"""
|
||||
|
||||
http_referer: Annotated[
|
||||
Optional[str],
|
||||
@@ -116,6 +126,7 @@ APIType = Union[
|
||||
Literal[
|
||||
"completions",
|
||||
"embeddings",
|
||||
"rerank",
|
||||
"video",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
@@ -123,403 +134,241 @@ APIType = Union[
|
||||
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",
|
||||
"AkashML",
|
||||
"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",
|
||||
"Ionstream",
|
||||
"Infermatic",
|
||||
"Io Net",
|
||||
"Inflection",
|
||||
"Liquid",
|
||||
"Mara",
|
||||
"Mancer 2",
|
||||
"Minimax",
|
||||
"ModelRun",
|
||||
"Mistral",
|
||||
"Modular",
|
||||
"Moonshot AI",
|
||||
"Morph",
|
||||
"NCompass",
|
||||
"Nebius",
|
||||
"NextBit",
|
||||
"Novita",
|
||||
"Nvidia",
|
||||
"OpenAI",
|
||||
"OpenInference",
|
||||
"Parasail",
|
||||
"Perplexity",
|
||||
"Phala",
|
||||
"Reka",
|
||||
"Relace",
|
||||
"SambaNova",
|
||||
"Seed",
|
||||
"SiliconFlow",
|
||||
"Sourceful",
|
||||
"StepFun",
|
||||
"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):
|
||||
r"""Generation data"""
|
||||
|
||||
id: str
|
||||
r"""Unique identifier for the generation"""
|
||||
upstream_id: Nullable[str]
|
||||
r"""Upstream provider's identifier for this generation"""
|
||||
total_cost: float
|
||||
r"""Total cost of the generation in USD"""
|
||||
api_type: Nullable[APIType]
|
||||
r"""Type of API used for the generation"""
|
||||
app_id: Nullable[int]
|
||||
r"""ID of the app that made the request"""
|
||||
cache_discount: Nullable[float]
|
||||
r"""Discount applied due to caching"""
|
||||
upstream_inference_cost: Nullable[float]
|
||||
r"""Cost charged by the upstream provider"""
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the generation was created"""
|
||||
model: str
|
||||
r"""Model used for the generation"""
|
||||
app_id: Nullable[float]
|
||||
r"""ID of the app that made the request"""
|
||||
streamed: Nullable[bool]
|
||||
r"""Whether the response was streamed"""
|
||||
cancelled: Nullable[bool]
|
||||
r"""Whether the generation was cancelled"""
|
||||
provider_name: Nullable[str]
|
||||
r"""Name of the provider that served the request"""
|
||||
latency: Nullable[float]
|
||||
r"""Total latency in milliseconds"""
|
||||
moderation_latency: Nullable[float]
|
||||
r"""Moderation latency in milliseconds"""
|
||||
generation_time: Nullable[float]
|
||||
r"""Time taken for generation in milliseconds"""
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the generation was created"""
|
||||
external_user: Nullable[str]
|
||||
r"""External user identifier"""
|
||||
finish_reason: Nullable[str]
|
||||
r"""Reason the generation finished"""
|
||||
tokens_prompt: Nullable[float]
|
||||
r"""Number of tokens in the prompt"""
|
||||
tokens_completion: Nullable[float]
|
||||
r"""Number of tokens in the completion"""
|
||||
native_tokens_prompt: Nullable[float]
|
||||
r"""Native prompt tokens as reported by provider"""
|
||||
native_tokens_completion: Nullable[float]
|
||||
r"""Native completion tokens as reported by provider"""
|
||||
native_tokens_completion_images: Nullable[float]
|
||||
r"""Native completion image tokens as reported by provider"""
|
||||
native_tokens_reasoning: Nullable[float]
|
||||
r"""Native reasoning tokens as reported by provider"""
|
||||
native_tokens_cached: Nullable[float]
|
||||
generation_time: Nullable[float]
|
||||
r"""Time taken for generation in milliseconds"""
|
||||
http_referer: Nullable[str]
|
||||
r"""Referer header from the request"""
|
||||
id: str
|
||||
r"""Unique identifier for the generation"""
|
||||
is_byok: bool
|
||||
r"""Whether this used bring-your-own-key"""
|
||||
latency: Nullable[float]
|
||||
r"""Total latency in milliseconds"""
|
||||
model: str
|
||||
r"""Model used for the generation"""
|
||||
moderation_latency: Nullable[float]
|
||||
r"""Moderation latency in milliseconds"""
|
||||
native_finish_reason: Nullable[str]
|
||||
r"""Native finish reason as reported by provider"""
|
||||
native_tokens_cached: Nullable[int]
|
||||
r"""Native cached tokens as reported by provider"""
|
||||
num_media_prompt: Nullable[float]
|
||||
r"""Number of media items in the prompt"""
|
||||
num_input_audio_prompt: Nullable[float]
|
||||
native_tokens_completion: Nullable[int]
|
||||
r"""Native completion tokens as reported by provider"""
|
||||
native_tokens_completion_images: Nullable[int]
|
||||
r"""Native completion image tokens as reported by provider"""
|
||||
native_tokens_prompt: Nullable[int]
|
||||
r"""Native prompt tokens as reported by provider"""
|
||||
native_tokens_reasoning: Nullable[int]
|
||||
r"""Native reasoning tokens as reported by provider"""
|
||||
num_input_audio_prompt: Nullable[int]
|
||||
r"""Number of audio inputs in the prompt"""
|
||||
num_media_completion: Nullable[float]
|
||||
num_media_completion: Nullable[int]
|
||||
r"""Number of media items in the completion"""
|
||||
num_search_results: Nullable[float]
|
||||
num_media_prompt: Nullable[int]
|
||||
r"""Number of media items in the prompt"""
|
||||
num_search_results: Nullable[int]
|
||||
r"""Number of search results included"""
|
||||
origin: str
|
||||
r"""Origin URL of the request"""
|
||||
usage: float
|
||||
r"""Usage amount in USD"""
|
||||
is_byok: bool
|
||||
r"""Whether this used bring-your-own-key"""
|
||||
native_finish_reason: Nullable[str]
|
||||
r"""Native finish reason as reported by provider"""
|
||||
external_user: Nullable[str]
|
||||
r"""External user identifier"""
|
||||
api_type: Nullable[APIType]
|
||||
r"""Type of API used for the generation"""
|
||||
provider_name: Nullable[str]
|
||||
r"""Name of the provider that served the request"""
|
||||
provider_responses: Nullable[
|
||||
List[components_providerresponse.ProviderResponseTypedDict]
|
||||
]
|
||||
r"""List of provider responses for this generation, including fallback attempts"""
|
||||
router: Nullable[str]
|
||||
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"""
|
||||
streamed: Nullable[bool]
|
||||
r"""Whether the response was streamed"""
|
||||
tokens_completion: Nullable[int]
|
||||
r"""Number of tokens in the completion"""
|
||||
tokens_prompt: Nullable[int]
|
||||
r"""Number of tokens in the prompt"""
|
||||
total_cost: float
|
||||
r"""Total cost of the generation in USD"""
|
||||
upstream_id: Nullable[str]
|
||||
r"""Upstream provider's identifier for this generation"""
|
||||
upstream_inference_cost: Nullable[float]
|
||||
r"""Cost charged by the upstream provider"""
|
||||
usage: float
|
||||
r"""Usage amount in USD"""
|
||||
user_agent: Nullable[str]
|
||||
r"""User-Agent header from the request"""
|
||||
http_referer: Nullable[str]
|
||||
r"""Referer header from the request"""
|
||||
request_id: NotRequired[Nullable[str]]
|
||||
r"""Unique identifier grouping all generations from a single API request"""
|
||||
session_id: NotRequired[Nullable[str]]
|
||||
r"""Session identifier grouping multiple generations in the same session"""
|
||||
|
||||
|
||||
class GetGenerationData(BaseModel):
|
||||
r"""Generation data"""
|
||||
|
||||
id: str
|
||||
r"""Unique identifier for the generation"""
|
||||
api_type: Annotated[Nullable[APIType], PlainValidator(validate_open_enum(False))]
|
||||
r"""Type of API used for the generation"""
|
||||
|
||||
upstream_id: Nullable[str]
|
||||
r"""Upstream provider's identifier for this generation"""
|
||||
|
||||
total_cost: float
|
||||
r"""Total cost of the generation in USD"""
|
||||
app_id: Nullable[int]
|
||||
r"""ID of the app that made the request"""
|
||||
|
||||
cache_discount: Nullable[float]
|
||||
r"""Discount applied due to caching"""
|
||||
|
||||
upstream_inference_cost: Nullable[float]
|
||||
r"""Cost charged by the upstream provider"""
|
||||
cancelled: Nullable[bool]
|
||||
r"""Whether the generation was cancelled"""
|
||||
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the generation was created"""
|
||||
|
||||
model: str
|
||||
r"""Model used for the generation"""
|
||||
|
||||
app_id: Nullable[float]
|
||||
r"""ID of the app that made the request"""
|
||||
|
||||
streamed: Nullable[bool]
|
||||
r"""Whether the response was streamed"""
|
||||
|
||||
cancelled: Nullable[bool]
|
||||
r"""Whether the generation was cancelled"""
|
||||
|
||||
provider_name: Nullable[str]
|
||||
r"""Name of the provider that served the request"""
|
||||
|
||||
latency: Nullable[float]
|
||||
r"""Total latency in milliseconds"""
|
||||
|
||||
moderation_latency: Nullable[float]
|
||||
r"""Moderation latency in milliseconds"""
|
||||
|
||||
generation_time: Nullable[float]
|
||||
r"""Time taken for generation in milliseconds"""
|
||||
external_user: Nullable[str]
|
||||
r"""External user identifier"""
|
||||
|
||||
finish_reason: Nullable[str]
|
||||
r"""Reason the generation finished"""
|
||||
|
||||
tokens_prompt: Nullable[float]
|
||||
r"""Number of tokens in the prompt"""
|
||||
generation_time: Nullable[float]
|
||||
r"""Time taken for generation in milliseconds"""
|
||||
|
||||
tokens_completion: Nullable[float]
|
||||
r"""Number of tokens in the completion"""
|
||||
http_referer: Nullable[str]
|
||||
r"""Referer header from the request"""
|
||||
|
||||
native_tokens_prompt: Nullable[float]
|
||||
r"""Native prompt tokens as reported by provider"""
|
||||
id: str
|
||||
r"""Unique identifier for the generation"""
|
||||
|
||||
native_tokens_completion: Nullable[float]
|
||||
r"""Native completion tokens as reported by provider"""
|
||||
is_byok: bool
|
||||
r"""Whether this used bring-your-own-key"""
|
||||
|
||||
native_tokens_completion_images: Nullable[float]
|
||||
r"""Native completion image tokens as reported by provider"""
|
||||
latency: Nullable[float]
|
||||
r"""Total latency in milliseconds"""
|
||||
|
||||
native_tokens_reasoning: Nullable[float]
|
||||
r"""Native reasoning tokens as reported by provider"""
|
||||
model: str
|
||||
r"""Model used for the generation"""
|
||||
|
||||
native_tokens_cached: Nullable[float]
|
||||
moderation_latency: Nullable[float]
|
||||
r"""Moderation latency in milliseconds"""
|
||||
|
||||
native_finish_reason: Nullable[str]
|
||||
r"""Native finish reason as reported by provider"""
|
||||
|
||||
native_tokens_cached: Nullable[int]
|
||||
r"""Native cached tokens as reported by provider"""
|
||||
|
||||
num_media_prompt: Nullable[float]
|
||||
r"""Number of media items in the prompt"""
|
||||
native_tokens_completion: Nullable[int]
|
||||
r"""Native completion tokens as reported by provider"""
|
||||
|
||||
num_input_audio_prompt: Nullable[float]
|
||||
native_tokens_completion_images: Nullable[int]
|
||||
r"""Native completion image tokens as reported by provider"""
|
||||
|
||||
native_tokens_prompt: Nullable[int]
|
||||
r"""Native prompt tokens as reported by provider"""
|
||||
|
||||
native_tokens_reasoning: Nullable[int]
|
||||
r"""Native reasoning tokens as reported by provider"""
|
||||
|
||||
num_input_audio_prompt: Nullable[int]
|
||||
r"""Number of audio inputs in the prompt"""
|
||||
|
||||
num_media_completion: Nullable[float]
|
||||
num_media_completion: Nullable[int]
|
||||
r"""Number of media items in the completion"""
|
||||
|
||||
num_search_results: Nullable[float]
|
||||
num_media_prompt: Nullable[int]
|
||||
r"""Number of media items in the prompt"""
|
||||
|
||||
num_search_results: Nullable[int]
|
||||
r"""Number of search results included"""
|
||||
|
||||
origin: str
|
||||
r"""Origin URL of the request"""
|
||||
|
||||
usage: float
|
||||
r"""Usage amount in USD"""
|
||||
provider_name: Nullable[str]
|
||||
r"""Name of the provider that served the request"""
|
||||
|
||||
is_byok: bool
|
||||
r"""Whether this used bring-your-own-key"""
|
||||
|
||||
native_finish_reason: Nullable[str]
|
||||
r"""Native finish reason as reported by provider"""
|
||||
|
||||
external_user: Nullable[str]
|
||||
r"""External user identifier"""
|
||||
|
||||
api_type: Annotated[Nullable[APIType], PlainValidator(validate_open_enum(False))]
|
||||
r"""Type of API used for the generation"""
|
||||
provider_responses: Nullable[List[components_providerresponse.ProviderResponse]]
|
||||
r"""List of provider responses for this generation, including fallback attempts"""
|
||||
|
||||
router: Nullable[str]
|
||||
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"""
|
||||
streamed: Nullable[bool]
|
||||
r"""Whether the response was streamed"""
|
||||
|
||||
tokens_completion: Nullable[int]
|
||||
r"""Number of tokens in the completion"""
|
||||
|
||||
tokens_prompt: Nullable[int]
|
||||
r"""Number of tokens in the prompt"""
|
||||
|
||||
total_cost: float
|
||||
r"""Total cost of the generation in USD"""
|
||||
|
||||
upstream_id: Nullable[str]
|
||||
r"""Upstream provider's identifier for this generation"""
|
||||
|
||||
upstream_inference_cost: Nullable[float]
|
||||
r"""Cost charged by the upstream provider"""
|
||||
|
||||
usage: float
|
||||
r"""Usage amount in USD"""
|
||||
|
||||
user_agent: Nullable[str]
|
||||
r"""User-Agent header from the request"""
|
||||
|
||||
http_referer: Nullable[str]
|
||||
r"""Referer header from the request"""
|
||||
request_id: OptionalNullable[str] = UNSET
|
||||
r"""Unique identifier grouping all generations from a single API request"""
|
||||
|
||||
session_id: OptionalNullable[str] = UNSET
|
||||
r"""Session identifier grouping multiple generations in the same session"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
optional_fields = ["request_id", "session_id"]
|
||||
nullable_fields = [
|
||||
"upstream_id",
|
||||
"cache_discount",
|
||||
"upstream_inference_cost",
|
||||
"api_type",
|
||||
"app_id",
|
||||
"streamed",
|
||||
"cache_discount",
|
||||
"cancelled",
|
||||
"provider_name",
|
||||
"external_user",
|
||||
"finish_reason",
|
||||
"generation_time",
|
||||
"http_referer",
|
||||
"latency",
|
||||
"moderation_latency",
|
||||
"generation_time",
|
||||
"finish_reason",
|
||||
"tokens_prompt",
|
||||
"tokens_completion",
|
||||
"native_tokens_prompt",
|
||||
"native_finish_reason",
|
||||
"native_tokens_cached",
|
||||
"native_tokens_completion",
|
||||
"native_tokens_completion_images",
|
||||
"native_tokens_prompt",
|
||||
"native_tokens_reasoning",
|
||||
"native_tokens_cached",
|
||||
"num_media_prompt",
|
||||
"num_input_audio_prompt",
|
||||
"num_media_completion",
|
||||
"num_media_prompt",
|
||||
"num_search_results",
|
||||
"native_finish_reason",
|
||||
"external_user",
|
||||
"api_type",
|
||||
"router",
|
||||
"provider_name",
|
||||
"provider_responses",
|
||||
"request_id",
|
||||
"router",
|
||||
"session_id",
|
||||
"streamed",
|
||||
"tokens_completion",
|
||||
"tokens_prompt",
|
||||
"upstream_id",
|
||||
"upstream_inference_cost",
|
||||
"user_agent",
|
||||
"http_referer",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user