mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-08-02 12:50:48 +08:00
## Python SDK Changes:
* `open_router.beta.responses.send()`: * `request` **Changed** **Breaking** ⚠️ * `response` **Changed** **Breaking** ⚠️ * `open_router.presets.create_presets_responses()`: `request` **Changed** **Breaking** ⚠️ * `open_router.presets.create_presets_chat_completions()`: `request` **Changed** **Breaking** ⚠️ * `open_router.chat.send()`: `request` **Changed** **Breaking** ⚠️ * `open_router.workspaces.set_budget()`: **Added** * `open_router.o_auth.create_auth_code()`: * `request.workspace_id` **Added** * `error.status[403]` **Added** * `open_router.files.download()`: **Added** * `open_router.models.get()`: **Added** * `open_router.workspaces.list_budgets()`: **Added** * `open_router.workspaces.delete_budget()`: **Added** * `open_router.datasets.get_benchmarks_artificial_analysis()`: **Added** * `open_router.beta.analytics.query_analytics()`: `response.data.warnings` **Added** * `open_router.files.delete()`: **Added** * `open_router.files.retrieve()`: **Added** * `open_router.files.upload()`: **Added** * `open_router.embeddings.list_models()`: `response.data.[].benchmarks` **Added** * `open_router.models.list()`: * `request` **Changed** * `response.data.[].benchmarks` **Added** * `open_router.models.list_for_user()`: `response.data.[].benchmarks` **Added** * `open_router.files.list()`: **Added** * `open_router.presets.create_presets_messages()`: `request` **Changed** * `open_router.datasets.get_benchmarks_design_arena()`: **Added**
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import (
|
||||
FieldMetadata,
|
||||
HeaderMetadata,
|
||||
@@ -9,6 +16,7 @@ from openrouter.utils import (
|
||||
validate_open_enum,
|
||||
)
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
@@ -96,6 +104,24 @@ GetModelsSort = Union[
|
||||
r"""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."""
|
||||
|
||||
|
||||
Distillable = Union[
|
||||
Literal[
|
||||
"true",
|
||||
"false",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Filter by distillation capability. \"true\" returns only distillable models, \"false\" excludes them."""
|
||||
|
||||
|
||||
Zdr = Literal["true",]
|
||||
r"""When set to \"true\", return only models with zero data retention endpoints."""
|
||||
|
||||
|
||||
Region = Literal["eu",]
|
||||
r"""Filter to models with endpoints in the given data region. Currently only \"eu\" is supported."""
|
||||
|
||||
|
||||
class GetModelsRequestTypedDict(TypedDict):
|
||||
http_referer: NotRequired[str]
|
||||
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
@@ -118,6 +144,28 @@ class GetModelsRequestTypedDict(TypedDict):
|
||||
r"""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\"."""
|
||||
sort: NotRequired[GetModelsSort]
|
||||
r"""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."""
|
||||
q: NotRequired[str]
|
||||
r"""Free-text search by model name or slug."""
|
||||
input_modalities: NotRequired[str]
|
||||
r"""Filter models by input modality. Comma-separated list of: text, image, audio, file."""
|
||||
context: NotRequired[int]
|
||||
r"""Minimum context length (tokens). Models with smaller context are excluded."""
|
||||
min_price: NotRequired[Nullable[float]]
|
||||
r"""Minimum prompt price in $/M tokens."""
|
||||
max_price: NotRequired[Nullable[float]]
|
||||
r"""Maximum prompt price in $/M tokens."""
|
||||
arch: NotRequired[str]
|
||||
r"""Filter models by architecture/model family (e.g. GPT, Claude, Gemini, Llama)."""
|
||||
model_authors: NotRequired[str]
|
||||
r"""Filter models by the organization that created the model. Comma-separated list of author slugs."""
|
||||
providers: NotRequired[str]
|
||||
r"""Filter models by hosting provider. Comma-separated list of provider names."""
|
||||
distillable: NotRequired[Distillable]
|
||||
r"""Filter by distillation capability. \"true\" returns only distillable models, \"false\" excludes them."""
|
||||
zdr: NotRequired[Zdr]
|
||||
r"""When set to \"true\", return only models with zero data retention endpoints."""
|
||||
region: NotRequired[Region]
|
||||
r"""Filter to models with endpoints in the given data region. Currently only \"eu\" is supported."""
|
||||
|
||||
|
||||
class GetModelsRequest(BaseModel):
|
||||
@@ -174,3 +222,118 @@ class GetModelsRequest(BaseModel):
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""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."""
|
||||
|
||||
q: Annotated[
|
||||
Optional[str],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Free-text search by model name or slug."""
|
||||
|
||||
input_modalities: Annotated[
|
||||
Optional[str],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Filter models by input modality. Comma-separated list of: text, image, audio, file."""
|
||||
|
||||
context: Annotated[
|
||||
Optional[int],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Minimum context length (tokens). Models with smaller context are excluded."""
|
||||
|
||||
min_price: Annotated[
|
||||
OptionalNullable[float],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = UNSET
|
||||
r"""Minimum prompt price in $/M tokens."""
|
||||
|
||||
max_price: Annotated[
|
||||
OptionalNullable[float],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = UNSET
|
||||
r"""Maximum prompt price in $/M tokens."""
|
||||
|
||||
arch: Annotated[
|
||||
Optional[str],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Filter models by architecture/model family (e.g. GPT, Claude, Gemini, Llama)."""
|
||||
|
||||
model_authors: Annotated[
|
||||
Optional[str],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Filter models by the organization that created the model. Comma-separated list of author slugs."""
|
||||
|
||||
providers: Annotated[
|
||||
Optional[str],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Filter models by hosting provider. Comma-separated list of provider names."""
|
||||
|
||||
distillable: Annotated[
|
||||
Annotated[Optional[Distillable], PlainValidator(validate_open_enum(False))],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Filter by distillation capability. \"true\" returns only distillable models, \"false\" excludes them."""
|
||||
|
||||
zdr: Annotated[
|
||||
Optional[Zdr],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""When set to \"true\", return only models with zero data retention endpoints."""
|
||||
|
||||
region: Annotated[
|
||||
Optional[Region],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Filter to models with endpoints in the given data region. Currently only \"eu\" is supported."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"HTTP-Referer",
|
||||
"X-OpenRouter-Title",
|
||||
"X-OpenRouter-Categories",
|
||||
"category",
|
||||
"supported_parameters",
|
||||
"output_modalities",
|
||||
"sort",
|
||||
"q",
|
||||
"input_modalities",
|
||||
"context",
|
||||
"min_price",
|
||||
"max_price",
|
||||
"arch",
|
||||
"model_authors",
|
||||
"providers",
|
||||
"distillable",
|
||||
"zdr",
|
||||
"region",
|
||||
]
|
||||
nullable_fields = ["min_price", "max_price"]
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user