mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-30 12:20:57 +08:00
Commits included in this export:
- 56d382078cfce7fa597d1da2bce531af2d060b47 - 9ef6db7e04c9401536763a321b05d00311cef31a - bf855082e30820d466f0f86a6d6e87de2ecfb06f - 335b1cbe361214e48b945b987b4e164457aa817b - 648485fdc7f9d8ae86fd857eccedcc5e41fb2e69 - 80c49474a15a2bd549a5f26efad3858aa45b7c7b - 70e8ac317f9c4472db3decd024d1819650df4182 - 9f2a6659ab6dbf111a0c29e4366328c3d2048826 - a3a28b1fc6ec7d2941232a4ebde8c5f470497876 - 4b5dc9193480b7c5c9ddb882ccf3ee2128ca0d51 - bb413e979a46ef67c2f266743f7ebd798af42afb - b60e92d5dcec83f31986164f51c010d1728b2b17 - 45687f423707f5838461585c568a024a19eb2f06 - 3103d3ca68b6e42ccdb6136588ec2b6edc8dcab0 - fd9f991606027cd86116317c71f8eb7b4e2aa3eb - 0f312019161edd76c1e5923d142c788d22f096d5 - 5dbab2094bc744db4a90b3097520d897e5d0d634 - 4c47d1af1735db18a1c1a7f463e801c7f71ad4e5 GitOrigin-RevId: 56d382078cfce7fa597d1da2bce531af2d060b47
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
import importlib.metadata
|
||||
|
||||
__title__: str = "openrouter"
|
||||
__version__: str = "0.6.0"
|
||||
__version__: str = "0.7.11"
|
||||
__openapi_doc_version__: str = "1.0.0"
|
||||
__gen_version__: str = "2.768.0"
|
||||
__user_agent__: str = "speakeasy-sdk/python 0.6.0 2.768.0 1.0.0 openrouter"
|
||||
__user_agent__: str = "speakeasy-sdk/python 0.7.11 2.768.0 1.0.0 openrouter"
|
||||
|
||||
try:
|
||||
if __package__ is not None:
|
||||
|
||||
+562
-242
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,39 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from ._schema14 import Schema14, Schema14TypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Any, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
PromptTypedDict = TypeAliasType("PromptTypedDict", Union[float, str, Any])
|
||||
|
||||
|
||||
Prompt = TypeAliasType("Prompt", Union[float, str, Any])
|
||||
|
||||
|
||||
CompletionTypedDict = TypeAliasType("CompletionTypedDict", Union[float, str, Any])
|
||||
|
||||
|
||||
Completion = TypeAliasType("Completion", Union[float, str, Any])
|
||||
|
||||
|
||||
class Schema10TypedDict(TypedDict):
|
||||
prompt: NotRequired[PromptTypedDict]
|
||||
completion: NotRequired[CompletionTypedDict]
|
||||
image: NotRequired[Schema14TypedDict]
|
||||
audio: NotRequired[Schema14TypedDict]
|
||||
request: NotRequired[Schema14TypedDict]
|
||||
|
||||
|
||||
class Schema10(BaseModel):
|
||||
prompt: Optional[Prompt] = None
|
||||
|
||||
completion: Optional[Completion] = None
|
||||
|
||||
image: Optional[Schema14] = None
|
||||
|
||||
audio: Optional[Schema14] = None
|
||||
|
||||
request: Optional[Schema14] = None
|
||||
@@ -1,11 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import Any, Union
|
||||
from typing_extensions import TypeAliasType
|
||||
|
||||
|
||||
Schema14TypedDict = TypeAliasType("Schema14TypedDict", Union[float, str, Any])
|
||||
|
||||
|
||||
Schema14 = TypeAliasType("Schema14", Union[float, str, Any])
|
||||
@@ -1,154 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import get_discriminator, validate_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import Discriminator, Tag
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class Schema17ResponseHealingTypedDict(TypedDict):
|
||||
id: Literal["response-healing"]
|
||||
enabled: NotRequired[bool]
|
||||
|
||||
|
||||
class Schema17ResponseHealing(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 Schema17FileParserTypedDict(TypedDict):
|
||||
id: Literal["file-parser"]
|
||||
enabled: NotRequired[bool]
|
||||
pdf: NotRequired[PdfTypedDict]
|
||||
|
||||
|
||||
class Schema17FileParser(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 Schema17WebTypedDict(TypedDict):
|
||||
id: Literal["web"]
|
||||
enabled: NotRequired[bool]
|
||||
max_results: NotRequired[float]
|
||||
search_prompt: NotRequired[str]
|
||||
engine: NotRequired[Engine]
|
||||
|
||||
|
||||
class Schema17Web(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 Schema17ModerationTypedDict(TypedDict):
|
||||
id: Literal["moderation"]
|
||||
|
||||
|
||||
class Schema17Moderation(BaseModel):
|
||||
ID: Annotated[
|
||||
Annotated[Literal["moderation"], AfterValidator(validate_const("moderation"))],
|
||||
pydantic.Field(alias="id"),
|
||||
] = "moderation"
|
||||
|
||||
|
||||
class Schema17AutoRouterTypedDict(TypedDict):
|
||||
id: Literal["auto-router"]
|
||||
enabled: NotRequired[bool]
|
||||
allowed_models: NotRequired[List[str]]
|
||||
|
||||
|
||||
class Schema17AutoRouter(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
|
||||
|
||||
|
||||
Schema17TypedDict = TypeAliasType(
|
||||
"Schema17TypedDict",
|
||||
Union[
|
||||
Schema17ModerationTypedDict,
|
||||
Schema17ResponseHealingTypedDict,
|
||||
Schema17AutoRouterTypedDict,
|
||||
Schema17FileParserTypedDict,
|
||||
Schema17WebTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Schema17 = Annotated[
|
||||
Union[
|
||||
Annotated[Schema17AutoRouter, Tag("auto-router")],
|
||||
Annotated[Schema17Moderation, Tag("moderation")],
|
||||
Annotated[Schema17Web, Tag("web")],
|
||||
Annotated[Schema17FileParser, Tag("file-parser")],
|
||||
Annotated[Schema17ResponseHealing, Tag("response-healing")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "id", "id")),
|
||||
]
|
||||
@@ -1,235 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
Schema21 = Union[
|
||||
Literal[
|
||||
"unknown",
|
||||
"openai-responses-v1",
|
||||
"azure-openai-responses-v1",
|
||||
"xai-responses-v1",
|
||||
"anthropic-claude-v1",
|
||||
"google-gemini-v1",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class Schema19ReasoningTextTypedDict(TypedDict):
|
||||
type: Literal["reasoning.text"]
|
||||
text: NotRequired[Nullable[str]]
|
||||
signature: NotRequired[Nullable[str]]
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[Schema21]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class Schema19ReasoningText(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["reasoning.text"], AfterValidator(validate_const("reasoning.text"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "reasoning.text"
|
||||
|
||||
text: OptionalNullable[str] = UNSET
|
||||
|
||||
signature: OptionalNullable[str] = UNSET
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[Schema21], PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["text", "signature", "id", "format", "index"]
|
||||
nullable_fields = ["text", "signature", "id", "format"]
|
||||
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 Schema19ReasoningEncryptedTypedDict(TypedDict):
|
||||
data: str
|
||||
type: Literal["reasoning.encrypted"]
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[Schema21]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class Schema19ReasoningEncrypted(BaseModel):
|
||||
data: str
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["reasoning.encrypted"],
|
||||
AfterValidator(validate_const("reasoning.encrypted")),
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "reasoning.encrypted"
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[Schema21], PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["id", "format", "index"]
|
||||
nullable_fields = ["id", "format"]
|
||||
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 Schema19ReasoningSummaryTypedDict(TypedDict):
|
||||
summary: str
|
||||
type: Literal["reasoning.summary"]
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[Schema21]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class Schema19ReasoningSummary(BaseModel):
|
||||
summary: str
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["reasoning.summary"],
|
||||
AfterValidator(validate_const("reasoning.summary")),
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "reasoning.summary"
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[Schema21], PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["id", "format", "index"]
|
||||
nullable_fields = ["id", "format"]
|
||||
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
|
||||
|
||||
|
||||
Schema19TypedDict = TypeAliasType(
|
||||
"Schema19TypedDict",
|
||||
Union[
|
||||
Schema19ReasoningSummaryTypedDict,
|
||||
Schema19ReasoningEncryptedTypedDict,
|
||||
Schema19ReasoningTextTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Schema19 = Annotated[
|
||||
Union[
|
||||
Annotated[Schema19ReasoningSummary, Tag("reasoning.summary")],
|
||||
Annotated[Schema19ReasoningEncrypted, Tag("reasoning.encrypted")],
|
||||
Annotated[Schema19ReasoningText, Tag("reasoning.text")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
@@ -1,96 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypeAliasType
|
||||
|
||||
|
||||
Schema5Enum = Union[
|
||||
Literal[
|
||||
"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",
|
||||
"StepFun",
|
||||
"Stealth",
|
||||
"StreamLake",
|
||||
"Switchpoint",
|
||||
"Together",
|
||||
"Upstage",
|
||||
"Venice",
|
||||
"WandB",
|
||||
"Xiaomi",
|
||||
"xAI",
|
||||
"Z.AI",
|
||||
"FakeProvider",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
Schema5TypedDict = TypeAliasType("Schema5TypedDict", Union[Schema5Enum, str])
|
||||
|
||||
|
||||
Schema5 = TypeAliasType(
|
||||
"Schema5",
|
||||
Union[Annotated[Schema5Enum, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
@@ -1,12 +1,16 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from ._schema19 import Schema19, Schema19TypedDict
|
||||
from .assistantmessageimages import (
|
||||
AssistantMessageImages,
|
||||
AssistantMessageImagesTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitem import (
|
||||
ChatMessageContentItem,
|
||||
ChatMessageContentItemTypedDict,
|
||||
)
|
||||
from .chatmessagetoolcall import ChatMessageToolCall, ChatMessageToolCallTypedDict
|
||||
from .reasoningdetailunion import ReasoningDetailUnion, ReasoningDetailUnionTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -14,71 +18,72 @@ from openrouter.types import (
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
AssistantMessageRole = Literal["assistant",]
|
||||
|
||||
|
||||
AssistantMessageContentTypedDict = TypeAliasType(
|
||||
"AssistantMessageContentTypedDict",
|
||||
Union[str, List[ChatMessageContentItemTypedDict]],
|
||||
Union[str, List[ChatMessageContentItemTypedDict], Any],
|
||||
)
|
||||
r"""Assistant message content"""
|
||||
|
||||
|
||||
AssistantMessageContent = TypeAliasType(
|
||||
"AssistantMessageContent", Union[str, List[ChatMessageContentItem]]
|
||||
"AssistantMessageContent", Union[str, List[ChatMessageContentItem], Any]
|
||||
)
|
||||
|
||||
|
||||
class AssistantMessageImageURLTypedDict(TypedDict):
|
||||
url: str
|
||||
|
||||
|
||||
class AssistantMessageImageURL(BaseModel):
|
||||
url: str
|
||||
|
||||
|
||||
class ImageTypedDict(TypedDict):
|
||||
image_url: AssistantMessageImageURLTypedDict
|
||||
|
||||
|
||||
class Image(BaseModel):
|
||||
image_url: AssistantMessageImageURL
|
||||
r"""Assistant message content"""
|
||||
|
||||
|
||||
class AssistantMessageTypedDict(TypedDict):
|
||||
role: Literal["assistant"]
|
||||
r"""Assistant message for requests and responses"""
|
||||
|
||||
role: AssistantMessageRole
|
||||
content: NotRequired[Nullable[AssistantMessageContentTypedDict]]
|
||||
r"""Assistant message content"""
|
||||
name: NotRequired[str]
|
||||
r"""Optional name for the assistant"""
|
||||
tool_calls: NotRequired[List[ChatMessageToolCallTypedDict]]
|
||||
r"""Tool calls made by the assistant"""
|
||||
refusal: NotRequired[Nullable[str]]
|
||||
r"""Refusal message if content was refused"""
|
||||
reasoning: NotRequired[Nullable[str]]
|
||||
reasoning_details: NotRequired[List[Schema19TypedDict]]
|
||||
images: NotRequired[List[ImageTypedDict]]
|
||||
r"""Reasoning output"""
|
||||
reasoning_details: NotRequired[List[ReasoningDetailUnionTypedDict]]
|
||||
r"""Reasoning details for extended thinking models"""
|
||||
images: NotRequired[List[AssistantMessageImagesTypedDict]]
|
||||
r"""Generated images from image generation models"""
|
||||
|
||||
|
||||
class AssistantMessage(BaseModel):
|
||||
ROLE: Annotated[
|
||||
Annotated[Literal["assistant"], AfterValidator(validate_const("assistant"))],
|
||||
pydantic.Field(alias="role"),
|
||||
] = "assistant"
|
||||
r"""Assistant message for requests and responses"""
|
||||
|
||||
role: AssistantMessageRole
|
||||
|
||||
content: OptionalNullable[AssistantMessageContent] = UNSET
|
||||
r"""Assistant message content"""
|
||||
|
||||
name: Optional[str] = None
|
||||
r"""Optional name for the assistant"""
|
||||
|
||||
tool_calls: Optional[List[ChatMessageToolCall]] = None
|
||||
r"""Tool calls made by the assistant"""
|
||||
|
||||
refusal: OptionalNullable[str] = UNSET
|
||||
r"""Refusal message if content was refused"""
|
||||
|
||||
reasoning: OptionalNullable[str] = UNSET
|
||||
r"""Reasoning output"""
|
||||
|
||||
reasoning_details: Optional[List[Schema19]] = None
|
||||
reasoning_details: Optional[List[ReasoningDetailUnion]] = None
|
||||
r"""Reasoning details for extended thinking models"""
|
||||
|
||||
images: Optional[List[Image]] = None
|
||||
images: Optional[List[AssistantMessageImages]] = None
|
||||
r"""Generated images from image generation models"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class AssistantMessageImagesImageURLTypedDict(TypedDict):
|
||||
url: str
|
||||
r"""URL or base64-encoded data of the generated image"""
|
||||
|
||||
|
||||
class AssistantMessageImagesImageURL(BaseModel):
|
||||
url: str
|
||||
r"""URL or base64-encoded data of the generated image"""
|
||||
|
||||
|
||||
class AssistantMessageImagesTypedDict(TypedDict):
|
||||
image_url: AssistantMessageImagesImageURLTypedDict
|
||||
|
||||
|
||||
class AssistantMessageImages(BaseModel):
|
||||
image_url: AssistantMessageImagesImageURL
|
||||
@@ -1,66 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
CodeTypedDict = TypeAliasType("CodeTypedDict", Union[str, float])
|
||||
|
||||
|
||||
Code = TypeAliasType("Code", Union[str, float])
|
||||
|
||||
|
||||
class ChatErrorErrorTypedDict(TypedDict):
|
||||
code: Nullable[CodeTypedDict]
|
||||
message: str
|
||||
param: NotRequired[Nullable[str]]
|
||||
type: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class ChatErrorError(BaseModel):
|
||||
code: Nullable[Code]
|
||||
|
||||
message: str
|
||||
|
||||
param: OptionalNullable[str] = UNSET
|
||||
|
||||
type: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["param", "type"]
|
||||
nullable_fields = ["code", "param", "type"]
|
||||
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
|
||||
@@ -1,22 +1,38 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from ._schema10 import Schema10, Schema10TypedDict
|
||||
from ._schema17 import Schema17, Schema17TypedDict
|
||||
from ._schema5 import Schema5, Schema5TypedDict
|
||||
from .chatstreamoptions import ChatStreamOptions, ChatStreamOptionsTypedDict
|
||||
from .datacollection import DataCollection
|
||||
from .debugoptions import DebugOptions, DebugOptionsTypedDict
|
||||
from .message import Message, MessageTypedDict
|
||||
from .providersortunion import ProviderSortUnion, ProviderSortUnionTypedDict
|
||||
from .reasoningsummaryverbosity import ReasoningSummaryVerbosity
|
||||
from .pdfparseroptions import PDFParserOptions, PDFParserOptionsTypedDict
|
||||
from .preferredmaxlatency import PreferredMaxLatency, PreferredMaxLatencyTypedDict
|
||||
from .preferredminthroughput import (
|
||||
PreferredMinThroughput,
|
||||
PreferredMinThroughputTypedDict,
|
||||
)
|
||||
from .providername import ProviderName
|
||||
from .quantization import Quantization
|
||||
from .responseformatjsonobject import (
|
||||
ResponseFormatJSONObject,
|
||||
ResponseFormatJSONObjectTypedDict,
|
||||
)
|
||||
from .responseformatjsonschema import (
|
||||
ResponseFormatJSONSchema,
|
||||
ResponseFormatJSONSchemaTypedDict,
|
||||
)
|
||||
from .responseformattext import ResponseFormatText, ResponseFormatTextTypedDict
|
||||
from .responseformattextgrammar import (
|
||||
ResponseFormatTextGrammar,
|
||||
ResponseFormatTextGrammarTypedDict,
|
||||
)
|
||||
from .responseformattextpython import (
|
||||
ResponseFormatTextPython,
|
||||
ResponseFormatTextPythonTypedDict,
|
||||
)
|
||||
from .toolchoiceoption import ToolChoiceOption, ToolChoiceOptionTypedDict
|
||||
from .tooldefinitionjson import ToolDefinitionJSON, ToolDefinitionJSONTypedDict
|
||||
from .websearchengine import WebSearchEngine
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -25,59 +41,109 @@ from openrouter.types import (
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_const, validate_open_enum
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from pydantic import ConfigDict, Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, Dict, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
Schema3 = Union[
|
||||
ChatGenerationParamsOrderTypedDict = TypeAliasType(
|
||||
"ChatGenerationParamsOrderTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
ChatGenerationParamsOrder = TypeAliasType(
|
||||
"ChatGenerationParamsOrder",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
ChatGenerationParamsOnlyTypedDict = TypeAliasType(
|
||||
"ChatGenerationParamsOnlyTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
ChatGenerationParamsOnly = TypeAliasType(
|
||||
"ChatGenerationParamsOnly",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
ChatGenerationParamsIgnoreTypedDict = TypeAliasType(
|
||||
"ChatGenerationParamsIgnoreTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
ChatGenerationParamsIgnore = TypeAliasType(
|
||||
"ChatGenerationParamsIgnore",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
ChatGenerationParamsSortEnum = Union[
|
||||
Literal[
|
||||
"deny",
|
||||
"allow",
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
Schema8 = Union[
|
||||
Literal[
|
||||
"int4",
|
||||
"int8",
|
||||
"fp4",
|
||||
"fp6",
|
||||
"fp8",
|
||||
"fp16",
|
||||
"bf16",
|
||||
"fp32",
|
||||
"unknown",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
ChatGenerationParamsProviderSortConfigEnum = Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
]
|
||||
|
||||
|
||||
class Schema15TypedDict(TypedDict):
|
||||
p50: NotRequired[Nullable[float]]
|
||||
p75: NotRequired[Nullable[float]]
|
||||
p90: NotRequired[Nullable[float]]
|
||||
p99: NotRequired[Nullable[float]]
|
||||
ChatGenerationParamsBy = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
|
||||
class Schema15(BaseModel):
|
||||
p50: OptionalNullable[float] = UNSET
|
||||
ChatGenerationParamsPartition = Union[
|
||||
Literal[
|
||||
"model",
|
||||
"none",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
p75: OptionalNullable[float] = UNSET
|
||||
|
||||
p90: OptionalNullable[float] = UNSET
|
||||
class ChatGenerationParamsProviderSortConfigTypedDict(TypedDict):
|
||||
by: NotRequired[Nullable[ChatGenerationParamsBy]]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
partition: NotRequired[Nullable[ChatGenerationParamsPartition]]
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
p99: OptionalNullable[float] = UNSET
|
||||
|
||||
class ChatGenerationParamsProviderSortConfig(BaseModel):
|
||||
by: Annotated[
|
||||
OptionalNullable[ChatGenerationParamsBy],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
partition: Annotated[
|
||||
OptionalNullable[ChatGenerationParamsPartition],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["p50", "p75", "p90", "p99"]
|
||||
nullable_fields = ["p50", "p75", "p90", "p99"]
|
||||
optional_fields = ["by", "partition"]
|
||||
nullable_fields = ["by", "partition"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
@@ -105,60 +171,177 @@ class Schema15(BaseModel):
|
||||
return m
|
||||
|
||||
|
||||
Schema15UnionTypedDict = TypeAliasType(
|
||||
"Schema15UnionTypedDict", Union[Schema15TypedDict, float]
|
||||
ChatGenerationParamsProviderSortConfigUnionTypedDict = TypeAliasType(
|
||||
"ChatGenerationParamsProviderSortConfigUnionTypedDict",
|
||||
Union[
|
||||
ChatGenerationParamsProviderSortConfigTypedDict,
|
||||
ChatGenerationParamsProviderSortConfigEnum,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Schema15Union = TypeAliasType("Schema15Union", Union[Schema15, float])
|
||||
ChatGenerationParamsProviderSortConfigUnion = TypeAliasType(
|
||||
"ChatGenerationParamsProviderSortConfigUnion",
|
||||
Union[
|
||||
ChatGenerationParamsProviderSortConfig,
|
||||
ChatGenerationParamsProviderSortConfigEnum,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class Schema0TypedDict(TypedDict):
|
||||
ChatGenerationParamsProviderSort = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
|
||||
ChatGenerationParamsSortUnionTypedDict = TypeAliasType(
|
||||
"ChatGenerationParamsSortUnionTypedDict",
|
||||
Union[
|
||||
ChatGenerationParamsProviderSort,
|
||||
ChatGenerationParamsProviderSortConfigUnionTypedDict,
|
||||
ChatGenerationParamsSortEnum,
|
||||
],
|
||||
)
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
|
||||
ChatGenerationParamsSortUnion = TypeAliasType(
|
||||
"ChatGenerationParamsSortUnion",
|
||||
Union[
|
||||
Annotated[
|
||||
ChatGenerationParamsProviderSort, PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
ChatGenerationParamsProviderSortConfigUnion,
|
||||
Annotated[
|
||||
ChatGenerationParamsSortEnum, PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
],
|
||||
)
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
|
||||
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[str]
|
||||
r"""Price per million prompt tokens"""
|
||||
completion: NotRequired[str]
|
||||
image: NotRequired[str]
|
||||
audio: NotRequired[str]
|
||||
request: NotRequired[str]
|
||||
|
||||
|
||||
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[str] = None
|
||||
r"""Price per million prompt tokens"""
|
||||
|
||||
completion: Optional[str] = None
|
||||
|
||||
image: Optional[str] = None
|
||||
|
||||
audio: Optional[str] = None
|
||||
|
||||
request: Optional[str] = None
|
||||
|
||||
|
||||
class ChatGenerationParamsProviderTypedDict(TypedDict):
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
|
||||
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]]
|
||||
data_collection: NotRequired[Nullable[Schema3]]
|
||||
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[DataCollection]]
|
||||
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: NotRequired[Nullable[bool]]
|
||||
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
|
||||
enforce_distillable_text: NotRequired[Nullable[bool]]
|
||||
order: NotRequired[Nullable[List[Schema5TypedDict]]]
|
||||
only: NotRequired[Nullable[List[Schema5TypedDict]]]
|
||||
ignore: NotRequired[Nullable[List[Schema5TypedDict]]]
|
||||
quantizations: NotRequired[Nullable[List[Schema8]]]
|
||||
sort: NotRequired[Nullable[ProviderSortUnionTypedDict]]
|
||||
max_price: NotRequired[Schema10TypedDict]
|
||||
preferred_min_throughput: NotRequired[Nullable[Schema15UnionTypedDict]]
|
||||
preferred_max_latency: NotRequired[Nullable[Schema15UnionTypedDict]]
|
||||
r"""Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used."""
|
||||
order: NotRequired[Nullable[List[ChatGenerationParamsOrderTypedDict]]]
|
||||
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[ChatGenerationParamsOnlyTypedDict]]]
|
||||
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[ChatGenerationParamsIgnoreTypedDict]]]
|
||||
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[Quantization]]]
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
sort: NotRequired[Nullable[ChatGenerationParamsSortUnionTypedDict]]
|
||||
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[PreferredMinThroughputTypedDict]]
|
||||
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[PreferredMaxLatencyTypedDict]]
|
||||
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."""
|
||||
|
||||
|
||||
class Schema0(BaseModel):
|
||||
class ChatGenerationParamsProvider(BaseModel):
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
|
||||
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[Schema3], PlainValidator(validate_open_enum(False))
|
||||
OptionalNullable[DataCollection], 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
|
||||
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
|
||||
|
||||
enforce_distillable_text: OptionalNullable[bool] = UNSET
|
||||
r"""Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used."""
|
||||
|
||||
order: OptionalNullable[List[Schema5]] = UNSET
|
||||
order: OptionalNullable[List[ChatGenerationParamsOrder]] = 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."""
|
||||
|
||||
only: OptionalNullable[List[Schema5]] = UNSET
|
||||
only: OptionalNullable[List[ChatGenerationParamsOnly]] = UNSET
|
||||
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
|
||||
|
||||
ignore: OptionalNullable[List[Schema5]] = UNSET
|
||||
ignore: OptionalNullable[List[ChatGenerationParamsIgnore]] = UNSET
|
||||
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
||||
|
||||
quantizations: OptionalNullable[
|
||||
List[Annotated[Schema8, PlainValidator(validate_open_enum(False))]]
|
||||
List[Annotated[Quantization, PlainValidator(validate_open_enum(False))]]
|
||||
] = UNSET
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
|
||||
sort: OptionalNullable[ProviderSortUnion] = UNSET
|
||||
sort: OptionalNullable[ChatGenerationParamsSortUnion] = UNSET
|
||||
|
||||
max_price: Optional[Schema10] = None
|
||||
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."""
|
||||
|
||||
preferred_min_throughput: OptionalNullable[Schema15Union] = UNSET
|
||||
preferred_min_throughput: OptionalNullable[PreferredMinThroughput] = 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_max_latency: OptionalNullable[Schema15Union] = UNSET
|
||||
preferred_max_latency: OptionalNullable[PreferredMaxLatency] = 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."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
@@ -218,15 +401,165 @@ class Schema0(BaseModel):
|
||||
return m
|
||||
|
||||
|
||||
Route = Union[
|
||||
Literal[
|
||||
"fallback",
|
||||
"sort",
|
||||
ChatGenerationParamsIDResponseHealing = Literal["response-healing",]
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginResponseHealingTypedDict(TypedDict):
|
||||
id: ChatGenerationParamsIDResponseHealing
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the response-healing plugin for this request. Defaults to true."""
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginResponseHealing(BaseModel):
|
||||
id: ChatGenerationParamsIDResponseHealing
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the response-healing plugin for this request. Defaults to true."""
|
||||
|
||||
|
||||
ChatGenerationParamsIDFileParser = Literal["file-parser",]
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginFileParserTypedDict(TypedDict):
|
||||
id: ChatGenerationParamsIDFileParser
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the file-parser plugin for this request. Defaults to true."""
|
||||
pdf: NotRequired[PDFParserOptionsTypedDict]
|
||||
r"""Options for PDF parsing."""
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginFileParser(BaseModel):
|
||||
id: ChatGenerationParamsIDFileParser
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the file-parser plugin for this request. Defaults to true."""
|
||||
|
||||
pdf: Optional[PDFParserOptions] = None
|
||||
r"""Options for PDF parsing."""
|
||||
|
||||
|
||||
ChatGenerationParamsIDWeb = Literal["web",]
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginWebTypedDict(TypedDict):
|
||||
id: ChatGenerationParamsIDWeb
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the web-search plugin for this request. Defaults to true."""
|
||||
max_results: NotRequired[float]
|
||||
search_prompt: NotRequired[str]
|
||||
engine: NotRequired[WebSearchEngine]
|
||||
r"""The search engine to use for web search."""
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginWeb(BaseModel):
|
||||
id: ChatGenerationParamsIDWeb
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the web-search plugin for this request. Defaults to true."""
|
||||
|
||||
max_results: Optional[float] = None
|
||||
|
||||
search_prompt: Optional[str] = None
|
||||
|
||||
engine: Annotated[
|
||||
Optional[WebSearchEngine], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""The search engine to use for web search."""
|
||||
|
||||
|
||||
ChatGenerationParamsIDModeration = Literal["moderation",]
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginModerationTypedDict(TypedDict):
|
||||
id: ChatGenerationParamsIDModeration
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginModeration(BaseModel):
|
||||
id: ChatGenerationParamsIDModeration
|
||||
|
||||
|
||||
ChatGenerationParamsIDAutoRouter = Literal["auto-router",]
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginAutoRouterTypedDict(TypedDict):
|
||||
id: ChatGenerationParamsIDAutoRouter
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
|
||||
allowed_models: NotRequired[List[str]]
|
||||
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginAutoRouter(BaseModel):
|
||||
id: ChatGenerationParamsIDAutoRouter
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
|
||||
|
||||
allowed_models: Optional[List[str]] = None
|
||||
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
|
||||
|
||||
|
||||
ChatGenerationParamsPluginUnionTypedDict = TypeAliasType(
|
||||
"ChatGenerationParamsPluginUnionTypedDict",
|
||||
Union[
|
||||
ChatGenerationParamsPluginModerationTypedDict,
|
||||
ChatGenerationParamsPluginResponseHealingTypedDict,
|
||||
ChatGenerationParamsPluginAutoRouterTypedDict,
|
||||
ChatGenerationParamsPluginFileParserTypedDict,
|
||||
ChatGenerationParamsPluginWebTypedDict,
|
||||
],
|
||||
UnrecognizedStr,
|
||||
)
|
||||
|
||||
|
||||
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")),
|
||||
]
|
||||
|
||||
|
||||
class ChatGenerationParamsTraceTypedDict(TypedDict):
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
|
||||
trace_id: NotRequired[str]
|
||||
trace_name: NotRequired[str]
|
||||
span_name: NotRequired[str]
|
||||
generation_name: NotRequired[str]
|
||||
parent_span_id: NotRequired[str]
|
||||
|
||||
|
||||
class ChatGenerationParamsTrace(BaseModel):
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
|
||||
)
|
||||
__pydantic_extra__: Dict[str, Nullable[Any]] = pydantic.Field(init=False)
|
||||
|
||||
trace_id: Optional[str] = None
|
||||
|
||||
trace_name: Optional[str] = None
|
||||
|
||||
span_name: Optional[str] = None
|
||||
|
||||
generation_name: Optional[str] = None
|
||||
|
||||
parent_span_id: Optional[str] = None
|
||||
|
||||
@property
|
||||
def additional_properties(self):
|
||||
return self.__pydantic_extra__
|
||||
|
||||
@additional_properties.setter
|
||||
def additional_properties(self, value):
|
||||
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
|
||||
|
||||
|
||||
Effort = Union[
|
||||
Literal[
|
||||
"xhigh",
|
||||
@@ -238,22 +571,26 @@ Effort = Union[
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Constrains effort on reasoning for reasoning models"""
|
||||
|
||||
|
||||
class ReasoningTypedDict(TypedDict):
|
||||
r"""Configuration options for reasoning models"""
|
||||
|
||||
effort: NotRequired[Nullable[Effort]]
|
||||
summary: NotRequired[Nullable[ReasoningSummaryVerbosity]]
|
||||
r"""Constrains effort on reasoning for reasoning models"""
|
||||
summary: NotRequired[Nullable[Any]]
|
||||
|
||||
|
||||
class Reasoning(BaseModel):
|
||||
r"""Configuration options for reasoning models"""
|
||||
|
||||
effort: Annotated[
|
||||
OptionalNullable[Effort], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
r"""Constrains effort on reasoning for reasoning models"""
|
||||
|
||||
summary: Annotated[
|
||||
OptionalNullable[ReasoningSummaryVerbosity],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
summary: OptionalNullable[Any] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
@@ -286,51 +623,17 @@ class Reasoning(BaseModel):
|
||||
return m
|
||||
|
||||
|
||||
class ResponseFormatPythonTypedDict(TypedDict):
|
||||
type: Literal["python"]
|
||||
|
||||
|
||||
class ResponseFormatPython(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["python"], AfterValidator(validate_const("python"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "python"
|
||||
|
||||
|
||||
class ResponseFormatJSONObjectTypedDict(TypedDict):
|
||||
type: Literal["json_object"]
|
||||
|
||||
|
||||
class ResponseFormatJSONObject(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["json_object"], AfterValidator(validate_const("json_object"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "json_object"
|
||||
|
||||
|
||||
class ResponseFormatTextTypedDict(TypedDict):
|
||||
type: Literal["text"]
|
||||
|
||||
|
||||
class ResponseFormatText(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["text"], AfterValidator(validate_const("text"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "text"
|
||||
|
||||
|
||||
ResponseFormatTypedDict = TypeAliasType(
|
||||
"ResponseFormatTypedDict",
|
||||
Union[
|
||||
ResponseFormatTextTypedDict,
|
||||
ResponseFormatJSONObjectTypedDict,
|
||||
ResponseFormatPythonTypedDict,
|
||||
ResponseFormatTextPythonTypedDict,
|
||||
ResponseFormatJSONSchemaTypedDict,
|
||||
ResponseFormatTextGrammarTypedDict,
|
||||
],
|
||||
)
|
||||
r"""Response format configuration"""
|
||||
|
||||
|
||||
ResponseFormat = Annotated[
|
||||
@@ -339,33 +642,28 @@ ResponseFormat = Annotated[
|
||||
Annotated[ResponseFormatJSONObject, Tag("json_object")],
|
||||
Annotated[ResponseFormatJSONSchema, Tag("json_schema")],
|
||||
Annotated[ResponseFormatTextGrammar, Tag("grammar")],
|
||||
Annotated[ResponseFormatPython, Tag("python")],
|
||||
Annotated[ResponseFormatTextPython, Tag("python")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
r"""Response format configuration"""
|
||||
|
||||
|
||||
StopTypedDict = TypeAliasType("StopTypedDict", Union[str, List[str]])
|
||||
StopTypedDict = TypeAliasType("StopTypedDict", Union[str, List[str], Any])
|
||||
r"""Stop sequences (up to 4)"""
|
||||
|
||||
|
||||
Stop = TypeAliasType("Stop", Union[str, List[str]])
|
||||
|
||||
|
||||
class DebugTypedDict(TypedDict):
|
||||
echo_upstream_body: NotRequired[bool]
|
||||
|
||||
|
||||
class Debug(BaseModel):
|
||||
echo_upstream_body: Optional[bool] = None
|
||||
Stop = TypeAliasType("Stop", Union[str, List[str], Any])
|
||||
r"""Stop sequences (up to 4)"""
|
||||
|
||||
|
||||
ChatGenerationParamsImageConfigTypedDict = TypeAliasType(
|
||||
"ChatGenerationParamsImageConfigTypedDict", Union[str, float, List[Any]]
|
||||
"ChatGenerationParamsImageConfigTypedDict", Union[str, float, List[Nullable[Any]]]
|
||||
)
|
||||
|
||||
|
||||
ChatGenerationParamsImageConfig = TypeAliasType(
|
||||
"ChatGenerationParamsImageConfig", Union[str, float, List[Any]]
|
||||
"ChatGenerationParamsImageConfig", Union[str, float, List[Nullable[Any]]]
|
||||
)
|
||||
|
||||
|
||||
@@ -379,108 +677,171 @@ Modality = Union[
|
||||
|
||||
|
||||
class ChatGenerationParamsTypedDict(TypedDict):
|
||||
r"""Chat completion request parameters"""
|
||||
|
||||
messages: List[MessageTypedDict]
|
||||
provider: NotRequired[Nullable[Schema0TypedDict]]
|
||||
plugins: NotRequired[List[Schema17TypedDict]]
|
||||
route: NotRequired[Nullable[Route]]
|
||||
r"""List of messages for the conversation"""
|
||||
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."""
|
||||
user: NotRequired[str]
|
||||
r"""Unique user identifier"""
|
||||
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."""
|
||||
trace: NotRequired[ChatGenerationParamsTraceTypedDict]
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
model: NotRequired[str]
|
||||
r"""Model to use for completion"""
|
||||
models: NotRequired[List[str]]
|
||||
r"""Models to use for completion"""
|
||||
frequency_penalty: NotRequired[Nullable[float]]
|
||||
r"""Frequency penalty (-2.0 to 2.0)"""
|
||||
logit_bias: NotRequired[Nullable[Dict[str, float]]]
|
||||
r"""Token logit bias adjustments"""
|
||||
logprobs: NotRequired[Nullable[bool]]
|
||||
r"""Return log probabilities"""
|
||||
top_logprobs: NotRequired[Nullable[float]]
|
||||
r"""Number of top log probabilities to return (0-20)"""
|
||||
max_completion_tokens: NotRequired[Nullable[float]]
|
||||
r"""Maximum tokens in completion"""
|
||||
max_tokens: NotRequired[Nullable[float]]
|
||||
r"""Maximum tokens (deprecated, use max_completion_tokens)"""
|
||||
metadata: NotRequired[Dict[str, str]]
|
||||
r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)"""
|
||||
presence_penalty: NotRequired[Nullable[float]]
|
||||
r"""Presence penalty (-2.0 to 2.0)"""
|
||||
reasoning: NotRequired[ReasoningTypedDict]
|
||||
r"""Configuration options for reasoning models"""
|
||||
response_format: NotRequired[ResponseFormatTypedDict]
|
||||
r"""Response format configuration"""
|
||||
seed: NotRequired[Nullable[int]]
|
||||
r"""Random seed for deterministic outputs"""
|
||||
stop: NotRequired[Nullable[StopTypedDict]]
|
||||
r"""Stop sequences (up to 4)"""
|
||||
stream: NotRequired[bool]
|
||||
r"""Enable streaming response"""
|
||||
stream_options: NotRequired[Nullable[ChatStreamOptionsTypedDict]]
|
||||
r"""Streaming configuration options"""
|
||||
temperature: NotRequired[Nullable[float]]
|
||||
tool_choice: NotRequired[Any]
|
||||
r"""Sampling temperature (0-2)"""
|
||||
parallel_tool_calls: NotRequired[Nullable[bool]]
|
||||
tool_choice: NotRequired[ToolChoiceOptionTypedDict]
|
||||
r"""Tool choice configuration"""
|
||||
tools: NotRequired[List[ToolDefinitionJSONTypedDict]]
|
||||
r"""Available tools for function calling"""
|
||||
top_p: NotRequired[Nullable[float]]
|
||||
debug: NotRequired[DebugTypedDict]
|
||||
r"""Nucleus sampling parameter (0-1)"""
|
||||
debug: NotRequired[DebugOptionsTypedDict]
|
||||
r"""Debug options for inspecting request transformations (streaming only)"""
|
||||
image_config: NotRequired[Dict[str, ChatGenerationParamsImageConfigTypedDict]]
|
||||
r"""Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details."""
|
||||
modalities: NotRequired[List[Modality]]
|
||||
r"""Output modalities for the response. Supported values are \"text\" and \"image\"."""
|
||||
|
||||
|
||||
class ChatGenerationParams(BaseModel):
|
||||
r"""Chat completion request parameters"""
|
||||
|
||||
messages: List[Message]
|
||||
r"""List of messages for the conversation"""
|
||||
|
||||
provider: OptionalNullable[Schema0] = UNSET
|
||||
provider: OptionalNullable[ChatGenerationParamsProvider] = UNSET
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
|
||||
plugins: Optional[List[Schema17]] = None
|
||||
|
||||
route: Annotated[
|
||||
OptionalNullable[Route], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
plugins: Optional[List[ChatGenerationParamsPluginUnion]] = None
|
||||
r"""Plugins you want to enable for this request, including their settings."""
|
||||
|
||||
user: Optional[str] = None
|
||||
r"""Unique user identifier"""
|
||||
|
||||
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."""
|
||||
|
||||
trace: Optional[ChatGenerationParamsTrace] = None
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
|
||||
model: Optional[str] = None
|
||||
r"""Model to use for completion"""
|
||||
|
||||
models: Optional[List[str]] = None
|
||||
r"""Models to use for completion"""
|
||||
|
||||
frequency_penalty: OptionalNullable[float] = UNSET
|
||||
r"""Frequency penalty (-2.0 to 2.0)"""
|
||||
|
||||
logit_bias: OptionalNullable[Dict[str, float]] = UNSET
|
||||
r"""Token logit bias adjustments"""
|
||||
|
||||
logprobs: OptionalNullable[bool] = UNSET
|
||||
r"""Return log probabilities"""
|
||||
|
||||
top_logprobs: OptionalNullable[float] = UNSET
|
||||
r"""Number of top log probabilities to return (0-20)"""
|
||||
|
||||
max_completion_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Maximum tokens in completion"""
|
||||
|
||||
max_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Maximum tokens (deprecated, use max_completion_tokens)"""
|
||||
|
||||
metadata: Optional[Dict[str, str]] = None
|
||||
r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)"""
|
||||
|
||||
presence_penalty: OptionalNullable[float] = UNSET
|
||||
r"""Presence penalty (-2.0 to 2.0)"""
|
||||
|
||||
reasoning: Optional[Reasoning] = None
|
||||
r"""Configuration options for reasoning models"""
|
||||
|
||||
response_format: Optional[ResponseFormat] = None
|
||||
r"""Response format configuration"""
|
||||
|
||||
seed: OptionalNullable[int] = UNSET
|
||||
r"""Random seed for deterministic outputs"""
|
||||
|
||||
stop: OptionalNullable[Stop] = UNSET
|
||||
r"""Stop sequences (up to 4)"""
|
||||
|
||||
stream: Optional[bool] = False
|
||||
r"""Enable streaming response"""
|
||||
|
||||
stream_options: OptionalNullable[ChatStreamOptions] = UNSET
|
||||
r"""Streaming configuration options"""
|
||||
|
||||
temperature: OptionalNullable[float] = UNSET
|
||||
temperature: OptionalNullable[float] = 1
|
||||
r"""Sampling temperature (0-2)"""
|
||||
|
||||
tool_choice: Optional[Any] = None
|
||||
parallel_tool_calls: OptionalNullable[bool] = UNSET
|
||||
|
||||
tool_choice: Optional[ToolChoiceOption] = None
|
||||
r"""Tool choice configuration"""
|
||||
|
||||
tools: Optional[List[ToolDefinitionJSON]] = None
|
||||
r"""Available tools for function calling"""
|
||||
|
||||
top_p: OptionalNullable[float] = UNSET
|
||||
top_p: OptionalNullable[float] = 1
|
||||
r"""Nucleus sampling parameter (0-1)"""
|
||||
|
||||
debug: Optional[Debug] = None
|
||||
debug: Optional[DebugOptions] = None
|
||||
r"""Debug options for inspecting request transformations (streaming only)"""
|
||||
|
||||
image_config: Optional[Dict[str, ChatGenerationParamsImageConfig]] = None
|
||||
r"""Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details."""
|
||||
|
||||
modalities: Optional[
|
||||
List[Annotated[Modality, PlainValidator(validate_open_enum(False))]]
|
||||
] = None
|
||||
r"""Output modalities for the response. Supported values are \"text\" and \"image\"."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"provider",
|
||||
"plugins",
|
||||
"route",
|
||||
"user",
|
||||
"session_id",
|
||||
"trace",
|
||||
"model",
|
||||
"models",
|
||||
"frequency_penalty",
|
||||
@@ -498,6 +859,7 @@ class ChatGenerationParams(BaseModel):
|
||||
"stream",
|
||||
"stream_options",
|
||||
"temperature",
|
||||
"parallel_tool_calls",
|
||||
"tool_choice",
|
||||
"tools",
|
||||
"top_p",
|
||||
@@ -507,7 +869,6 @@ class ChatGenerationParams(BaseModel):
|
||||
]
|
||||
nullable_fields = [
|
||||
"provider",
|
||||
"route",
|
||||
"frequency_penalty",
|
||||
"logit_bias",
|
||||
"logprobs",
|
||||
@@ -519,6 +880,7 @@ class ChatGenerationParams(BaseModel):
|
||||
"stop",
|
||||
"stream_options",
|
||||
"temperature",
|
||||
"parallel_tool_calls",
|
||||
"top_p",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
@@ -14,20 +14,32 @@ from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class CompletionTokensDetailsTypedDict(TypedDict):
|
||||
r"""Detailed completion token usage"""
|
||||
|
||||
reasoning_tokens: NotRequired[Nullable[float]]
|
||||
r"""Tokens used for reasoning"""
|
||||
audio_tokens: NotRequired[Nullable[float]]
|
||||
r"""Tokens used for audio output"""
|
||||
accepted_prediction_tokens: NotRequired[Nullable[float]]
|
||||
r"""Accepted prediction tokens"""
|
||||
rejected_prediction_tokens: NotRequired[Nullable[float]]
|
||||
r"""Rejected prediction tokens"""
|
||||
|
||||
|
||||
class CompletionTokensDetails(BaseModel):
|
||||
r"""Detailed completion token usage"""
|
||||
|
||||
reasoning_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Tokens used for reasoning"""
|
||||
|
||||
audio_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Tokens used for audio output"""
|
||||
|
||||
accepted_prediction_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Accepted prediction tokens"""
|
||||
|
||||
rejected_prediction_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Rejected prediction tokens"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
@@ -71,40 +83,66 @@ class CompletionTokensDetails(BaseModel):
|
||||
|
||||
|
||||
class PromptTokensDetailsTypedDict(TypedDict):
|
||||
r"""Detailed prompt token usage"""
|
||||
|
||||
cached_tokens: NotRequired[float]
|
||||
r"""Cached prompt tokens"""
|
||||
cache_write_tokens: NotRequired[float]
|
||||
r"""Tokens written to cache. Only returned for models with explicit caching and cache write pricing."""
|
||||
audio_tokens: NotRequired[float]
|
||||
r"""Audio input tokens"""
|
||||
video_tokens: NotRequired[float]
|
||||
r"""Video input tokens"""
|
||||
|
||||
|
||||
class PromptTokensDetails(BaseModel):
|
||||
r"""Detailed prompt token usage"""
|
||||
|
||||
cached_tokens: Optional[float] = None
|
||||
r"""Cached prompt tokens"""
|
||||
|
||||
cache_write_tokens: Optional[float] = None
|
||||
r"""Tokens written to cache. Only returned for models with explicit caching and cache write pricing."""
|
||||
|
||||
audio_tokens: Optional[float] = None
|
||||
r"""Audio input tokens"""
|
||||
|
||||
video_tokens: Optional[float] = None
|
||||
r"""Video input tokens"""
|
||||
|
||||
|
||||
class ChatGenerationTokenUsageTypedDict(TypedDict):
|
||||
r"""Token usage statistics"""
|
||||
|
||||
completion_tokens: float
|
||||
r"""Number of tokens in the completion"""
|
||||
prompt_tokens: float
|
||||
r"""Number of tokens in the prompt"""
|
||||
total_tokens: float
|
||||
r"""Total number of tokens"""
|
||||
completion_tokens_details: NotRequired[Nullable[CompletionTokensDetailsTypedDict]]
|
||||
r"""Detailed completion token usage"""
|
||||
prompt_tokens_details: NotRequired[Nullable[PromptTokensDetailsTypedDict]]
|
||||
r"""Detailed prompt token usage"""
|
||||
|
||||
|
||||
class ChatGenerationTokenUsage(BaseModel):
|
||||
r"""Token usage statistics"""
|
||||
|
||||
completion_tokens: float
|
||||
r"""Number of tokens in the completion"""
|
||||
|
||||
prompt_tokens: float
|
||||
r"""Number of tokens in the prompt"""
|
||||
|
||||
total_tokens: float
|
||||
r"""Total number of tokens"""
|
||||
|
||||
completion_tokens_details: OptionalNullable[CompletionTokensDetails] = UNSET
|
||||
r"""Detailed completion token usage"""
|
||||
|
||||
prompt_tokens_details: OptionalNullable[PromptTokensDetails] = UNSET
|
||||
r"""Detailed prompt token usage"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
|
||||
@@ -17,30 +17,52 @@ from .chatmessagecontentitemvideo import (
|
||||
ChatMessageContentItemVideo,
|
||||
ChatMessageContentItemVideoTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitemvideolegacy import (
|
||||
ChatMessageContentItemVideoLegacy,
|
||||
ChatMessageContentItemVideoLegacyTypedDict,
|
||||
)
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import Union
|
||||
from typing_extensions import Annotated, TypeAliasType
|
||||
|
||||
|
||||
ChatMessageContentItem1TypedDict = TypeAliasType(
|
||||
"ChatMessageContentItem1TypedDict",
|
||||
Union[
|
||||
ChatMessageContentItemVideoLegacyTypedDict, ChatMessageContentItemVideoTypedDict
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
ChatMessageContentItem1 = Annotated[
|
||||
Union[
|
||||
Annotated[ChatMessageContentItemVideoLegacy, Tag("input_video")],
|
||||
Annotated[ChatMessageContentItemVideo, Tag("video_url")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
ChatMessageContentItemTypedDict = TypeAliasType(
|
||||
"ChatMessageContentItemTypedDict",
|
||||
Union[
|
||||
ChatMessageContentItemImageTypedDict,
|
||||
ChatMessageContentItemAudioTypedDict,
|
||||
ChatMessageContentItemTextTypedDict,
|
||||
ChatMessageContentItemVideoTypedDict,
|
||||
ChatMessageContentItem1TypedDict,
|
||||
],
|
||||
)
|
||||
r"""Content part for chat completion messages"""
|
||||
|
||||
|
||||
ChatMessageContentItem = Annotated[
|
||||
ChatMessageContentItem = TypeAliasType(
|
||||
"ChatMessageContentItem",
|
||||
Union[
|
||||
Annotated[ChatMessageContentItemText, Tag("text")],
|
||||
Annotated[ChatMessageContentItemImage, Tag("image_url")],
|
||||
Annotated[ChatMessageContentItemAudio, Tag("input_audio")],
|
||||
Annotated[ChatMessageContentItemVideo, Tag("input_video")],
|
||||
Annotated[ChatMessageContentItemVideo, Tag("video_url")],
|
||||
ChatMessageContentItemImage,
|
||||
ChatMessageContentItemAudio,
|
||||
ChatMessageContentItemText,
|
||||
ChatMessageContentItem1,
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
)
|
||||
r"""Content part for chat completion messages"""
|
||||
|
||||
@@ -2,35 +2,39 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
ChatMessageContentItemAudioType = Literal["input_audio",]
|
||||
|
||||
|
||||
class ChatMessageContentItemAudioInputAudioTypedDict(TypedDict):
|
||||
data: str
|
||||
r"""Base64 encoded audio data"""
|
||||
format_: str
|
||||
r"""Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider."""
|
||||
|
||||
|
||||
class ChatMessageContentItemAudioInputAudio(BaseModel):
|
||||
data: str
|
||||
r"""Base64 encoded audio data"""
|
||||
|
||||
format_: Annotated[str, pydantic.Field(alias="format")]
|
||||
r"""Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider."""
|
||||
|
||||
|
||||
class ChatMessageContentItemAudioTypedDict(TypedDict):
|
||||
r"""Audio input content part. Supported audio formats vary by provider."""
|
||||
|
||||
type: ChatMessageContentItemAudioType
|
||||
input_audio: ChatMessageContentItemAudioInputAudioTypedDict
|
||||
type: Literal["input_audio"]
|
||||
|
||||
|
||||
class ChatMessageContentItemAudio(BaseModel):
|
||||
input_audio: ChatMessageContentItemAudioInputAudio
|
||||
r"""Audio input content part. Supported audio formats vary by provider."""
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["input_audio"], AfterValidator(validate_const("input_audio"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "input_audio"
|
||||
type: ChatMessageContentItemAudioType
|
||||
|
||||
input_audio: ChatMessageContentItemAudioInputAudio
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import validate_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatMessageContentItemCacheControlType = Literal["ephemeral",]
|
||||
|
||||
|
||||
TTL = Union[
|
||||
Literal[
|
||||
"5m",
|
||||
@@ -19,14 +21,15 @@ TTL = Union[
|
||||
|
||||
|
||||
class ChatMessageContentItemCacheControlTypedDict(TypedDict):
|
||||
type: Literal["ephemeral"]
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
type: ChatMessageContentItemCacheControlType
|
||||
ttl: NotRequired[TTL]
|
||||
|
||||
|
||||
class ChatMessageContentItemCacheControl(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["ephemeral"], AfterValidator(validate_const("ephemeral"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "ephemeral"
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
type: ChatMessageContentItemCacheControlType
|
||||
|
||||
ttl: Annotated[Optional[TTL], PlainValidator(validate_open_enum(False))] = None
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import validate_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatMessageContentItemImageType = Literal["image_url",]
|
||||
|
||||
|
||||
ChatMessageContentItemImageDetail = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
@@ -17,31 +19,37 @@ ChatMessageContentItemImageDetail = Union[
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Image detail level for vision models"""
|
||||
|
||||
|
||||
class ChatMessageContentItemImageImageURLTypedDict(TypedDict):
|
||||
url: str
|
||||
r"""URL of the image (data: URLs supported)"""
|
||||
detail: NotRequired[ChatMessageContentItemImageDetail]
|
||||
r"""Image detail level for vision models"""
|
||||
|
||||
|
||||
class ChatMessageContentItemImageImageURL(BaseModel):
|
||||
url: str
|
||||
r"""URL of the image (data: URLs supported)"""
|
||||
|
||||
detail: Annotated[
|
||||
Optional[ChatMessageContentItemImageDetail],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = None
|
||||
r"""Image detail level for vision models"""
|
||||
|
||||
|
||||
class ChatMessageContentItemImageTypedDict(TypedDict):
|
||||
r"""Image content part for vision models"""
|
||||
|
||||
type: ChatMessageContentItemImageType
|
||||
image_url: ChatMessageContentItemImageImageURLTypedDict
|
||||
type: Literal["image_url"]
|
||||
|
||||
|
||||
class ChatMessageContentItemImage(BaseModel):
|
||||
image_url: ChatMessageContentItemImageImageURL
|
||||
r"""Image content part for vision models"""
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["image_url"], AfterValidator(validate_const("image_url"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "image_url"
|
||||
type: ChatMessageContentItemImageType
|
||||
|
||||
image_url: ChatMessageContentItemImageImageURL
|
||||
|
||||
@@ -6,25 +6,28 @@ from .chatmessagecontentitemcachecontrol import (
|
||||
ChatMessageContentItemCacheControlTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatMessageContentItemTextType = Literal["text",]
|
||||
|
||||
|
||||
class ChatMessageContentItemTextTypedDict(TypedDict):
|
||||
r"""Text content part"""
|
||||
|
||||
type: ChatMessageContentItemTextType
|
||||
text: str
|
||||
type: Literal["text"]
|
||||
cache_control: NotRequired[ChatMessageContentItemCacheControlTypedDict]
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
|
||||
class ChatMessageContentItemText(BaseModel):
|
||||
r"""Text content part"""
|
||||
|
||||
type: ChatMessageContentItemTextType
|
||||
|
||||
text: str
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["text"], AfterValidator(validate_const("text"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "text"
|
||||
|
||||
cache_control: Optional[ChatMessageContentItemCacheControl] = None
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
@@ -1,74 +1,27 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .videoinput import VideoInput, VideoInputTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import get_discriminator, validate_const
|
||||
import pydantic
|
||||
from pydantic import Discriminator, Tag
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypeAliasType, TypedDict
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class VideoURL2TypedDict(TypedDict):
|
||||
url: str
|
||||
ChatMessageContentItemVideoType = Literal["video_url",]
|
||||
|
||||
|
||||
class VideoURL2(BaseModel):
|
||||
url: str
|
||||
class ChatMessageContentItemVideoTypedDict(TypedDict):
|
||||
r"""Video input content part"""
|
||||
|
||||
type: ChatMessageContentItemVideoType
|
||||
video_url: VideoInputTypedDict
|
||||
r"""Video input object"""
|
||||
|
||||
|
||||
class ChatMessageContentItemVideoVideoURLTypedDict(TypedDict):
|
||||
video_url: VideoURL2TypedDict
|
||||
type: Literal["video_url"]
|
||||
class ChatMessageContentItemVideo(BaseModel):
|
||||
r"""Video input content part"""
|
||||
|
||||
type: ChatMessageContentItemVideoType
|
||||
|
||||
class ChatMessageContentItemVideoVideoURL(BaseModel):
|
||||
video_url: VideoURL2
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["video_url"], AfterValidator(validate_const("video_url"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "video_url"
|
||||
|
||||
|
||||
class VideoURL1TypedDict(TypedDict):
|
||||
url: str
|
||||
|
||||
|
||||
class VideoURL1(BaseModel):
|
||||
url: str
|
||||
|
||||
|
||||
class ChatMessageContentItemVideoInputVideoTypedDict(TypedDict):
|
||||
video_url: VideoURL1TypedDict
|
||||
type: Literal["input_video"]
|
||||
|
||||
|
||||
class ChatMessageContentItemVideoInputVideo(BaseModel):
|
||||
video_url: VideoURL1
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["input_video"], AfterValidator(validate_const("input_video"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "input_video"
|
||||
|
||||
|
||||
ChatMessageContentItemVideoTypedDict = TypeAliasType(
|
||||
"ChatMessageContentItemVideoTypedDict",
|
||||
Union[
|
||||
ChatMessageContentItemVideoInputVideoTypedDict,
|
||||
ChatMessageContentItemVideoVideoURLTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
ChatMessageContentItemVideo = Annotated[
|
||||
Union[
|
||||
Annotated[ChatMessageContentItemVideoInputVideo, Tag("input_video")],
|
||||
Annotated[ChatMessageContentItemVideoVideoURL, Tag("video_url")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
video_url: VideoInput
|
||||
r"""Video input object"""
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .videoinput import VideoInput, VideoInputTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict, deprecated
|
||||
|
||||
|
||||
ChatMessageContentItemVideoLegacyType = Literal["input_video",]
|
||||
|
||||
|
||||
@deprecated(
|
||||
"warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
||||
)
|
||||
class ChatMessageContentItemVideoLegacyTypedDict(TypedDict):
|
||||
r"""Video input content part (legacy format - deprecated)"""
|
||||
|
||||
type: ChatMessageContentItemVideoLegacyType
|
||||
video_url: VideoInputTypedDict
|
||||
r"""Video input object"""
|
||||
|
||||
|
||||
@deprecated(
|
||||
"warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
||||
)
|
||||
class ChatMessageContentItemVideoLegacy(BaseModel):
|
||||
r"""Video input content part (legacy format - deprecated)"""
|
||||
|
||||
type: ChatMessageContentItemVideoLegacyType
|
||||
|
||||
video_url: VideoInput
|
||||
r"""Video input object"""
|
||||
@@ -53,20 +53,32 @@ class ChatMessageTokenLogprobTopLogprob(BaseModel):
|
||||
|
||||
|
||||
class ChatMessageTokenLogprobTypedDict(TypedDict):
|
||||
r"""Token log probability information"""
|
||||
|
||||
token: str
|
||||
r"""The token"""
|
||||
logprob: float
|
||||
r"""Log probability of the token"""
|
||||
bytes_: Nullable[List[float]]
|
||||
r"""UTF-8 bytes of the token"""
|
||||
top_logprobs: List[ChatMessageTokenLogprobTopLogprobTypedDict]
|
||||
r"""Top alternative tokens with probabilities"""
|
||||
|
||||
|
||||
class ChatMessageTokenLogprob(BaseModel):
|
||||
r"""Token log probability information"""
|
||||
|
||||
token: str
|
||||
r"""The token"""
|
||||
|
||||
logprob: float
|
||||
r"""Log probability of the token"""
|
||||
|
||||
bytes_: Annotated[Nullable[List[float]], pydantic.Field(alias="bytes")]
|
||||
r"""UTF-8 bytes of the token"""
|
||||
|
||||
top_logprobs: List[ChatMessageTokenLogprobTopLogprob]
|
||||
r"""Top alternative tokens with probabilities"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
|
||||
@@ -12,14 +12,22 @@ from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class ChatMessageTokenLogprobsTypedDict(TypedDict):
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
content: Nullable[List[ChatMessageTokenLogprobTypedDict]]
|
||||
r"""Log probabilities for content tokens"""
|
||||
refusal: Nullable[List[ChatMessageTokenLogprobTypedDict]]
|
||||
r"""Log probabilities for refusal tokens"""
|
||||
|
||||
|
||||
class ChatMessageTokenLogprobs(BaseModel):
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
content: Nullable[List[ChatMessageTokenLogprob]]
|
||||
r"""Log probabilities for content tokens"""
|
||||
|
||||
refusal: Nullable[List[ChatMessageTokenLogprob]]
|
||||
r"""Log probabilities for refusal tokens"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
|
||||
@@ -2,36 +2,43 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
ChatMessageToolCallType = Literal["function",]
|
||||
|
||||
|
||||
class ChatMessageToolCallFunctionTypedDict(TypedDict):
|
||||
name: str
|
||||
r"""Function name to call"""
|
||||
arguments: str
|
||||
r"""Function arguments as JSON string"""
|
||||
|
||||
|
||||
class ChatMessageToolCallFunction(BaseModel):
|
||||
name: str
|
||||
r"""Function name to call"""
|
||||
|
||||
arguments: str
|
||||
r"""Function arguments as JSON string"""
|
||||
|
||||
|
||||
class ChatMessageToolCallTypedDict(TypedDict):
|
||||
r"""Tool call made by the assistant"""
|
||||
|
||||
id: str
|
||||
r"""Tool call identifier"""
|
||||
type: ChatMessageToolCallType
|
||||
function: ChatMessageToolCallFunctionTypedDict
|
||||
type: Literal["function"]
|
||||
|
||||
|
||||
class ChatMessageToolCall(BaseModel):
|
||||
r"""Tool call made by the assistant"""
|
||||
|
||||
id: str
|
||||
r"""Tool call identifier"""
|
||||
|
||||
type: ChatMessageToolCallType
|
||||
|
||||
function: ChatMessageToolCallFunction
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["function"], AfterValidator(validate_const("function"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "function"
|
||||
|
||||
@@ -13,44 +13,54 @@ from openrouter.types import (
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatResponseObject = Literal["chat.completion",]
|
||||
|
||||
|
||||
class ChatResponseTypedDict(TypedDict):
|
||||
r"""Chat completion response"""
|
||||
|
||||
id: str
|
||||
r"""Unique completion identifier"""
|
||||
choices: List[ChatResponseChoiceTypedDict]
|
||||
r"""List of completion choices"""
|
||||
created: float
|
||||
r"""Unix timestamp of creation"""
|
||||
model: str
|
||||
object: Literal["chat.completion"]
|
||||
r"""Model used for completion"""
|
||||
object: ChatResponseObject
|
||||
system_fingerprint: NotRequired[Nullable[str]]
|
||||
r"""System fingerprint"""
|
||||
usage: NotRequired[ChatGenerationTokenUsageTypedDict]
|
||||
r"""Token usage statistics"""
|
||||
|
||||
|
||||
class ChatResponse(BaseModel):
|
||||
r"""Chat completion response"""
|
||||
|
||||
id: str
|
||||
r"""Unique completion identifier"""
|
||||
|
||||
choices: List[ChatResponseChoice]
|
||||
r"""List of completion choices"""
|
||||
|
||||
created: float
|
||||
r"""Unix timestamp of creation"""
|
||||
|
||||
model: str
|
||||
r"""Model used for completion"""
|
||||
|
||||
OBJECT: Annotated[
|
||||
Annotated[
|
||||
Literal["chat.completion"],
|
||||
AfterValidator(validate_const("chat.completion")),
|
||||
],
|
||||
pydantic.Field(alias="object"),
|
||||
] = "chat.completion"
|
||||
object: ChatResponseObject
|
||||
|
||||
system_fingerprint: OptionalNullable[str] = UNSET
|
||||
r"""System fingerprint"""
|
||||
|
||||
usage: Optional[ChatGenerationTokenUsage] = None
|
||||
r"""Token usage statistics"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
||||
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||
from .chatmessagetokenlogprobs import (
|
||||
ChatMessageTokenLogprobs,
|
||||
ChatMessageTokenLogprobsTypedDict,
|
||||
@@ -14,29 +13,36 @@ from openrouter.types import (
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
from typing import Any
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatResponseChoiceTypedDict(TypedDict):
|
||||
finish_reason: Nullable[ChatCompletionFinishReason]
|
||||
r"""Chat completion choice"""
|
||||
|
||||
finish_reason: Nullable[Any]
|
||||
index: float
|
||||
r"""Choice index"""
|
||||
message: AssistantMessageTypedDict
|
||||
r"""Assistant message for requests and responses"""
|
||||
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
|
||||
class ChatResponseChoice(BaseModel):
|
||||
finish_reason: Annotated[
|
||||
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
r"""Chat completion choice"""
|
||||
|
||||
finish_reason: Nullable[Any]
|
||||
|
||||
index: float
|
||||
r"""Choice index"""
|
||||
|
||||
message: AssistantMessage
|
||||
r"""Assistant message for requests and responses"""
|
||||
|
||||
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||
from .chatmessagetokenlogprobs import (
|
||||
ChatMessageTokenLogprobs,
|
||||
ChatMessageTokenLogprobsTypedDict,
|
||||
@@ -17,29 +16,36 @@ from openrouter.types import (
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
from typing import Any
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatStreamingChoiceTypedDict(TypedDict):
|
||||
r"""Streaming completion choice chunk"""
|
||||
|
||||
delta: ChatStreamingMessageChunkTypedDict
|
||||
finish_reason: Nullable[ChatCompletionFinishReason]
|
||||
r"""Delta changes in streaming response"""
|
||||
finish_reason: Nullable[Any]
|
||||
index: float
|
||||
r"""Choice index"""
|
||||
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
|
||||
class ChatStreamingChoice(BaseModel):
|
||||
delta: ChatStreamingMessageChunk
|
||||
r"""Streaming completion choice chunk"""
|
||||
|
||||
finish_reason: Annotated[
|
||||
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
delta: ChatStreamingMessageChunk
|
||||
r"""Delta changes in streaming response"""
|
||||
|
||||
finish_reason: Nullable[Any]
|
||||
|
||||
index: float
|
||||
r"""Choice index"""
|
||||
|
||||
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from ._schema19 import Schema19, Schema19TypedDict
|
||||
from .chatstreamingmessagetoolcall import (
|
||||
ChatStreamingMessageToolCall,
|
||||
ChatStreamingMessageToolCallTypedDict,
|
||||
)
|
||||
from .reasoningdetailunion import ReasoningDetailUnion, ReasoningDetailUnionTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -19,29 +19,46 @@ from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatStreamingMessageChunkRole = Literal["assistant",]
|
||||
r"""The role of the message author"""
|
||||
|
||||
|
||||
class ChatStreamingMessageChunkTypedDict(TypedDict):
|
||||
r"""Delta changes in streaming response"""
|
||||
|
||||
role: NotRequired[ChatStreamingMessageChunkRole]
|
||||
r"""The role of the message author"""
|
||||
content: NotRequired[Nullable[str]]
|
||||
r"""Message content delta"""
|
||||
reasoning: NotRequired[Nullable[str]]
|
||||
r"""Reasoning content delta"""
|
||||
refusal: NotRequired[Nullable[str]]
|
||||
r"""Refusal message delta"""
|
||||
tool_calls: NotRequired[List[ChatStreamingMessageToolCallTypedDict]]
|
||||
reasoning_details: NotRequired[List[Schema19TypedDict]]
|
||||
r"""Tool calls delta"""
|
||||
reasoning_details: NotRequired[List[ReasoningDetailUnionTypedDict]]
|
||||
r"""Reasoning details for extended thinking models"""
|
||||
|
||||
|
||||
class ChatStreamingMessageChunk(BaseModel):
|
||||
r"""Delta changes in streaming response"""
|
||||
|
||||
role: Optional[ChatStreamingMessageChunkRole] = None
|
||||
r"""The role of the message author"""
|
||||
|
||||
content: OptionalNullable[str] = UNSET
|
||||
r"""Message content delta"""
|
||||
|
||||
reasoning: OptionalNullable[str] = UNSET
|
||||
r"""Reasoning content delta"""
|
||||
|
||||
refusal: OptionalNullable[str] = UNSET
|
||||
r"""Refusal message delta"""
|
||||
|
||||
tool_calls: Optional[List[ChatStreamingMessageToolCall]] = None
|
||||
r"""Tool calls delta"""
|
||||
|
||||
reasoning_details: Optional[List[Schema19]] = None
|
||||
reasoning_details: Optional[List[ReasoningDetailUnion]] = None
|
||||
r"""Reasoning details for extended thinking models"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
|
||||
@@ -2,41 +2,57 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatStreamingMessageToolCallType = Literal["function",]
|
||||
r"""Tool call type"""
|
||||
|
||||
|
||||
class ChatStreamingMessageToolCallFunctionTypedDict(TypedDict):
|
||||
r"""Function call details"""
|
||||
|
||||
name: NotRequired[str]
|
||||
r"""Function name"""
|
||||
arguments: NotRequired[str]
|
||||
r"""Function arguments as JSON string"""
|
||||
|
||||
|
||||
class ChatStreamingMessageToolCallFunction(BaseModel):
|
||||
r"""Function call details"""
|
||||
|
||||
name: Optional[str] = None
|
||||
r"""Function name"""
|
||||
|
||||
arguments: Optional[str] = None
|
||||
r"""Function arguments as JSON string"""
|
||||
|
||||
|
||||
class ChatStreamingMessageToolCallTypedDict(TypedDict):
|
||||
r"""Tool call delta for streaming responses"""
|
||||
|
||||
index: float
|
||||
r"""Tool call index in the array"""
|
||||
id: NotRequired[str]
|
||||
type: Literal["function"]
|
||||
r"""Tool call identifier"""
|
||||
type: NotRequired[ChatStreamingMessageToolCallType]
|
||||
r"""Tool call type"""
|
||||
function: NotRequired[ChatStreamingMessageToolCallFunctionTypedDict]
|
||||
r"""Function call details"""
|
||||
|
||||
|
||||
class ChatStreamingMessageToolCall(BaseModel):
|
||||
r"""Tool call delta for streaming responses"""
|
||||
|
||||
index: float
|
||||
r"""Tool call index in the array"""
|
||||
|
||||
id: Optional[str] = None
|
||||
r"""Tool call identifier"""
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Optional[Literal["function"]], AfterValidator(validate_const("function"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "function"
|
||||
type: Optional[ChatStreamingMessageToolCallType] = None
|
||||
r"""Tool call type"""
|
||||
|
||||
function: Optional[ChatStreamingMessageToolCallFunction] = None
|
||||
r"""Function call details"""
|
||||
|
||||
@@ -13,58 +13,78 @@ from openrouter.types import (
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatStreamingResponseChunkErrorTypedDict(TypedDict):
|
||||
ChatStreamingResponseChunkObject = Literal["chat.completion.chunk",]
|
||||
|
||||
|
||||
class ErrorTypedDict(TypedDict):
|
||||
r"""Error information"""
|
||||
|
||||
message: str
|
||||
r"""Error message"""
|
||||
code: float
|
||||
r"""Error code"""
|
||||
|
||||
|
||||
class ChatStreamingResponseChunkError(BaseModel):
|
||||
class Error(BaseModel):
|
||||
r"""Error information"""
|
||||
|
||||
message: str
|
||||
r"""Error message"""
|
||||
|
||||
code: float
|
||||
r"""Error code"""
|
||||
|
||||
|
||||
class ChatStreamingResponseChunkDataTypedDict(TypedDict):
|
||||
class ChatStreamingResponseChunkTypedDict(TypedDict):
|
||||
r"""Streaming chat completion chunk"""
|
||||
|
||||
id: str
|
||||
r"""Unique chunk identifier"""
|
||||
choices: List[ChatStreamingChoiceTypedDict]
|
||||
r"""List of streaming chunk choices"""
|
||||
created: float
|
||||
r"""Unix timestamp of creation"""
|
||||
model: str
|
||||
object: Literal["chat.completion.chunk"]
|
||||
r"""Model used for completion"""
|
||||
object: ChatStreamingResponseChunkObject
|
||||
system_fingerprint: NotRequired[Nullable[str]]
|
||||
error: NotRequired[ChatStreamingResponseChunkErrorTypedDict]
|
||||
r"""System fingerprint"""
|
||||
error: NotRequired[ErrorTypedDict]
|
||||
r"""Error information"""
|
||||
usage: NotRequired[ChatGenerationTokenUsageTypedDict]
|
||||
r"""Token usage statistics"""
|
||||
|
||||
|
||||
class ChatStreamingResponseChunkData(BaseModel):
|
||||
class ChatStreamingResponseChunk(BaseModel):
|
||||
r"""Streaming chat completion chunk"""
|
||||
|
||||
id: str
|
||||
r"""Unique chunk identifier"""
|
||||
|
||||
choices: List[ChatStreamingChoice]
|
||||
r"""List of streaming chunk choices"""
|
||||
|
||||
created: float
|
||||
r"""Unix timestamp of creation"""
|
||||
|
||||
model: str
|
||||
r"""Model used for completion"""
|
||||
|
||||
OBJECT: Annotated[
|
||||
Annotated[
|
||||
Literal["chat.completion.chunk"],
|
||||
AfterValidator(validate_const("chat.completion.chunk")),
|
||||
],
|
||||
pydantic.Field(alias="object"),
|
||||
] = "chat.completion.chunk"
|
||||
object: ChatStreamingResponseChunkObject
|
||||
|
||||
system_fingerprint: OptionalNullable[str] = UNSET
|
||||
r"""System fingerprint"""
|
||||
|
||||
error: Optional[ChatStreamingResponseChunkError] = None
|
||||
error: Optional[Error] = None
|
||||
r"""Error information"""
|
||||
|
||||
usage: Optional[ChatGenerationTokenUsage] = None
|
||||
r"""Token usage statistics"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
@@ -95,11 +115,3 @@ class ChatStreamingResponseChunkData(BaseModel):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class ChatStreamingResponseChunkTypedDict(TypedDict):
|
||||
data: ChatStreamingResponseChunkDataTypedDict
|
||||
|
||||
|
||||
class ChatStreamingResponseChunk(BaseModel):
|
||||
data: ChatStreamingResponseChunkData
|
||||
|
||||
@@ -2,13 +2,25 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
import pydantic
|
||||
from typing import Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatStreamOptionsTypedDict(TypedDict):
|
||||
r"""Streaming configuration options"""
|
||||
|
||||
include_usage: NotRequired[bool]
|
||||
r"""Deprecated: This field has no effect. Full usage details are always included."""
|
||||
|
||||
|
||||
class ChatStreamOptions(BaseModel):
|
||||
include_usage: Optional[bool] = None
|
||||
r"""Streaming configuration options"""
|
||||
|
||||
include_usage: Annotated[
|
||||
Optional[bool],
|
||||
pydantic.Field(
|
||||
deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
||||
),
|
||||
] = None
|
||||
r"""Deprecated: This field has no effect. Full usage details are always included."""
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class DebugOptionsTypedDict(TypedDict):
|
||||
r"""Debug options for inspecting request transformations (streaming only)"""
|
||||
|
||||
echo_upstream_body: NotRequired[bool]
|
||||
r"""If true, includes the transformed upstream request body in a debug chunk at the start of the stream. Only works with streaming mode."""
|
||||
|
||||
|
||||
class DebugOptions(BaseModel):
|
||||
r"""Debug options for inspecting request transformations (streaming only)"""
|
||||
|
||||
echo_upstream_body: Optional[bool] = None
|
||||
r"""If true, includes the transformed upstream request body in a debug chunk at the start of the stream. Only works with streaming mode."""
|
||||
@@ -6,36 +6,43 @@ from .chatmessagecontentitemtext import (
|
||||
ChatMessageContentItemTextTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
DeveloperMessageRole = Literal["developer",]
|
||||
|
||||
|
||||
DeveloperMessageContentTypedDict = TypeAliasType(
|
||||
"DeveloperMessageContentTypedDict",
|
||||
Union[str, List[ChatMessageContentItemTextTypedDict]],
|
||||
)
|
||||
r"""Developer message content"""
|
||||
|
||||
|
||||
DeveloperMessageContent = TypeAliasType(
|
||||
"DeveloperMessageContent", Union[str, List[ChatMessageContentItemText]]
|
||||
)
|
||||
r"""Developer message content"""
|
||||
|
||||
|
||||
class DeveloperMessageTypedDict(TypedDict):
|
||||
r"""Developer message"""
|
||||
|
||||
role: DeveloperMessageRole
|
||||
content: DeveloperMessageContentTypedDict
|
||||
role: Literal["developer"]
|
||||
r"""Developer message content"""
|
||||
name: NotRequired[str]
|
||||
r"""Optional name for the developer message"""
|
||||
|
||||
|
||||
class DeveloperMessage(BaseModel):
|
||||
content: DeveloperMessageContent
|
||||
r"""Developer message"""
|
||||
|
||||
ROLE: Annotated[
|
||||
Annotated[Literal["developer"], AfterValidator(validate_const("developer"))],
|
||||
pydantic.Field(alias="role"),
|
||||
] = "developer"
|
||||
role: DeveloperMessageRole
|
||||
|
||||
content: DeveloperMessageContent
|
||||
r"""Developer message content"""
|
||||
|
||||
name: Optional[str] = None
|
||||
r"""Optional name for the developer message"""
|
||||
|
||||
@@ -15,20 +15,34 @@ from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class JSONSchemaConfigTypedDict(TypedDict):
|
||||
r"""JSON Schema configuration object"""
|
||||
|
||||
name: str
|
||||
r"""Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)"""
|
||||
description: NotRequired[str]
|
||||
schema_: NotRequired[Dict[str, Any]]
|
||||
r"""Schema description for the model"""
|
||||
schema_: NotRequired[Dict[str, Nullable[Any]]]
|
||||
r"""JSON Schema object"""
|
||||
strict: NotRequired[Nullable[bool]]
|
||||
r"""Enable strict schema adherence"""
|
||||
|
||||
|
||||
class JSONSchemaConfig(BaseModel):
|
||||
r"""JSON Schema configuration object"""
|
||||
|
||||
name: str
|
||||
r"""Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)"""
|
||||
|
||||
description: Optional[str] = None
|
||||
r"""Schema description for the model"""
|
||||
|
||||
schema_: Annotated[Optional[Dict[str, Any]], pydantic.Field(alias="schema")] = None
|
||||
schema_: Annotated[
|
||||
Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="schema")
|
||||
] = None
|
||||
r"""JSON Schema object"""
|
||||
|
||||
strict: OptionalNullable[bool] = UNSET
|
||||
r"""Enable strict schema adherence"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
|
||||
@@ -22,6 +22,7 @@ MessageTypedDict = TypeAliasType(
|
||||
AssistantMessageTypedDict,
|
||||
],
|
||||
)
|
||||
r"""Chat completion message with role-based discrimination"""
|
||||
|
||||
|
||||
Message = Annotated[
|
||||
@@ -34,3 +35,4 @@ Message = Annotated[
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "role", "role")),
|
||||
]
|
||||
r"""Chat completion message with role-based discrimination"""
|
||||
|
||||
@@ -5,14 +5,14 @@ from openrouter.types import BaseModel
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class ModelsCountResponseDataTypedDict(TypedDict):
|
||||
class DataTypedDict(TypedDict):
|
||||
r"""Model count data"""
|
||||
|
||||
count: float
|
||||
r"""Total number of available models"""
|
||||
|
||||
|
||||
class ModelsCountResponseData(BaseModel):
|
||||
class Data(BaseModel):
|
||||
r"""Model count data"""
|
||||
|
||||
count: float
|
||||
@@ -22,12 +22,12 @@ class ModelsCountResponseData(BaseModel):
|
||||
class ModelsCountResponseTypedDict(TypedDict):
|
||||
r"""Model count data"""
|
||||
|
||||
data: ModelsCountResponseDataTypedDict
|
||||
data: DataTypedDict
|
||||
r"""Model count data"""
|
||||
|
||||
|
||||
class ModelsCountResponse(BaseModel):
|
||||
r"""Model count data"""
|
||||
|
||||
data: ModelsCountResponseData
|
||||
data: Data
|
||||
r"""Model count data"""
|
||||
|
||||
@@ -2,30 +2,33 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
NamedToolChoiceType = Literal["function",]
|
||||
|
||||
|
||||
class NamedToolChoiceFunctionTypedDict(TypedDict):
|
||||
name: str
|
||||
r"""Function name to call"""
|
||||
|
||||
|
||||
class NamedToolChoiceFunction(BaseModel):
|
||||
name: str
|
||||
r"""Function name to call"""
|
||||
|
||||
|
||||
class NamedToolChoiceTypedDict(TypedDict):
|
||||
r"""Named tool choice for specific function"""
|
||||
|
||||
type: NamedToolChoiceType
|
||||
function: NamedToolChoiceFunctionTypedDict
|
||||
type: Literal["function"]
|
||||
|
||||
|
||||
class NamedToolChoice(BaseModel):
|
||||
function: NamedToolChoiceFunction
|
||||
r"""Named tool choice for specific function"""
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["function"], AfterValidator(validate_const("function"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "function"
|
||||
type: NamedToolChoiceType
|
||||
|
||||
function: NamedToolChoiceFunction
|
||||
|
||||
@@ -13,13 +13,12 @@ from openrouter.types import (
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class OpenAIResponsesReasoningConfigTypedDict(TypedDict):
|
||||
effort: NotRequired[Nullable[OpenAIResponsesReasoningEffort]]
|
||||
summary: NotRequired[ReasoningSummaryVerbosity]
|
||||
summary: NotRequired[Nullable[ReasoningSummaryVerbosity]]
|
||||
|
||||
|
||||
class OpenAIResponsesReasoningConfig(BaseModel):
|
||||
@@ -29,13 +28,14 @@ class OpenAIResponsesReasoningConfig(BaseModel):
|
||||
] = UNSET
|
||||
|
||||
summary: Annotated[
|
||||
Optional[ReasoningSummaryVerbosity], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
OptionalNullable[ReasoningSummaryVerbosity],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["effort", "summary"]
|
||||
nullable_fields = ["effort"]
|
||||
nullable_fields = ["effort", "summary"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
@@ -55,7 +55,7 @@ from typing import Any, Dict, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
Object = Literal["response",]
|
||||
OpenResponsesNonStreamingResponseObject = Literal["response",]
|
||||
|
||||
|
||||
OpenResponsesNonStreamingResponseType = Literal["function",]
|
||||
@@ -146,7 +146,7 @@ class OpenResponsesNonStreamingResponseTypedDict(TypedDict):
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
|
||||
id: str
|
||||
object: Object
|
||||
object: OpenResponsesNonStreamingResponseObject
|
||||
created_at: float
|
||||
model: str
|
||||
status: OpenAIResponsesResponseStatus
|
||||
@@ -190,7 +190,7 @@ class OpenResponsesNonStreamingResponse(BaseModel):
|
||||
|
||||
id: str
|
||||
|
||||
object: Object
|
||||
object: OpenResponsesNonStreamingResponseObject
|
||||
|
||||
created_at: float
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class OpenResponsesReasoningTypedDict(TypedDict):
|
||||
type: OpenResponsesReasoningType
|
||||
id: str
|
||||
summary: List[ReasoningSummaryTextTypedDict]
|
||||
content: NotRequired[List[ReasoningTextContentTypedDict]]
|
||||
content: NotRequired[Nullable[List[ReasoningTextContentTypedDict]]]
|
||||
encrypted_content: NotRequired[Nullable[str]]
|
||||
status: NotRequired[OpenResponsesReasoningStatusUnionTypedDict]
|
||||
signature: NotRequired[Nullable[str]]
|
||||
@@ -86,7 +86,7 @@ class OpenResponsesReasoning(BaseModel):
|
||||
|
||||
summary: List[ReasoningSummaryText]
|
||||
|
||||
content: Optional[List[ReasoningTextContent]] = None
|
||||
content: OptionalNullable[List[ReasoningTextContent]] = UNSET
|
||||
|
||||
encrypted_content: OptionalNullable[str] = UNSET
|
||||
|
||||
@@ -111,7 +111,7 @@ class OpenResponsesReasoning(BaseModel):
|
||||
"signature",
|
||||
"format",
|
||||
]
|
||||
nullable_fields = ["encrypted_content", "signature", "format"]
|
||||
nullable_fields = ["content", "encrypted_content", "signature", "format"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
@@ -13,7 +13,6 @@ from openrouter.types import (
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
@@ -21,7 +20,7 @@ class OpenResponsesReasoningConfigTypedDict(TypedDict):
|
||||
r"""Configuration for reasoning mode in the response"""
|
||||
|
||||
effort: NotRequired[Nullable[OpenAIResponsesReasoningEffort]]
|
||||
summary: NotRequired[ReasoningSummaryVerbosity]
|
||||
summary: NotRequired[Nullable[ReasoningSummaryVerbosity]]
|
||||
max_tokens: NotRequired[Nullable[float]]
|
||||
enabled: NotRequired[Nullable[bool]]
|
||||
|
||||
@@ -35,8 +34,9 @@ class OpenResponsesReasoningConfig(BaseModel):
|
||||
] = UNSET
|
||||
|
||||
summary: Annotated[
|
||||
Optional[ReasoningSummaryVerbosity], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
OptionalNullable[ReasoningSummaryVerbosity],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
|
||||
max_tokens: OptionalNullable[float] = UNSET
|
||||
|
||||
@@ -45,7 +45,7 @@ class OpenResponsesReasoningConfig(BaseModel):
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["effort", "summary", "max_tokens", "enabled"]
|
||||
nullable_fields = ["effort", "max_tokens", "enabled"]
|
||||
nullable_fields = ["effort", "summary", "max_tokens", "enabled"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
@@ -55,7 +55,7 @@ from openrouter.types import (
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic import ConfigDict, Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from typing import Any, Dict, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
@@ -244,7 +244,7 @@ class OpenResponsesRequestMaxPrice(BaseModel):
|
||||
request: Optional[str] = None
|
||||
|
||||
|
||||
class ProviderTypedDict(TypedDict):
|
||||
class OpenResponsesRequestProviderTypedDict(TypedDict):
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
|
||||
allow_fallbacks: NotRequired[Nullable[bool]]
|
||||
@@ -283,7 +283,7 @@ class ProviderTypedDict(TypedDict):
|
||||
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."""
|
||||
|
||||
|
||||
class Provider(BaseModel):
|
||||
class OpenResponsesRequestProvider(BaseModel):
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
|
||||
allow_fallbacks: OptionalNullable[bool] = UNSET
|
||||
@@ -395,35 +395,35 @@ class Provider(BaseModel):
|
||||
return m
|
||||
|
||||
|
||||
IDResponseHealing = Literal["response-healing",]
|
||||
OpenResponsesRequestIDResponseHealing = Literal["response-healing",]
|
||||
|
||||
|
||||
class PluginResponseHealingTypedDict(TypedDict):
|
||||
id: IDResponseHealing
|
||||
class OpenResponsesRequestPluginResponseHealingTypedDict(TypedDict):
|
||||
id: OpenResponsesRequestIDResponseHealing
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the response-healing plugin for this request. Defaults to true."""
|
||||
|
||||
|
||||
class PluginResponseHealing(BaseModel):
|
||||
id: IDResponseHealing
|
||||
class OpenResponsesRequestPluginResponseHealing(BaseModel):
|
||||
id: OpenResponsesRequestIDResponseHealing
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the response-healing plugin for this request. Defaults to true."""
|
||||
|
||||
|
||||
IDFileParser = Literal["file-parser",]
|
||||
OpenResponsesRequestIDFileParser = Literal["file-parser",]
|
||||
|
||||
|
||||
class PluginFileParserTypedDict(TypedDict):
|
||||
id: IDFileParser
|
||||
class OpenResponsesRequestPluginFileParserTypedDict(TypedDict):
|
||||
id: OpenResponsesRequestIDFileParser
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the file-parser plugin for this request. Defaults to true."""
|
||||
pdf: NotRequired[PDFParserOptionsTypedDict]
|
||||
r"""Options for PDF parsing."""
|
||||
|
||||
|
||||
class PluginFileParser(BaseModel):
|
||||
id: IDFileParser
|
||||
class OpenResponsesRequestPluginFileParser(BaseModel):
|
||||
id: OpenResponsesRequestIDFileParser
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the file-parser plugin for this request. Defaults to true."""
|
||||
@@ -432,11 +432,11 @@ class PluginFileParser(BaseModel):
|
||||
r"""Options for PDF parsing."""
|
||||
|
||||
|
||||
IDWeb = Literal["web",]
|
||||
OpenResponsesRequestIDWeb = Literal["web",]
|
||||
|
||||
|
||||
class PluginWebTypedDict(TypedDict):
|
||||
id: IDWeb
|
||||
class OpenResponsesRequestPluginWebTypedDict(TypedDict):
|
||||
id: OpenResponsesRequestIDWeb
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the web-search plugin for this request. Defaults to true."""
|
||||
max_results: NotRequired[float]
|
||||
@@ -445,8 +445,8 @@ class PluginWebTypedDict(TypedDict):
|
||||
r"""The search engine to use for web search."""
|
||||
|
||||
|
||||
class PluginWeb(BaseModel):
|
||||
id: IDWeb
|
||||
class OpenResponsesRequestPluginWeb(BaseModel):
|
||||
id: OpenResponsesRequestIDWeb
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the web-search plugin for this request. Defaults to true."""
|
||||
@@ -461,30 +461,30 @@ class PluginWeb(BaseModel):
|
||||
r"""The search engine to use for web search."""
|
||||
|
||||
|
||||
IDModeration = Literal["moderation",]
|
||||
OpenResponsesRequestIDModeration = Literal["moderation",]
|
||||
|
||||
|
||||
class PluginModerationTypedDict(TypedDict):
|
||||
id: IDModeration
|
||||
class OpenResponsesRequestPluginModerationTypedDict(TypedDict):
|
||||
id: OpenResponsesRequestIDModeration
|
||||
|
||||
|
||||
class PluginModeration(BaseModel):
|
||||
id: IDModeration
|
||||
class OpenResponsesRequestPluginModeration(BaseModel):
|
||||
id: OpenResponsesRequestIDModeration
|
||||
|
||||
|
||||
IDAutoRouter = Literal["auto-router",]
|
||||
OpenResponsesRequestIDAutoRouter = Literal["auto-router",]
|
||||
|
||||
|
||||
class PluginAutoRouterTypedDict(TypedDict):
|
||||
id: IDAutoRouter
|
||||
class OpenResponsesRequestPluginAutoRouterTypedDict(TypedDict):
|
||||
id: OpenResponsesRequestIDAutoRouter
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
|
||||
allowed_models: NotRequired[List[str]]
|
||||
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
|
||||
|
||||
|
||||
class PluginAutoRouter(BaseModel):
|
||||
id: IDAutoRouter
|
||||
class OpenResponsesRequestPluginAutoRouter(BaseModel):
|
||||
id: OpenResponsesRequestIDAutoRouter
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
|
||||
@@ -493,30 +493,67 @@ class PluginAutoRouter(BaseModel):
|
||||
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
|
||||
|
||||
|
||||
PluginTypedDict = TypeAliasType(
|
||||
"PluginTypedDict",
|
||||
OpenResponsesRequestPluginUnionTypedDict = TypeAliasType(
|
||||
"OpenResponsesRequestPluginUnionTypedDict",
|
||||
Union[
|
||||
PluginModerationTypedDict,
|
||||
PluginResponseHealingTypedDict,
|
||||
PluginAutoRouterTypedDict,
|
||||
PluginFileParserTypedDict,
|
||||
PluginWebTypedDict,
|
||||
OpenResponsesRequestPluginModerationTypedDict,
|
||||
OpenResponsesRequestPluginResponseHealingTypedDict,
|
||||
OpenResponsesRequestPluginAutoRouterTypedDict,
|
||||
OpenResponsesRequestPluginFileParserTypedDict,
|
||||
OpenResponsesRequestPluginWebTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Plugin = Annotated[
|
||||
OpenResponsesRequestPluginUnion = Annotated[
|
||||
Union[
|
||||
Annotated[PluginAutoRouter, Tag("auto-router")],
|
||||
Annotated[PluginModeration, Tag("moderation")],
|
||||
Annotated[PluginWeb, Tag("web")],
|
||||
Annotated[PluginFileParser, Tag("file-parser")],
|
||||
Annotated[PluginResponseHealing, Tag("response-healing")],
|
||||
Annotated[OpenResponsesRequestPluginAutoRouter, Tag("auto-router")],
|
||||
Annotated[OpenResponsesRequestPluginModeration, Tag("moderation")],
|
||||
Annotated[OpenResponsesRequestPluginWeb, Tag("web")],
|
||||
Annotated[OpenResponsesRequestPluginFileParser, Tag("file-parser")],
|
||||
Annotated[OpenResponsesRequestPluginResponseHealing, Tag("response-healing")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "id", "id")),
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesRequestTraceTypedDict(TypedDict):
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
|
||||
trace_id: NotRequired[str]
|
||||
trace_name: NotRequired[str]
|
||||
span_name: NotRequired[str]
|
||||
generation_name: NotRequired[str]
|
||||
parent_span_id: NotRequired[str]
|
||||
|
||||
|
||||
class OpenResponsesRequestTrace(BaseModel):
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
|
||||
)
|
||||
__pydantic_extra__: Dict[str, Nullable[Any]] = pydantic.Field(init=False)
|
||||
|
||||
trace_id: Optional[str] = None
|
||||
|
||||
trace_name: Optional[str] = None
|
||||
|
||||
span_name: Optional[str] = None
|
||||
|
||||
generation_name: Optional[str] = None
|
||||
|
||||
parent_span_id: Optional[str] = None
|
||||
|
||||
@property
|
||||
def additional_properties(self):
|
||||
return self.__pydantic_extra__
|
||||
|
||||
@additional_properties.setter
|
||||
def additional_properties(self, value):
|
||||
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
|
||||
|
||||
|
||||
class OpenResponsesRequestTypedDict(TypedDict):
|
||||
r"""Request schema for Responses endpoint"""
|
||||
|
||||
@@ -556,14 +593,16 @@ class OpenResponsesRequestTypedDict(TypedDict):
|
||||
service_tier: NotRequired[ServiceTier]
|
||||
truncation: NotRequired[Nullable[Truncation]]
|
||||
stream: NotRequired[bool]
|
||||
provider: NotRequired[Nullable[ProviderTypedDict]]
|
||||
provider: NotRequired[Nullable[OpenResponsesRequestProviderTypedDict]]
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
plugins: NotRequired[List[PluginTypedDict]]
|
||||
plugins: NotRequired[List[OpenResponsesRequestPluginUnionTypedDict]]
|
||||
r"""Plugins you want to enable for this request, including their settings."""
|
||||
user: NotRequired[str]
|
||||
r"""A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters."""
|
||||
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."""
|
||||
trace: NotRequired[OpenResponsesRequestTraceTypedDict]
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
|
||||
|
||||
class OpenResponsesRequest(BaseModel):
|
||||
@@ -652,10 +691,10 @@ class OpenResponsesRequest(BaseModel):
|
||||
|
||||
stream: Optional[bool] = False
|
||||
|
||||
provider: OptionalNullable[Provider] = UNSET
|
||||
provider: OptionalNullable[OpenResponsesRequestProvider] = UNSET
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
|
||||
plugins: Optional[List[Plugin]] = None
|
||||
plugins: Optional[List[OpenResponsesRequestPluginUnion]] = None
|
||||
r"""Plugins you want to enable for this request, including their settings."""
|
||||
|
||||
user: Optional[str] = None
|
||||
@@ -664,6 +703,9 @@ class OpenResponsesRequest(BaseModel):
|
||||
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."""
|
||||
|
||||
trace: Optional[OpenResponsesRequestTrace] = None
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
@@ -701,6 +743,7 @@ class OpenResponsesRequest(BaseModel):
|
||||
"plugins",
|
||||
"user",
|
||||
"session_id",
|
||||
"trace",
|
||||
]
|
||||
nullable_fields = [
|
||||
"instructions",
|
||||
|
||||
@@ -41,7 +41,9 @@ ProviderName = Union[
|
||||
"Inception",
|
||||
"Inceptron",
|
||||
"InferenceNet",
|
||||
"Ionstream",
|
||||
"Infermatic",
|
||||
"Io Net",
|
||||
"Inflection",
|
||||
"Liquid",
|
||||
"Mara",
|
||||
|
||||
@@ -8,7 +8,6 @@ from .preferredminthroughput import (
|
||||
PreferredMinThroughputTypedDict,
|
||||
)
|
||||
from .providername import ProviderName
|
||||
from .providersort import ProviderSort
|
||||
from .quantization import Quantization
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
@@ -58,7 +57,7 @@ ProviderPreferencesIgnore = TypeAliasType(
|
||||
)
|
||||
|
||||
|
||||
SortEnum = Union[
|
||||
ProviderPreferencesSortEnum = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
@@ -68,13 +67,24 @@ SortEnum = Union[
|
||||
]
|
||||
|
||||
|
||||
ProviderSortConfigEnum = Literal[
|
||||
ProviderPreferencesProviderSortConfigEnum = Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
]
|
||||
|
||||
|
||||
ProviderPreferencesBy = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
|
||||
ProviderPreferencesPartition = Union[
|
||||
Literal[
|
||||
"model",
|
||||
@@ -82,22 +92,28 @@ ProviderPreferencesPartition = Union[
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
|
||||
class ProviderPreferencesProviderSortConfigTypedDict(TypedDict):
|
||||
by: NotRequired[Nullable[ProviderSort]]
|
||||
by: NotRequired[Nullable[ProviderPreferencesBy]]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
partition: NotRequired[Nullable[ProviderPreferencesPartition]]
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
|
||||
class ProviderPreferencesProviderSortConfig(BaseModel):
|
||||
by: Annotated[
|
||||
OptionalNullable[ProviderSort], PlainValidator(validate_open_enum(False))
|
||||
OptionalNullable[ProviderPreferencesBy],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
partition: Annotated[
|
||||
OptionalNullable[ProviderPreferencesPartition],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
@@ -130,15 +146,20 @@ class ProviderPreferencesProviderSortConfig(BaseModel):
|
||||
return m
|
||||
|
||||
|
||||
ProviderSortConfigUnionTypedDict = TypeAliasType(
|
||||
"ProviderSortConfigUnionTypedDict",
|
||||
Union[ProviderPreferencesProviderSortConfigTypedDict, ProviderSortConfigEnum],
|
||||
ProviderPreferencesProviderSortConfigUnionTypedDict = TypeAliasType(
|
||||
"ProviderPreferencesProviderSortConfigUnionTypedDict",
|
||||
Union[
|
||||
ProviderPreferencesProviderSortConfigTypedDict,
|
||||
ProviderPreferencesProviderSortConfigEnum,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
ProviderSortConfigUnion = TypeAliasType(
|
||||
"ProviderSortConfigUnion",
|
||||
Union[ProviderPreferencesProviderSortConfig, ProviderSortConfigEnum],
|
||||
ProviderPreferencesProviderSortConfigUnion = TypeAliasType(
|
||||
"ProviderPreferencesProviderSortConfigUnion",
|
||||
Union[
|
||||
ProviderPreferencesProviderSortConfig, ProviderPreferencesProviderSortConfigEnum
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -150,11 +171,16 @@ ProviderPreferencesProviderSort = Union[
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
|
||||
ProviderPreferencesSortUnionTypedDict = TypeAliasType(
|
||||
"ProviderPreferencesSortUnionTypedDict",
|
||||
Union[ProviderPreferencesProviderSort, ProviderSortConfigUnionTypedDict, SortEnum],
|
||||
Union[
|
||||
ProviderPreferencesProviderSort,
|
||||
ProviderPreferencesProviderSortConfigUnionTypedDict,
|
||||
ProviderPreferencesSortEnum,
|
||||
],
|
||||
)
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
@@ -165,8 +191,10 @@ ProviderPreferencesSortUnion = TypeAliasType(
|
||||
Annotated[
|
||||
ProviderPreferencesProviderSort, PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
ProviderSortConfigUnion,
|
||||
Annotated[SortEnum, PlainValidator(validate_open_enum(False))],
|
||||
ProviderPreferencesProviderSortConfigUnion,
|
||||
Annotated[
|
||||
ProviderPreferencesSortEnum, PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
],
|
||||
)
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
@@ -13,3 +13,4 @@ ProviderSort = Union[
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .providersort import ProviderSort
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -17,6 +16,17 @@ from typing import Literal, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
By = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
|
||||
Partition = Union[
|
||||
Literal[
|
||||
"model",
|
||||
@@ -24,21 +34,30 @@ Partition = Union[
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
|
||||
class ProviderSortConfigTypedDict(TypedDict):
|
||||
by: NotRequired[Nullable[ProviderSort]]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
by: NotRequired[Nullable[By]]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
partition: NotRequired[Nullable[Partition]]
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
|
||||
class ProviderSortConfig(BaseModel):
|
||||
by: Annotated[
|
||||
OptionalNullable[ProviderSort], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
by: Annotated[OptionalNullable[By], PlainValidator(validate_open_enum(False))] = (
|
||||
UNSET
|
||||
)
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
partition: Annotated[
|
||||
OptionalNullable[Partition], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .providersort import ProviderSort
|
||||
from .providersortconfig import ProviderSortConfig, ProviderSortConfigTypedDict
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Union
|
||||
from typing_extensions import Annotated, TypeAliasType
|
||||
|
||||
|
||||
ProviderSortUnionTypedDict = TypeAliasType(
|
||||
"ProviderSortUnionTypedDict", Union[ProviderSortConfigTypedDict, ProviderSort]
|
||||
)
|
||||
|
||||
|
||||
ProviderSortUnion = TypeAliasType(
|
||||
"ProviderSortUnion",
|
||||
Union[
|
||||
ProviderSortConfig,
|
||||
Annotated[ProviderSort, PlainValidator(validate_open_enum(False))],
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,93 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
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
|
||||
|
||||
|
||||
ReasoningDetailEncryptedType = Literal["reasoning.encrypted",]
|
||||
|
||||
|
||||
ReasoningDetailEncryptedFormat = Union[
|
||||
Literal[
|
||||
"unknown",
|
||||
"openai-responses-v1",
|
||||
"azure-openai-responses-v1",
|
||||
"xai-responses-v1",
|
||||
"anthropic-claude-v1",
|
||||
"google-gemini-v1",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ReasoningDetailEncryptedTypedDict(TypedDict):
|
||||
r"""Reasoning detail encrypted schema"""
|
||||
|
||||
type: ReasoningDetailEncryptedType
|
||||
data: str
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[ReasoningDetailEncryptedFormat]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class ReasoningDetailEncrypted(BaseModel):
|
||||
r"""Reasoning detail encrypted schema"""
|
||||
|
||||
type: ReasoningDetailEncryptedType
|
||||
|
||||
data: str
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[ReasoningDetailEncryptedFormat],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["id", "format", "index"]
|
||||
nullable_fields = ["id", "format"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,93 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
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
|
||||
|
||||
|
||||
ReasoningDetailSummaryType = Literal["reasoning.summary",]
|
||||
|
||||
|
||||
ReasoningDetailSummaryFormat = Union[
|
||||
Literal[
|
||||
"unknown",
|
||||
"openai-responses-v1",
|
||||
"azure-openai-responses-v1",
|
||||
"xai-responses-v1",
|
||||
"anthropic-claude-v1",
|
||||
"google-gemini-v1",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ReasoningDetailSummaryTypedDict(TypedDict):
|
||||
r"""Reasoning detail summary schema"""
|
||||
|
||||
type: ReasoningDetailSummaryType
|
||||
summary: str
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[ReasoningDetailSummaryFormat]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class ReasoningDetailSummary(BaseModel):
|
||||
r"""Reasoning detail summary schema"""
|
||||
|
||||
type: ReasoningDetailSummaryType
|
||||
|
||||
summary: str
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[ReasoningDetailSummaryFormat],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["id", "format", "index"]
|
||||
nullable_fields = ["id", "format"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,96 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
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
|
||||
|
||||
|
||||
ReasoningDetailTextType = Literal["reasoning.text",]
|
||||
|
||||
|
||||
ReasoningDetailTextFormat = Union[
|
||||
Literal[
|
||||
"unknown",
|
||||
"openai-responses-v1",
|
||||
"azure-openai-responses-v1",
|
||||
"xai-responses-v1",
|
||||
"anthropic-claude-v1",
|
||||
"google-gemini-v1",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ReasoningDetailTextTypedDict(TypedDict):
|
||||
r"""Reasoning detail text schema"""
|
||||
|
||||
type: ReasoningDetailTextType
|
||||
text: NotRequired[Nullable[str]]
|
||||
signature: NotRequired[Nullable[str]]
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[ReasoningDetailTextFormat]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class ReasoningDetailText(BaseModel):
|
||||
r"""Reasoning detail text schema"""
|
||||
|
||||
type: ReasoningDetailTextType
|
||||
|
||||
text: OptionalNullable[str] = UNSET
|
||||
|
||||
signature: OptionalNullable[str] = UNSET
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[ReasoningDetailTextFormat],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["text", "signature", "id", "format", "index"]
|
||||
nullable_fields = ["text", "signature", "id", "format"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .reasoningdetailencrypted import (
|
||||
ReasoningDetailEncrypted,
|
||||
ReasoningDetailEncryptedTypedDict,
|
||||
)
|
||||
from .reasoningdetailsummary import (
|
||||
ReasoningDetailSummary,
|
||||
ReasoningDetailSummaryTypedDict,
|
||||
)
|
||||
from .reasoningdetailtext import ReasoningDetailText, ReasoningDetailTextTypedDict
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import Union
|
||||
from typing_extensions import Annotated, TypeAliasType
|
||||
|
||||
|
||||
ReasoningDetailUnionTypedDict = TypeAliasType(
|
||||
"ReasoningDetailUnionTypedDict",
|
||||
Union[
|
||||
ReasoningDetailSummaryTypedDict,
|
||||
ReasoningDetailEncryptedTypedDict,
|
||||
ReasoningDetailTextTypedDict,
|
||||
],
|
||||
)
|
||||
r"""Reasoning detail union schema"""
|
||||
|
||||
|
||||
ReasoningDetailUnion = Annotated[
|
||||
Union[
|
||||
Annotated[ReasoningDetailSummary, Tag("reasoning.summary")],
|
||||
Annotated[ReasoningDetailEncrypted, Tag("reasoning.encrypted")],
|
||||
Annotated[ReasoningDetailText, Tag("reasoning.text")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
r"""Reasoning detail union schema"""
|
||||
+5
-5
@@ -6,16 +6,16 @@ from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
ResponsesFormatJSONObjectType = Literal["json_object",]
|
||||
ResponseFormatJSONObjectType = Literal["json_object",]
|
||||
|
||||
|
||||
class ResponsesFormatJSONObjectTypedDict(TypedDict):
|
||||
class ResponseFormatJSONObjectTypedDict(TypedDict):
|
||||
r"""JSON object response format"""
|
||||
|
||||
type: ResponsesFormatJSONObjectType
|
||||
type: ResponseFormatJSONObjectType
|
||||
|
||||
|
||||
class ResponsesFormatJSONObject(BaseModel):
|
||||
class ResponseFormatJSONObject(BaseModel):
|
||||
r"""JSON object response format"""
|
||||
|
||||
type: ResponsesFormatJSONObjectType
|
||||
type: ResponseFormatJSONObjectType
|
||||
@@ -3,24 +3,25 @@
|
||||
from __future__ import annotations
|
||||
from .jsonschemaconfig import JSONSchemaConfig, JSONSchemaConfigTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
ResponseFormatJSONSchemaType = Literal["json_schema",]
|
||||
|
||||
|
||||
class ResponseFormatJSONSchemaTypedDict(TypedDict):
|
||||
r"""JSON Schema response format for structured outputs"""
|
||||
|
||||
type: ResponseFormatJSONSchemaType
|
||||
json_schema: JSONSchemaConfigTypedDict
|
||||
type: Literal["json_schema"]
|
||||
r"""JSON Schema configuration object"""
|
||||
|
||||
|
||||
class ResponseFormatJSONSchema(BaseModel):
|
||||
json_schema: JSONSchemaConfig
|
||||
r"""JSON Schema response format for structured outputs"""
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["json_schema"], AfterValidator(validate_const("json_schema"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "json_schema"
|
||||
type: ResponseFormatJSONSchemaType
|
||||
|
||||
json_schema: JSONSchemaConfig
|
||||
r"""JSON Schema configuration object"""
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
ResponseFormatTextType = Literal["text",]
|
||||
|
||||
|
||||
class ResponseFormatTextTypedDict(TypedDict):
|
||||
r"""Default text response format"""
|
||||
|
||||
type: ResponseFormatTextType
|
||||
|
||||
|
||||
class ResponseFormatText(BaseModel):
|
||||
r"""Default text response format"""
|
||||
|
||||
type: ResponseFormatTextType
|
||||
@@ -1,9 +1,9 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .responsesformatjsonobject import (
|
||||
ResponsesFormatJSONObject,
|
||||
ResponsesFormatJSONObjectTypedDict,
|
||||
from .responseformatjsonobject import (
|
||||
ResponseFormatJSONObject,
|
||||
ResponseFormatJSONObjectTypedDict,
|
||||
)
|
||||
from .responsesformattext import ResponsesFormatText, ResponsesFormatTextTypedDict
|
||||
from .responsesformattextjsonschemaconfig import (
|
||||
@@ -20,7 +20,7 @@ ResponseFormatTextConfigTypedDict = TypeAliasType(
|
||||
"ResponseFormatTextConfigTypedDict",
|
||||
Union[
|
||||
ResponsesFormatTextTypedDict,
|
||||
ResponsesFormatJSONObjectTypedDict,
|
||||
ResponseFormatJSONObjectTypedDict,
|
||||
ResponsesFormatTextJSONSchemaConfigTypedDict,
|
||||
],
|
||||
)
|
||||
@@ -30,7 +30,7 @@ r"""Text response format configuration"""
|
||||
ResponseFormatTextConfig = Annotated[
|
||||
Union[
|
||||
Annotated[ResponsesFormatText, Tag("text")],
|
||||
Annotated[ResponsesFormatJSONObject, Tag("json_object")],
|
||||
Annotated[ResponseFormatJSONObject, Tag("json_object")],
|
||||
Annotated[ResponsesFormatTextJSONSchemaConfig, Tag("json_schema")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
|
||||
@@ -2,22 +2,25 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
ResponseFormatTextGrammarType = Literal["grammar",]
|
||||
|
||||
|
||||
class ResponseFormatTextGrammarTypedDict(TypedDict):
|
||||
r"""Custom grammar response format"""
|
||||
|
||||
type: ResponseFormatTextGrammarType
|
||||
grammar: str
|
||||
type: Literal["grammar"]
|
||||
r"""Custom grammar for text generation"""
|
||||
|
||||
|
||||
class ResponseFormatTextGrammar(BaseModel):
|
||||
grammar: str
|
||||
r"""Custom grammar response format"""
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["grammar"], AfterValidator(validate_const("grammar"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "grammar"
|
||||
type: ResponseFormatTextGrammarType
|
||||
|
||||
grammar: str
|
||||
r"""Custom grammar for text generation"""
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
ResponseFormatTextPythonType = Literal["python",]
|
||||
|
||||
|
||||
class ResponseFormatTextPythonTypedDict(TypedDict):
|
||||
r"""Python code response format"""
|
||||
|
||||
type: ResponseFormatTextPythonType
|
||||
|
||||
|
||||
class ResponseFormatTextPython(BaseModel):
|
||||
r"""Python code response format"""
|
||||
|
||||
type: ResponseFormatTextPythonType
|
||||
@@ -8,7 +8,7 @@ from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
CodeEnum = Union[
|
||||
Code = Union[
|
||||
Literal[
|
||||
"server_error",
|
||||
"rate_limit_exceeded",
|
||||
@@ -36,13 +36,13 @@ CodeEnum = Union[
|
||||
class ResponsesErrorFieldTypedDict(TypedDict):
|
||||
r"""Error information returned from the API"""
|
||||
|
||||
code: CodeEnum
|
||||
code: Code
|
||||
message: str
|
||||
|
||||
|
||||
class ResponsesErrorField(BaseModel):
|
||||
r"""Error information returned from the API"""
|
||||
|
||||
code: Annotated[CodeEnum, PlainValidator(validate_open_enum(False))]
|
||||
code: Annotated[Code, PlainValidator(validate_open_enum(False))]
|
||||
|
||||
message: str
|
||||
|
||||
@@ -71,7 +71,7 @@ class ResponsesOutputItemReasoningTypedDict(TypedDict):
|
||||
type: ResponsesOutputItemReasoningType
|
||||
id: str
|
||||
summary: List[ReasoningSummaryTextTypedDict]
|
||||
content: NotRequired[List[ReasoningTextContentTypedDict]]
|
||||
content: NotRequired[Nullable[List[ReasoningTextContentTypedDict]]]
|
||||
encrypted_content: NotRequired[Nullable[str]]
|
||||
status: NotRequired[ResponsesOutputItemReasoningStatusUnionTypedDict]
|
||||
signature: NotRequired[Nullable[str]]
|
||||
@@ -89,7 +89,7 @@ class ResponsesOutputItemReasoning(BaseModel):
|
||||
|
||||
summary: List[ReasoningSummaryText]
|
||||
|
||||
content: Optional[List[ReasoningTextContent]] = None
|
||||
content: OptionalNullable[List[ReasoningTextContent]] = UNSET
|
||||
|
||||
encrypted_content: OptionalNullable[str] = UNSET
|
||||
|
||||
@@ -116,7 +116,7 @@ class ResponsesOutputItemReasoning(BaseModel):
|
||||
"signature",
|
||||
"format",
|
||||
]
|
||||
nullable_fields = ["encrypted_content", "signature", "format"]
|
||||
nullable_fields = ["content", "encrypted_content", "signature", "format"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
@@ -6,36 +6,43 @@ from .chatmessagecontentitemtext import (
|
||||
ChatMessageContentItemTextTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
SystemMessageRole = Literal["system",]
|
||||
|
||||
|
||||
SystemMessageContentTypedDict = TypeAliasType(
|
||||
"SystemMessageContentTypedDict",
|
||||
Union[str, List[ChatMessageContentItemTextTypedDict]],
|
||||
)
|
||||
r"""System message content"""
|
||||
|
||||
|
||||
SystemMessageContent = TypeAliasType(
|
||||
"SystemMessageContent", Union[str, List[ChatMessageContentItemText]]
|
||||
)
|
||||
r"""System message content"""
|
||||
|
||||
|
||||
class SystemMessageTypedDict(TypedDict):
|
||||
r"""System message for setting behavior"""
|
||||
|
||||
role: SystemMessageRole
|
||||
content: SystemMessageContentTypedDict
|
||||
role: Literal["system"]
|
||||
r"""System message content"""
|
||||
name: NotRequired[str]
|
||||
r"""Optional name for the system message"""
|
||||
|
||||
|
||||
class SystemMessage(BaseModel):
|
||||
content: SystemMessageContent
|
||||
r"""System message for setting behavior"""
|
||||
|
||||
ROLE: Annotated[
|
||||
Annotated[Literal["system"], AfterValidator(validate_const("system"))],
|
||||
pydantic.Field(alias="role"),
|
||||
] = "system"
|
||||
role: SystemMessageRole
|
||||
|
||||
content: SystemMessageContent
|
||||
r"""System message content"""
|
||||
|
||||
name: Optional[str] = None
|
||||
r"""Optional name for the system message"""
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .namedtoolchoice import NamedToolChoice, NamedToolChoiceTypedDict
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import TypeAliasType
|
||||
|
||||
|
||||
ToolChoiceOptionRequired = Literal["required",]
|
||||
|
||||
|
||||
ToolChoiceOptionAuto = Literal["auto",]
|
||||
|
||||
|
||||
ToolChoiceOptionNone = Literal["none",]
|
||||
|
||||
|
||||
ToolChoiceOptionTypedDict = TypeAliasType(
|
||||
"ToolChoiceOptionTypedDict",
|
||||
Union[
|
||||
NamedToolChoiceTypedDict,
|
||||
ToolChoiceOptionNone,
|
||||
ToolChoiceOptionAuto,
|
||||
ToolChoiceOptionRequired,
|
||||
],
|
||||
)
|
||||
r"""Tool choice configuration"""
|
||||
|
||||
|
||||
ToolChoiceOption = TypeAliasType(
|
||||
"ToolChoiceOption",
|
||||
Union[
|
||||
NamedToolChoice,
|
||||
ToolChoiceOptionNone,
|
||||
ToolChoiceOptionAuto,
|
||||
ToolChoiceOptionRequired,
|
||||
],
|
||||
)
|
||||
r"""Tool choice configuration"""
|
||||
@@ -1,6 +1,10 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatmessagecontentitemcachecontrol import (
|
||||
ChatMessageContentItemCacheControl,
|
||||
ChatMessageContentItemCacheControlTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -8,29 +12,41 @@ from openrouter.types import (
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Any, Dict, Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ToolDefinitionJSONType = Literal["function",]
|
||||
|
||||
|
||||
class ToolDefinitionJSONFunctionTypedDict(TypedDict):
|
||||
r"""Function definition for tool calling"""
|
||||
|
||||
name: str
|
||||
r"""Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)"""
|
||||
description: NotRequired[str]
|
||||
parameters: NotRequired[Dict[str, Any]]
|
||||
r"""Function description for the model"""
|
||||
parameters: NotRequired[Dict[str, Nullable[Any]]]
|
||||
r"""Function parameters as JSON Schema object"""
|
||||
strict: NotRequired[Nullable[bool]]
|
||||
r"""Enable strict schema adherence"""
|
||||
|
||||
|
||||
class ToolDefinitionJSONFunction(BaseModel):
|
||||
r"""Function definition for tool calling"""
|
||||
|
||||
name: str
|
||||
r"""Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)"""
|
||||
|
||||
description: Optional[str] = None
|
||||
r"""Function description for the model"""
|
||||
|
||||
parameters: Optional[Dict[str, Any]] = None
|
||||
parameters: Optional[Dict[str, Nullable[Any]]] = None
|
||||
r"""Function parameters as JSON Schema object"""
|
||||
|
||||
strict: OptionalNullable[bool] = UNSET
|
||||
r"""Enable strict schema adherence"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
@@ -64,14 +80,22 @@ class ToolDefinitionJSONFunction(BaseModel):
|
||||
|
||||
|
||||
class ToolDefinitionJSONTypedDict(TypedDict):
|
||||
r"""Tool definition for function calling"""
|
||||
|
||||
type: ToolDefinitionJSONType
|
||||
function: ToolDefinitionJSONFunctionTypedDict
|
||||
type: Literal["function"]
|
||||
r"""Function definition for tool calling"""
|
||||
cache_control: NotRequired[ChatMessageContentItemCacheControlTypedDict]
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
|
||||
class ToolDefinitionJSON(BaseModel):
|
||||
function: ToolDefinitionJSONFunction
|
||||
r"""Tool definition for function calling"""
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["function"], AfterValidator(validate_const("function"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "function"
|
||||
type: ToolDefinitionJSONType
|
||||
|
||||
function: ToolDefinitionJSONFunction
|
||||
r"""Function definition for tool calling"""
|
||||
|
||||
cache_control: Optional[ChatMessageContentItemCacheControl] = None
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
@@ -6,36 +6,43 @@ from .chatmessagecontentitem import (
|
||||
ChatMessageContentItemTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Union
|
||||
from typing_extensions import Annotated, TypeAliasType, TypedDict
|
||||
from typing_extensions import TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ToolResponseMessageRole = Literal["tool",]
|
||||
|
||||
|
||||
ToolResponseMessageContentTypedDict = TypeAliasType(
|
||||
"ToolResponseMessageContentTypedDict",
|
||||
Union[str, List[ChatMessageContentItemTypedDict]],
|
||||
)
|
||||
r"""Tool response content"""
|
||||
|
||||
|
||||
ToolResponseMessageContent = TypeAliasType(
|
||||
"ToolResponseMessageContent", Union[str, List[ChatMessageContentItem]]
|
||||
)
|
||||
r"""Tool response content"""
|
||||
|
||||
|
||||
class ToolResponseMessageTypedDict(TypedDict):
|
||||
r"""Tool response message"""
|
||||
|
||||
role: ToolResponseMessageRole
|
||||
content: ToolResponseMessageContentTypedDict
|
||||
r"""Tool response content"""
|
||||
tool_call_id: str
|
||||
role: Literal["tool"]
|
||||
r"""ID of the assistant message tool call this message responds to"""
|
||||
|
||||
|
||||
class ToolResponseMessage(BaseModel):
|
||||
r"""Tool response message"""
|
||||
|
||||
role: ToolResponseMessageRole
|
||||
|
||||
content: ToolResponseMessageContent
|
||||
r"""Tool response content"""
|
||||
|
||||
tool_call_id: str
|
||||
|
||||
ROLE: Annotated[
|
||||
Annotated[Literal["tool"], AfterValidator(validate_const("tool"))],
|
||||
pydantic.Field(alias="role"),
|
||||
] = "tool"
|
||||
r"""ID of the assistant message tool call this message responds to"""
|
||||
|
||||
@@ -6,35 +6,42 @@ from .chatmessagecontentitem import (
|
||||
ChatMessageContentItemTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
UserMessageRole = Literal["user",]
|
||||
|
||||
|
||||
UserMessageContentTypedDict = TypeAliasType(
|
||||
"UserMessageContentTypedDict", Union[str, List[ChatMessageContentItemTypedDict]]
|
||||
)
|
||||
r"""User message content"""
|
||||
|
||||
|
||||
UserMessageContent = TypeAliasType(
|
||||
"UserMessageContent", Union[str, List[ChatMessageContentItem]]
|
||||
)
|
||||
r"""User message content"""
|
||||
|
||||
|
||||
class UserMessageTypedDict(TypedDict):
|
||||
r"""User message"""
|
||||
|
||||
role: UserMessageRole
|
||||
content: UserMessageContentTypedDict
|
||||
role: Literal["user"]
|
||||
r"""User message content"""
|
||||
name: NotRequired[str]
|
||||
r"""Optional name for the user"""
|
||||
|
||||
|
||||
class UserMessage(BaseModel):
|
||||
content: UserMessageContent
|
||||
r"""User message"""
|
||||
|
||||
ROLE: Annotated[
|
||||
Annotated[Literal["user"], AfterValidator(validate_const("user"))],
|
||||
pydantic.Field(alias="role"),
|
||||
] = "user"
|
||||
role: UserMessageRole
|
||||
|
||||
content: UserMessageContent
|
||||
r"""User message content"""
|
||||
|
||||
name: Optional[str] = None
|
||||
r"""Optional name for the user"""
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class VideoInputTypedDict(TypedDict):
|
||||
r"""Video input object"""
|
||||
|
||||
url: str
|
||||
r"""URL of the video (data: URLs supported)"""
|
||||
|
||||
|
||||
class VideoInput(BaseModel):
|
||||
r"""Video input object"""
|
||||
|
||||
url: str
|
||||
r"""URL of the video (data: URLs supported)"""
|
||||
@@ -15,7 +15,6 @@ if TYPE_CHECKING:
|
||||
BadRequestResponseError,
|
||||
BadRequestResponseErrorData,
|
||||
)
|
||||
from .chaterror import ChatError, ChatErrorData
|
||||
from .edgenetworktimeoutresponse_error import (
|
||||
EdgeNetworkTimeoutResponseError,
|
||||
EdgeNetworkTimeoutResponseErrorData,
|
||||
@@ -70,8 +69,6 @@ __all__ = [
|
||||
"BadGatewayResponseErrorData",
|
||||
"BadRequestResponseError",
|
||||
"BadRequestResponseErrorData",
|
||||
"ChatError",
|
||||
"ChatErrorData",
|
||||
"EdgeNetworkTimeoutResponseError",
|
||||
"EdgeNetworkTimeoutResponseErrorData",
|
||||
"ForbiddenResponseError",
|
||||
@@ -107,8 +104,6 @@ _dynamic_imports: dict[str, str] = {
|
||||
"BadGatewayResponseErrorData": ".badgatewayresponse_error",
|
||||
"BadRequestResponseError": ".badrequestresponse_error",
|
||||
"BadRequestResponseErrorData": ".badrequestresponse_error",
|
||||
"ChatError": ".chaterror",
|
||||
"ChatErrorData": ".chaterror",
|
||||
"EdgeNetworkTimeoutResponseError": ".edgenetworktimeoutresponse_error",
|
||||
"EdgeNetworkTimeoutResponseErrorData": ".edgenetworktimeoutresponse_error",
|
||||
"ForbiddenResponseError": ".forbiddenresponse_error",
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from dataclasses import dataclass, field
|
||||
import httpx
|
||||
from openrouter.components import chaterror as components_chaterror
|
||||
from openrouter.errors import OpenRouterError
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class ChatErrorData(BaseModel):
|
||||
error: components_chaterror.ChatErrorError
|
||||
|
||||
|
||||
@dataclass(unsafe_hash=True)
|
||||
class ChatError(OpenRouterError):
|
||||
data: ChatErrorData = field(hash=False)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
data: ChatErrorData,
|
||||
raw_response: httpx.Response,
|
||||
body: Optional[str] = None,
|
||||
):
|
||||
fallback = body or raw_response.text
|
||||
message = str(data.error.message) or fallback
|
||||
super().__init__(message, raw_response, body)
|
||||
object.__setattr__(self, "data", data)
|
||||
@@ -297,6 +297,8 @@ class OAuth(BaseSDK):
|
||||
] = None,
|
||||
limit: Optional[float] = None,
|
||||
expires_at: OptionalNullable[datetime] = UNSET,
|
||||
key_label: Optional[str] = None,
|
||||
usage_limit_type: Optional[operations.UsageLimitType] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -316,6 +318,8 @@ class OAuth(BaseSDK):
|
||||
:param code_challenge_method: The method used to generate the code challenge
|
||||
:param limit: Credit limit for the API key to be created
|
||||
:param expires_at: Optional expiration time for the API key to be created
|
||||
:param key_label: Optional custom label for the API key. Defaults to the app name if not provided.
|
||||
:param usage_limit_type: Optional credit limit reset interval. When set, the credit limit resets on this interval.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -340,6 +344,8 @@ class OAuth(BaseSDK):
|
||||
code_challenge_method=code_challenge_method,
|
||||
limit=limit,
|
||||
expires_at=expires_at,
|
||||
key_label=key_label,
|
||||
usage_limit_type=usage_limit_type,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -439,6 +445,8 @@ class OAuth(BaseSDK):
|
||||
] = None,
|
||||
limit: Optional[float] = None,
|
||||
expires_at: OptionalNullable[datetime] = UNSET,
|
||||
key_label: Optional[str] = None,
|
||||
usage_limit_type: Optional[operations.UsageLimitType] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -458,6 +466,8 @@ class OAuth(BaseSDK):
|
||||
:param code_challenge_method: The method used to generate the code challenge
|
||||
:param limit: Credit limit for the API key to be created
|
||||
:param expires_at: Optional expiration time for the API key to be created
|
||||
:param key_label: Optional custom label for the API key. Defaults to the app name if not provided.
|
||||
:param usage_limit_type: Optional credit limit reset interval. When set, the credit limit resets on this interval.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -482,6 +492,8 @@ class OAuth(BaseSDK):
|
||||
code_challenge_method=code_challenge_method,
|
||||
limit=limit,
|
||||
expires_at=expires_at,
|
||||
key_label=key_label,
|
||||
usage_limit_type=usage_limit_type,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ if TYPE_CHECKING:
|
||||
CreateAuthKeysCodeRequestTypedDict,
|
||||
CreateAuthKeysCodeResponse,
|
||||
CreateAuthKeysCodeResponseTypedDict,
|
||||
UsageLimitType,
|
||||
)
|
||||
from .createcoinbasecharge import (
|
||||
CallData,
|
||||
@@ -363,6 +364,8 @@ if TYPE_CHECKING:
|
||||
SendChatCompletionRequestRequest,
|
||||
SendChatCompletionRequestRequestTypedDict,
|
||||
SendChatCompletionRequestResponse,
|
||||
SendChatCompletionRequestResponseBody,
|
||||
SendChatCompletionRequestResponseBodyTypedDict,
|
||||
SendChatCompletionRequestResponseTypedDict,
|
||||
)
|
||||
from .updateguardrail import (
|
||||
@@ -678,6 +681,8 @@ __all__ = [
|
||||
"SendChatCompletionRequestRequest",
|
||||
"SendChatCompletionRequestRequestTypedDict",
|
||||
"SendChatCompletionRequestResponse",
|
||||
"SendChatCompletionRequestResponseBody",
|
||||
"SendChatCompletionRequestResponseBodyTypedDict",
|
||||
"SendChatCompletionRequestResponseTypedDict",
|
||||
"TransferIntent",
|
||||
"TransferIntentTypedDict",
|
||||
@@ -707,6 +712,7 @@ __all__ = [
|
||||
"UpdateKeysResponse",
|
||||
"UpdateKeysResponseTypedDict",
|
||||
"Usage",
|
||||
"UsageLimitType",
|
||||
"UsageTypedDict",
|
||||
"Web3Data",
|
||||
"Web3DataTypedDict",
|
||||
@@ -756,6 +762,7 @@ _dynamic_imports: dict[str, str] = {
|
||||
"CreateAuthKeysCodeRequestTypedDict": ".createauthkeyscode",
|
||||
"CreateAuthKeysCodeResponse": ".createauthkeyscode",
|
||||
"CreateAuthKeysCodeResponseTypedDict": ".createauthkeyscode",
|
||||
"UsageLimitType": ".createauthkeyscode",
|
||||
"CallData": ".createcoinbasecharge",
|
||||
"CallDataTypedDict": ".createcoinbasecharge",
|
||||
"CreateCoinbaseChargeData": ".createcoinbasecharge",
|
||||
@@ -1005,6 +1012,8 @@ _dynamic_imports: dict[str, str] = {
|
||||
"SendChatCompletionRequestRequest": ".sendchatcompletionrequest",
|
||||
"SendChatCompletionRequestRequestTypedDict": ".sendchatcompletionrequest",
|
||||
"SendChatCompletionRequestResponse": ".sendchatcompletionrequest",
|
||||
"SendChatCompletionRequestResponseBody": ".sendchatcompletionrequest",
|
||||
"SendChatCompletionRequestResponseBodyTypedDict": ".sendchatcompletionrequest",
|
||||
"SendChatCompletionRequestResponseTypedDict": ".sendchatcompletionrequest",
|
||||
"UpdateGuardrailData": ".updateguardrail",
|
||||
"UpdateGuardrailDataTypedDict": ".updateguardrail",
|
||||
|
||||
@@ -66,6 +66,17 @@ CreateAuthKeysCodeCodeChallengeMethod = Union[
|
||||
r"""The method used to generate the code challenge"""
|
||||
|
||||
|
||||
UsageLimitType = Union[
|
||||
Literal[
|
||||
"daily",
|
||||
"weekly",
|
||||
"monthly",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Optional credit limit reset interval. When set, the credit limit resets on this interval."""
|
||||
|
||||
|
||||
class CreateAuthKeysCodeRequestBodyTypedDict(TypedDict):
|
||||
callback_url: str
|
||||
r"""The callback URL to redirect to after authorization. Note, only https URLs on ports 443 and 3000 are allowed."""
|
||||
@@ -77,6 +88,10 @@ class CreateAuthKeysCodeRequestBodyTypedDict(TypedDict):
|
||||
r"""Credit limit for the API key to be created"""
|
||||
expires_at: NotRequired[Nullable[datetime]]
|
||||
r"""Optional expiration time for the API key to be created"""
|
||||
key_label: NotRequired[str]
|
||||
r"""Optional custom label for the API key. Defaults to the app name if not provided."""
|
||||
usage_limit_type: NotRequired[UsageLimitType]
|
||||
r"""Optional credit limit reset interval. When set, the credit limit resets on this interval."""
|
||||
|
||||
|
||||
class CreateAuthKeysCodeRequestBody(BaseModel):
|
||||
@@ -98,6 +113,14 @@ class CreateAuthKeysCodeRequestBody(BaseModel):
|
||||
expires_at: OptionalNullable[datetime] = UNSET
|
||||
r"""Optional expiration time for the API key to be created"""
|
||||
|
||||
key_label: Optional[str] = None
|
||||
r"""Optional custom label for the API key. Defaults to the app name if not provided."""
|
||||
|
||||
usage_limit_type: Annotated[
|
||||
Optional[UsageLimitType], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""Optional credit limit reset interval. When set, the credit limit resets on this interval."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
@@ -105,6 +128,8 @@ class CreateAuthKeysCodeRequestBody(BaseModel):
|
||||
"code_challenge_method",
|
||||
"limit",
|
||||
"expires_at",
|
||||
"key_label",
|
||||
"usage_limit_type",
|
||||
]
|
||||
nullable_fields = ["expires_at"]
|
||||
null_default_fields = []
|
||||
|
||||
@@ -160,7 +160,9 @@ ProviderName = Union[
|
||||
"Inception",
|
||||
"Inceptron",
|
||||
"InferenceNet",
|
||||
"Ionstream",
|
||||
"Infermatic",
|
||||
"Io Net",
|
||||
"Inflection",
|
||||
"Liquid",
|
||||
"Mara",
|
||||
|
||||
@@ -55,7 +55,6 @@ class SendChatCompletionRequestRequestTypedDict(TypedDict):
|
||||
chat_generation_params: (
|
||||
components_chatgenerationparams.ChatGenerationParamsTypedDict
|
||||
)
|
||||
r"""Chat completion request parameters"""
|
||||
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.
|
||||
@@ -72,7 +71,6 @@ class SendChatCompletionRequestRequest(BaseModel):
|
||||
components_chatgenerationparams.ChatGenerationParams,
|
||||
FieldMetadata(request=RequestMetadata(media_type="application/json")),
|
||||
]
|
||||
r"""Chat completion request parameters"""
|
||||
|
||||
http_referer: Annotated[
|
||||
Optional[str],
|
||||
@@ -94,16 +92,30 @@ class SendChatCompletionRequestRequest(BaseModel):
|
||||
"""
|
||||
|
||||
|
||||
class SendChatCompletionRequestResponseBodyTypedDict(TypedDict):
|
||||
r"""Successful chat completion response"""
|
||||
|
||||
data: components_chatstreamingresponsechunk.ChatStreamingResponseChunkTypedDict
|
||||
r"""Streaming chat completion chunk"""
|
||||
|
||||
|
||||
class SendChatCompletionRequestResponseBody(BaseModel):
|
||||
r"""Successful chat completion response"""
|
||||
|
||||
data: components_chatstreamingresponsechunk.ChatStreamingResponseChunk
|
||||
r"""Streaming chat completion chunk"""
|
||||
|
||||
|
||||
SendChatCompletionRequestResponseTypedDict = TypeAliasType(
|
||||
"SendChatCompletionRequestResponseTypedDict",
|
||||
Union[
|
||||
components_chatresponse.ChatResponseTypedDict,
|
||||
Union[
|
||||
eventstreaming.EventStream[
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunkDataTypedDict
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunkTypedDict
|
||||
],
|
||||
eventstreaming.EventStreamAsync[
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunkDataTypedDict
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunkTypedDict
|
||||
],
|
||||
],
|
||||
],
|
||||
@@ -116,10 +128,10 @@ SendChatCompletionRequestResponse = TypeAliasType(
|
||||
components_chatresponse.ChatResponse,
|
||||
Union[
|
||||
eventstreaming.EventStream[
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunkData
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunk
|
||||
],
|
||||
eventstreaming.EventStreamAsync[
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunkData
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunk
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
+100
-16
@@ -86,13 +86,25 @@ class Responses(BaseSDK):
|
||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||
stream: Union[Literal[False], None] = None,
|
||||
provider: OptionalNullable[
|
||||
Union[components.Provider, components.ProviderTypedDict]
|
||||
Union[
|
||||
components.OpenResponsesRequestProvider,
|
||||
components.OpenResponsesRequestProviderTypedDict,
|
||||
]
|
||||
] = UNSET,
|
||||
plugins: Optional[
|
||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||
Union[
|
||||
List[components.OpenResponsesRequestPluginUnion],
|
||||
List[components.OpenResponsesRequestPluginUnionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
user: Optional[str] = None,
|
||||
session_id: Optional[str] = None,
|
||||
trace: Optional[
|
||||
Union[
|
||||
components.OpenResponsesRequestTrace,
|
||||
components.OpenResponsesRequestTraceTypedDict,
|
||||
]
|
||||
] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -140,6 +152,7 @@ class Responses(BaseSDK):
|
||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||
:param user: A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
||||
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -215,13 +228,25 @@ class Responses(BaseSDK):
|
||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||
stream: Literal[True],
|
||||
provider: OptionalNullable[
|
||||
Union[components.Provider, components.ProviderTypedDict]
|
||||
Union[
|
||||
components.OpenResponsesRequestProvider,
|
||||
components.OpenResponsesRequestProviderTypedDict,
|
||||
]
|
||||
] = UNSET,
|
||||
plugins: Optional[
|
||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||
Union[
|
||||
List[components.OpenResponsesRequestPluginUnion],
|
||||
List[components.OpenResponsesRequestPluginUnionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
user: Optional[str] = None,
|
||||
session_id: Optional[str] = None,
|
||||
trace: Optional[
|
||||
Union[
|
||||
components.OpenResponsesRequestTrace,
|
||||
components.OpenResponsesRequestTraceTypedDict,
|
||||
]
|
||||
] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -269,6 +294,7 @@ class Responses(BaseSDK):
|
||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||
:param user: A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
||||
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -343,13 +369,25 @@ class Responses(BaseSDK):
|
||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||
stream: Optional[bool] = False,
|
||||
provider: OptionalNullable[
|
||||
Union[components.Provider, components.ProviderTypedDict]
|
||||
Union[
|
||||
components.OpenResponsesRequestProvider,
|
||||
components.OpenResponsesRequestProviderTypedDict,
|
||||
]
|
||||
] = UNSET,
|
||||
plugins: Optional[
|
||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||
Union[
|
||||
List[components.OpenResponsesRequestPluginUnion],
|
||||
List[components.OpenResponsesRequestPluginUnionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
user: Optional[str] = None,
|
||||
session_id: Optional[str] = None,
|
||||
trace: Optional[
|
||||
Union[
|
||||
components.OpenResponsesRequestTrace,
|
||||
components.OpenResponsesRequestTraceTypedDict,
|
||||
]
|
||||
] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -397,6 +435,7 @@ class Responses(BaseSDK):
|
||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||
:param user: A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
||||
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -459,13 +498,16 @@ class Responses(BaseSDK):
|
||||
truncation=truncation,
|
||||
stream=stream,
|
||||
provider=utils.get_pydantic_model(
|
||||
provider, OptionalNullable[components.Provider]
|
||||
provider, OptionalNullable[components.OpenResponsesRequestProvider]
|
||||
),
|
||||
plugins=utils.get_pydantic_model(
|
||||
plugins, Optional[List[components.Plugin]]
|
||||
plugins, Optional[List[components.OpenResponsesRequestPluginUnion]]
|
||||
),
|
||||
user=user,
|
||||
session_id=session_id,
|
||||
trace=utils.get_pydantic_model(
|
||||
trace, Optional[components.OpenResponsesRequestTrace]
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -734,13 +776,25 @@ class Responses(BaseSDK):
|
||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||
stream: Union[Literal[False], None] = None,
|
||||
provider: OptionalNullable[
|
||||
Union[components.Provider, components.ProviderTypedDict]
|
||||
Union[
|
||||
components.OpenResponsesRequestProvider,
|
||||
components.OpenResponsesRequestProviderTypedDict,
|
||||
]
|
||||
] = UNSET,
|
||||
plugins: Optional[
|
||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||
Union[
|
||||
List[components.OpenResponsesRequestPluginUnion],
|
||||
List[components.OpenResponsesRequestPluginUnionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
user: Optional[str] = None,
|
||||
session_id: Optional[str] = None,
|
||||
trace: Optional[
|
||||
Union[
|
||||
components.OpenResponsesRequestTrace,
|
||||
components.OpenResponsesRequestTraceTypedDict,
|
||||
]
|
||||
] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -788,6 +842,7 @@ class Responses(BaseSDK):
|
||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||
:param user: A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
||||
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -863,13 +918,25 @@ class Responses(BaseSDK):
|
||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||
stream: Literal[True],
|
||||
provider: OptionalNullable[
|
||||
Union[components.Provider, components.ProviderTypedDict]
|
||||
Union[
|
||||
components.OpenResponsesRequestProvider,
|
||||
components.OpenResponsesRequestProviderTypedDict,
|
||||
]
|
||||
] = UNSET,
|
||||
plugins: Optional[
|
||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||
Union[
|
||||
List[components.OpenResponsesRequestPluginUnion],
|
||||
List[components.OpenResponsesRequestPluginUnionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
user: Optional[str] = None,
|
||||
session_id: Optional[str] = None,
|
||||
trace: Optional[
|
||||
Union[
|
||||
components.OpenResponsesRequestTrace,
|
||||
components.OpenResponsesRequestTraceTypedDict,
|
||||
]
|
||||
] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -917,6 +984,7 @@ class Responses(BaseSDK):
|
||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||
:param user: A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
||||
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -991,13 +1059,25 @@ class Responses(BaseSDK):
|
||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||
stream: Optional[bool] = False,
|
||||
provider: OptionalNullable[
|
||||
Union[components.Provider, components.ProviderTypedDict]
|
||||
Union[
|
||||
components.OpenResponsesRequestProvider,
|
||||
components.OpenResponsesRequestProviderTypedDict,
|
||||
]
|
||||
] = UNSET,
|
||||
plugins: Optional[
|
||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||
Union[
|
||||
List[components.OpenResponsesRequestPluginUnion],
|
||||
List[components.OpenResponsesRequestPluginUnionTypedDict],
|
||||
]
|
||||
] = None,
|
||||
user: Optional[str] = None,
|
||||
session_id: Optional[str] = None,
|
||||
trace: Optional[
|
||||
Union[
|
||||
components.OpenResponsesRequestTrace,
|
||||
components.OpenResponsesRequestTraceTypedDict,
|
||||
]
|
||||
] = None,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
@@ -1045,6 +1125,7 @@ class Responses(BaseSDK):
|
||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||
:param user: A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters.
|
||||
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
||||
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -1107,13 +1188,16 @@ class Responses(BaseSDK):
|
||||
truncation=truncation,
|
||||
stream=stream,
|
||||
provider=utils.get_pydantic_model(
|
||||
provider, OptionalNullable[components.Provider]
|
||||
provider, OptionalNullable[components.OpenResponsesRequestProvider]
|
||||
),
|
||||
plugins=utils.get_pydantic_model(
|
||||
plugins, Optional[List[components.Plugin]]
|
||||
plugins, Optional[List[components.OpenResponsesRequestPluginUnion]]
|
||||
),
|
||||
user=user,
|
||||
session_id=session_id,
|
||||
trace=utils.get_pydantic_model(
|
||||
trace, Optional[components.OpenResponsesRequestTrace]
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class OpenRouter(BaseSDK):
|
||||
beta: "Beta"
|
||||
analytics: "Analytics"
|
||||
r"""Analytics and usage endpoints"""
|
||||
chat: "Chat"
|
||||
credits: "Credits"
|
||||
r"""Credit management endpoints"""
|
||||
embeddings: "Embeddings"
|
||||
@@ -56,10 +57,10 @@ class OpenRouter(BaseSDK):
|
||||
r"""Guardrails endpoints"""
|
||||
o_auth: "OAuth"
|
||||
r"""OAuth authentication endpoints"""
|
||||
chat: "Chat"
|
||||
_sub_sdk_map = {
|
||||
"beta": ("openrouter.beta", "Beta"),
|
||||
"analytics": ("openrouter.analytics", "Analytics"),
|
||||
"chat": ("openrouter.chat", "Chat"),
|
||||
"credits": ("openrouter.credits", "Credits"),
|
||||
"embeddings": ("openrouter.embeddings", "Embeddings"),
|
||||
"generations": ("openrouter.generations", "Generations"),
|
||||
@@ -69,7 +70,6 @@ class OpenRouter(BaseSDK):
|
||||
"api_keys": ("openrouter.api_keys", "APIKeys"),
|
||||
"guardrails": ("openrouter.guardrails", "Guardrails"),
|
||||
"o_auth": ("openrouter.oauth", "OAuth"),
|
||||
"chat": ("openrouter.chat", "Chat"),
|
||||
}
|
||||
|
||||
def __init__(
|
||||
|
||||
Reference in New Issue
Block a user