Commits included in this export:

- 6ddaaa6989d725bbe966e45f7aed0c1bd72f9153
  - 4779741b6ba710b1299612b82e8544516bd9dd6a
  - 22083fcc8f58884d8212d6f3314b231c4ddd21cd
  - a925a620f97196d509e073a163caac053bd82316
  - 5c05d8829784601ffd151acef1a6978c266f913d
  - 6f4fff535fbf4274255c255ae23620b8e00e614f
  - ef358e96cb01e469b77d44683603a602b0813116
  - e6299b4ebfe5c2eed6c598771f0fd99f84555401
  - 24d3f0ee1c2aa19a62f7902836034080b9246813
  - 68922847c2969b773887310eb7aa9a814e199c5a
  - 729ee2338c39df22461526153e7f4ba868fd498e
  - e1074ff86fccf5e48406b7595298873106d3cc5a
  - 123bbdaf841d299162a82ee2573adfbb70a45b8f
  - ac457b8a8dad98fdf5ddcae8dd4711361cea3084
  - ea825199f4c59dd68fec01cf8d18a582963c9f25
  - 4d48e4f6bb936e785787314a965298da6b78fea0
  - 718729a573ee98893a4408d5a52ab4686661fe54
  - b867adcde6b64f3f2a11c4626254b39098e4b0b4
  - 21912c097b4066d109766c6b4492826595cd57c5
  - bc1ed85adc976a4634ca8a41b82e4fc2c39a864f
  - d145c89c941937a312ed1357590d2bfda9a3603d
  - 12f05b5dee397ead47cfcd545a7a2e3c7ff57524
  - dd28f75a19a015809797c7abf3f8758f7c37262e
  - c96e569781e07ab44172d9c69940ec17bafd81f4
  - c9d5a90e3c2b5077a2bdd49773f1a46d1a5a79c7
  - 58b08f87116ceab9076de2fdc0a4c74c919b44c4

GitOrigin-RevId: 6ddaaa6989d725bbe966e45f7aed0c1bd72f9153
This commit is contained in:
OpenRouter Team
2026-02-05 23:15:21 +00:00
parent 0c791b04d1
commit 1cad51abb6
247 changed files with 8079 additions and 4566 deletions
+55 -341
View File
@@ -1,7 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from ._schema0 import Schema0, Schema0TypedDict
from ._schema10 import Schema10, Schema10TypedDict
from ._schema17 import Schema17, Schema17TypedDict
from ._schema5 import Schema5, Schema5TypedDict
from .chatstreamoptions import ChatStreamOptions, ChatStreamOptionsTypedDict
from .message import Message, MessageTypedDict
from .providersortunion import ProviderSortUnion, ProviderSortUnionTypedDict
@@ -31,7 +33,7 @@ from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
ChatGenerationParamsDataCollection = Union[
Schema3 = Union[
Literal[
"deny",
"allow",
@@ -40,7 +42,7 @@ ChatGenerationParamsDataCollection = Union[
]
Quantizations = Union[
Schema8 = Union[
Literal[
"int4",
"int8",
@@ -56,38 +58,14 @@ Quantizations = Union[
]
class ChatGenerationParamsMaxPriceTypedDict(TypedDict):
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
prompt: NotRequired[Any]
completion: NotRequired[Any]
image: NotRequired[Any]
audio: NotRequired[Any]
request: NotRequired[Any]
class ChatGenerationParamsMaxPrice(BaseModel):
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
prompt: Optional[Any] = None
completion: Optional[Any] = None
image: Optional[Any] = None
audio: Optional[Any] = None
request: Optional[Any] = None
class ChatGenerationParamsPreferredMinThroughputTypedDict(TypedDict):
class Schema15TypedDict(TypedDict):
p50: NotRequired[Nullable[float]]
p75: NotRequired[Nullable[float]]
p90: NotRequired[Nullable[float]]
p99: NotRequired[Nullable[float]]
class ChatGenerationParamsPreferredMinThroughput(BaseModel):
class Schema15(BaseModel):
p50: OptionalNullable[float] = UNSET
p75: OptionalNullable[float] = UNSET
@@ -127,170 +105,60 @@ class ChatGenerationParamsPreferredMinThroughput(BaseModel):
return m
ChatGenerationParamsPreferredMinThroughputUnionTypedDict = TypeAliasType(
"ChatGenerationParamsPreferredMinThroughputUnionTypedDict",
Union[ChatGenerationParamsPreferredMinThroughputTypedDict, float],
Schema15UnionTypedDict = TypeAliasType(
"Schema15UnionTypedDict", Union[Schema15TypedDict, float]
)
ChatGenerationParamsPreferredMinThroughputUnion = TypeAliasType(
"ChatGenerationParamsPreferredMinThroughputUnion",
Union[ChatGenerationParamsPreferredMinThroughput, float],
)
Schema15Union = TypeAliasType("Schema15Union", Union[Schema15, float])
class ChatGenerationParamsPreferredMaxLatencyTypedDict(TypedDict):
p50: NotRequired[Nullable[float]]
p75: NotRequired[Nullable[float]]
p90: NotRequired[Nullable[float]]
p99: NotRequired[Nullable[float]]
class ChatGenerationParamsPreferredMaxLatency(BaseModel):
p50: OptionalNullable[float] = UNSET
p75: OptionalNullable[float] = UNSET
p90: OptionalNullable[float] = UNSET
p99: OptionalNullable[float] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["p50", "p75", "p90", "p99"]
nullable_fields = ["p50", "p75", "p90", "p99"]
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
ChatGenerationParamsPreferredMaxLatencyUnionTypedDict = TypeAliasType(
"ChatGenerationParamsPreferredMaxLatencyUnionTypedDict",
Union[ChatGenerationParamsPreferredMaxLatencyTypedDict, float],
)
ChatGenerationParamsPreferredMaxLatencyUnion = TypeAliasType(
"ChatGenerationParamsPreferredMaxLatencyUnion",
Union[ChatGenerationParamsPreferredMaxLatency, float],
)
class ChatGenerationParamsProviderTypedDict(TypedDict):
class Schema0TypedDict(TypedDict):
allow_fallbacks: NotRequired[Nullable[bool]]
r"""Whether to allow backup providers to serve requests
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
"""
require_parameters: NotRequired[Nullable[bool]]
r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest."""
data_collection: NotRequired[Nullable[ChatGenerationParamsDataCollection]]
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
"""
data_collection: NotRequired[Nullable[Schema3]]
zdr: NotRequired[Nullable[bool]]
enforce_distillable_text: NotRequired[Nullable[bool]]
order: NotRequired[Nullable[List[Schema0TypedDict]]]
r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message."""
only: NotRequired[Nullable[List[Schema0TypedDict]]]
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
ignore: NotRequired[Nullable[List[Schema0TypedDict]]]
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
quantizations: NotRequired[Nullable[List[Quantizations]]]
r"""A list of quantization levels to filter the provider by."""
order: NotRequired[Nullable[List[Schema5TypedDict]]]
only: NotRequired[Nullable[List[Schema5TypedDict]]]
ignore: NotRequired[Nullable[List[Schema5TypedDict]]]
quantizations: NotRequired[Nullable[List[Schema8]]]
sort: NotRequired[Nullable[ProviderSortUnionTypedDict]]
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
max_price: NotRequired[ChatGenerationParamsMaxPriceTypedDict]
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
preferred_min_throughput: NotRequired[
Nullable[ChatGenerationParamsPreferredMinThroughputUnionTypedDict]
]
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
preferred_max_latency: NotRequired[
Nullable[ChatGenerationParamsPreferredMaxLatencyUnionTypedDict]
]
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
max_price: NotRequired[Schema10TypedDict]
preferred_min_throughput: NotRequired[Nullable[Schema15UnionTypedDict]]
preferred_max_latency: NotRequired[Nullable[Schema15UnionTypedDict]]
class ChatGenerationParamsProvider(BaseModel):
class Schema0(BaseModel):
allow_fallbacks: OptionalNullable[bool] = UNSET
r"""Whether to allow backup providers to serve requests
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
"""
require_parameters: OptionalNullable[bool] = UNSET
r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest."""
data_collection: Annotated[
OptionalNullable[ChatGenerationParamsDataCollection],
PlainValidator(validate_open_enum(False)),
OptionalNullable[Schema3], PlainValidator(validate_open_enum(False))
] = UNSET
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
"""
zdr: OptionalNullable[bool] = UNSET
enforce_distillable_text: OptionalNullable[bool] = UNSET
order: OptionalNullable[List[Schema0]] = UNSET
r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message."""
order: OptionalNullable[List[Schema5]] = UNSET
only: OptionalNullable[List[Schema0]] = UNSET
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
only: OptionalNullable[List[Schema5]] = UNSET
ignore: OptionalNullable[List[Schema0]] = UNSET
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
ignore: OptionalNullable[List[Schema5]] = UNSET
quantizations: OptionalNullable[
List[Annotated[Quantizations, PlainValidator(validate_open_enum(False))]]
List[Annotated[Schema8, PlainValidator(validate_open_enum(False))]]
] = UNSET
r"""A list of quantization levels to filter the provider by."""
sort: OptionalNullable[ProviderSortUnion] = UNSET
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
max_price: Optional[ChatGenerationParamsMaxPrice] = None
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
max_price: Optional[Schema10] = None
preferred_min_throughput: OptionalNullable[
ChatGenerationParamsPreferredMinThroughputUnion
] = UNSET
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
preferred_min_throughput: OptionalNullable[Schema15Union] = UNSET
preferred_max_latency: OptionalNullable[
ChatGenerationParamsPreferredMaxLatencyUnion
] = UNSET
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
preferred_max_latency: OptionalNullable[Schema15Union] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
@@ -350,150 +218,6 @@ class ChatGenerationParamsProvider(BaseModel):
return m
class ChatGenerationParamsPluginResponseHealingTypedDict(TypedDict):
id: Literal["response-healing"]
enabled: NotRequired[bool]
class ChatGenerationParamsPluginResponseHealing(BaseModel):
ID: Annotated[
Annotated[
Literal["response-healing"],
AfterValidator(validate_const("response-healing")),
],
pydantic.Field(alias="id"),
] = "response-healing"
enabled: Optional[bool] = None
PdfEngine = Union[
Literal[
"mistral-ocr",
"pdf-text",
"native",
],
UnrecognizedStr,
]
class PdfTypedDict(TypedDict):
engine: NotRequired[PdfEngine]
class Pdf(BaseModel):
engine: Annotated[
Optional[PdfEngine], PlainValidator(validate_open_enum(False))
] = None
class ChatGenerationParamsPluginFileParserTypedDict(TypedDict):
id: Literal["file-parser"]
enabled: NotRequired[bool]
pdf: NotRequired[PdfTypedDict]
class ChatGenerationParamsPluginFileParser(BaseModel):
ID: Annotated[
Annotated[
Literal["file-parser"], AfterValidator(validate_const("file-parser"))
],
pydantic.Field(alias="id"),
] = "file-parser"
enabled: Optional[bool] = None
pdf: Optional[Pdf] = None
Engine = Union[
Literal[
"native",
"exa",
],
UnrecognizedStr,
]
class ChatGenerationParamsPluginWebTypedDict(TypedDict):
id: Literal["web"]
enabled: NotRequired[bool]
max_results: NotRequired[float]
search_prompt: NotRequired[str]
engine: NotRequired[Engine]
class ChatGenerationParamsPluginWeb(BaseModel):
ID: Annotated[
Annotated[Literal["web"], AfterValidator(validate_const("web"))],
pydantic.Field(alias="id"),
] = "web"
enabled: Optional[bool] = None
max_results: Optional[float] = None
search_prompt: Optional[str] = None
engine: Annotated[Optional[Engine], PlainValidator(validate_open_enum(False))] = (
None
)
class ChatGenerationParamsPluginModerationTypedDict(TypedDict):
id: Literal["moderation"]
class ChatGenerationParamsPluginModeration(BaseModel):
ID: Annotated[
Annotated[Literal["moderation"], AfterValidator(validate_const("moderation"))],
pydantic.Field(alias="id"),
] = "moderation"
class ChatGenerationParamsPluginAutoRouterTypedDict(TypedDict):
id: Literal["auto-router"]
enabled: NotRequired[bool]
allowed_models: NotRequired[List[str]]
class ChatGenerationParamsPluginAutoRouter(BaseModel):
ID: Annotated[
Annotated[
Literal["auto-router"], AfterValidator(validate_const("auto-router"))
],
pydantic.Field(alias="id"),
] = "auto-router"
enabled: Optional[bool] = None
allowed_models: Optional[List[str]] = None
ChatGenerationParamsPluginUnionTypedDict = TypeAliasType(
"ChatGenerationParamsPluginUnionTypedDict",
Union[
ChatGenerationParamsPluginModerationTypedDict,
ChatGenerationParamsPluginResponseHealingTypedDict,
ChatGenerationParamsPluginAutoRouterTypedDict,
ChatGenerationParamsPluginFileParserTypedDict,
ChatGenerationParamsPluginWebTypedDict,
],
)
ChatGenerationParamsPluginUnion = Annotated[
Union[
Annotated[ChatGenerationParamsPluginAutoRouter, Tag("auto-router")],
Annotated[ChatGenerationParamsPluginModeration, Tag("moderation")],
Annotated[ChatGenerationParamsPluginWeb, Tag("web")],
Annotated[ChatGenerationParamsPluginFileParser, Tag("file-parser")],
Annotated[ChatGenerationParamsPluginResponseHealing, Tag("response-healing")],
],
Discriminator(lambda m: get_discriminator(m, "id", "id")),
]
Route = Union[
Literal[
"fallback",
@@ -562,22 +286,22 @@ class Reasoning(BaseModel):
return m
class ChatGenerationParamsResponseFormatPythonTypedDict(TypedDict):
class ResponseFormatPythonTypedDict(TypedDict):
type: Literal["python"]
class ChatGenerationParamsResponseFormatPython(BaseModel):
class ResponseFormatPython(BaseModel):
TYPE: Annotated[
Annotated[Literal["python"], AfterValidator(validate_const("python"))],
pydantic.Field(alias="type"),
] = "python"
class ChatGenerationParamsResponseFormatJSONObjectTypedDict(TypedDict):
class ResponseFormatJSONObjectTypedDict(TypedDict):
type: Literal["json_object"]
class ChatGenerationParamsResponseFormatJSONObject(BaseModel):
class ResponseFormatJSONObject(BaseModel):
TYPE: Annotated[
Annotated[
Literal["json_object"], AfterValidator(validate_const("json_object"))
@@ -586,49 +310,45 @@ class ChatGenerationParamsResponseFormatJSONObject(BaseModel):
] = "json_object"
class ChatGenerationParamsResponseFormatTextTypedDict(TypedDict):
class ResponseFormatTextTypedDict(TypedDict):
type: Literal["text"]
class ChatGenerationParamsResponseFormatText(BaseModel):
class ResponseFormatText(BaseModel):
TYPE: Annotated[
Annotated[Literal["text"], AfterValidator(validate_const("text"))],
pydantic.Field(alias="type"),
] = "text"
ChatGenerationParamsResponseFormatUnionTypedDict = TypeAliasType(
"ChatGenerationParamsResponseFormatUnionTypedDict",
ResponseFormatTypedDict = TypeAliasType(
"ResponseFormatTypedDict",
Union[
ChatGenerationParamsResponseFormatTextTypedDict,
ChatGenerationParamsResponseFormatJSONObjectTypedDict,
ChatGenerationParamsResponseFormatPythonTypedDict,
ResponseFormatTextTypedDict,
ResponseFormatJSONObjectTypedDict,
ResponseFormatPythonTypedDict,
ResponseFormatJSONSchemaTypedDict,
ResponseFormatTextGrammarTypedDict,
],
)
ChatGenerationParamsResponseFormatUnion = Annotated[
ResponseFormat = Annotated[
Union[
Annotated[ChatGenerationParamsResponseFormatText, Tag("text")],
Annotated[ChatGenerationParamsResponseFormatJSONObject, Tag("json_object")],
Annotated[ResponseFormatText, Tag("text")],
Annotated[ResponseFormatJSONObject, Tag("json_object")],
Annotated[ResponseFormatJSONSchema, Tag("json_schema")],
Annotated[ResponseFormatTextGrammar, Tag("grammar")],
Annotated[ChatGenerationParamsResponseFormatPython, Tag("python")],
Annotated[ResponseFormatPython, Tag("python")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
ChatGenerationParamsStopTypedDict = TypeAliasType(
"ChatGenerationParamsStopTypedDict", Union[str, List[str]]
)
StopTypedDict = TypeAliasType("StopTypedDict", Union[str, List[str]])
ChatGenerationParamsStop = TypeAliasType(
"ChatGenerationParamsStop", Union[str, List[str]]
)
Stop = TypeAliasType("Stop", Union[str, List[str]])
class DebugTypedDict(TypedDict):
@@ -640,12 +360,12 @@ class Debug(BaseModel):
ChatGenerationParamsImageConfigTypedDict = TypeAliasType(
"ChatGenerationParamsImageConfigTypedDict", Union[str, float]
"ChatGenerationParamsImageConfigTypedDict", Union[str, float, List[Any]]
)
ChatGenerationParamsImageConfig = TypeAliasType(
"ChatGenerationParamsImageConfig", Union[str, float]
"ChatGenerationParamsImageConfig", Union[str, float, List[Any]]
)
@@ -660,14 +380,11 @@ Modality = Union[
class ChatGenerationParamsTypedDict(TypedDict):
messages: List[MessageTypedDict]
provider: NotRequired[Nullable[ChatGenerationParamsProviderTypedDict]]
r"""When multiple model providers are available, optionally indicate your routing preference."""
plugins: NotRequired[List[ChatGenerationParamsPluginUnionTypedDict]]
r"""Plugins you want to enable for this request, including their settings."""
provider: NotRequired[Nullable[Schema0TypedDict]]
plugins: NotRequired[List[Schema17TypedDict]]
route: NotRequired[Nullable[Route]]
user: NotRequired[str]
session_id: NotRequired[str]
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters."""
model: NotRequired[str]
models: NotRequired[List[str]]
frequency_penalty: NotRequired[Nullable[float]]
@@ -679,9 +396,9 @@ class ChatGenerationParamsTypedDict(TypedDict):
metadata: NotRequired[Dict[str, str]]
presence_penalty: NotRequired[Nullable[float]]
reasoning: NotRequired[ReasoningTypedDict]
response_format: NotRequired[ChatGenerationParamsResponseFormatUnionTypedDict]
response_format: NotRequired[ResponseFormatTypedDict]
seed: NotRequired[Nullable[int]]
stop: NotRequired[Nullable[ChatGenerationParamsStopTypedDict]]
stop: NotRequired[Nullable[StopTypedDict]]
stream: NotRequired[bool]
stream_options: NotRequired[Nullable[ChatStreamOptionsTypedDict]]
temperature: NotRequired[Nullable[float]]
@@ -696,11 +413,9 @@ class ChatGenerationParamsTypedDict(TypedDict):
class ChatGenerationParams(BaseModel):
messages: List[Message]
provider: OptionalNullable[ChatGenerationParamsProvider] = UNSET
r"""When multiple model providers are available, optionally indicate your routing preference."""
provider: OptionalNullable[Schema0] = UNSET
plugins: Optional[List[ChatGenerationParamsPluginUnion]] = None
r"""Plugins you want to enable for this request, including their settings."""
plugins: Optional[List[Schema17]] = None
route: Annotated[
OptionalNullable[Route], PlainValidator(validate_open_enum(False))
@@ -709,7 +424,6 @@ class ChatGenerationParams(BaseModel):
user: Optional[str] = None
session_id: Optional[str] = None
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters."""
model: Optional[str] = None
@@ -733,11 +447,11 @@ class ChatGenerationParams(BaseModel):
reasoning: Optional[Reasoning] = None
response_format: Optional[ChatGenerationParamsResponseFormatUnion] = None
response_format: Optional[ResponseFormat] = None
seed: OptionalNullable[int] = UNSET
stop: OptionalNullable[ChatGenerationParamsStop] = UNSET
stop: OptionalNullable[Stop] = UNSET
stream: Optional[bool] = False