latest updates

This commit is contained in:
Matt Apperson
2025-12-04 10:46:19 -05:00
parent a1dae775cb
commit 6cd0d2a76d
84 changed files with 9465 additions and 8751 deletions
+32 -13
View File
@@ -21,6 +21,7 @@ if TYPE_CHECKING:
BadRequestResponseErrorData,
BadRequestResponseErrorDataTypedDict,
)
from .chatcompletionfinishreason import ChatCompletionFinishReason
from .chaterror import ChatErrorError, ChatErrorErrorTypedDict, Code, CodeTypedDict
from .chatgenerationparams import (
ChatGenerationParams,
@@ -35,6 +36,8 @@ if TYPE_CHECKING:
ChatGenerationParamsStop,
ChatGenerationParamsStopTypedDict,
ChatGenerationParamsTypedDict,
Debug,
DebugTypedDict,
Effort,
Reasoning,
ReasoningTypedDict,
@@ -53,11 +56,15 @@ if TYPE_CHECKING:
)
from .chatmessagecontentitemaudio import (
ChatMessageContentItemAudio,
ChatMessageContentItemAudioFormat,
ChatMessageContentItemAudioInputAudio,
ChatMessageContentItemAudioInputAudioTypedDict,
ChatMessageContentItemAudioTypedDict,
)
from .chatmessagecontentitemcachecontrol import (
ChatMessageContentItemCacheControl,
ChatMessageContentItemCacheControlTypedDict,
TTL,
)
from .chatmessagecontentitemimage import (
ChatMessageContentItemImage,
ChatMessageContentItemImageDetail,
@@ -98,13 +105,8 @@ if TYPE_CHECKING:
ChatMessageToolCallTypedDict,
)
from .chatresponse import ChatResponse, ChatResponseTypedDict
from .chatresponsechoice import (
ChatCompletionFinishReason,
ChatResponseChoice,
ChatResponseChoiceTypedDict,
ChatStreamingChoice,
ChatStreamingChoiceTypedDict,
)
from .chatresponsechoice import ChatResponseChoice, ChatResponseChoiceTypedDict
from .chatstreamingchoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
from .chatstreamingmessagechunk import (
ChatStreamingMessageChunk,
ChatStreamingMessageChunkRole,
@@ -422,6 +424,7 @@ if TYPE_CHECKING:
Engine,
IDFileParser,
IDModeration,
IDResponseHealing,
IDWeb,
Ignore,
IgnoreTypedDict,
@@ -446,6 +449,8 @@ if TYPE_CHECKING:
PluginFileParserTypedDict,
PluginModeration,
PluginModerationTypedDict,
PluginResponseHealing,
PluginResponseHealingTypedDict,
PluginTypedDict,
PluginWeb,
PluginWebTypedDict,
@@ -820,10 +825,11 @@ __all__ = [
"ChatGenerationTokenUsageTypedDict",
"ChatMessageContentItem",
"ChatMessageContentItemAudio",
"ChatMessageContentItemAudioFormat",
"ChatMessageContentItemAudioInputAudio",
"ChatMessageContentItemAudioInputAudioTypedDict",
"ChatMessageContentItemAudioTypedDict",
"ChatMessageContentItemCacheControl",
"ChatMessageContentItemCacheControlTypedDict",
"ChatMessageContentItemImage",
"ChatMessageContentItemImageDetail",
"ChatMessageContentItemImageTypedDict",
@@ -896,6 +902,8 @@ __all__ = [
"CreateChargeRequest",
"CreateChargeRequestTypedDict",
"DataCollection",
"Debug",
"DebugTypedDict",
"DefaultParameters",
"DefaultParametersTypedDict",
"EdgeNetworkTimeoutResponseErrorData",
@@ -913,6 +921,7 @@ __all__ = [
"ForbiddenResponseErrorDataTypedDict",
"IDFileParser",
"IDModeration",
"IDResponseHealing",
"IDWeb",
"Ignore",
"IgnoreTypedDict",
@@ -1206,6 +1215,8 @@ __all__ = [
"PluginFileParserTypedDict",
"PluginModeration",
"PluginModerationTypedDict",
"PluginResponseHealing",
"PluginResponseHealingTypedDict",
"PluginTypedDict",
"PluginWeb",
"PluginWebTypedDict",
@@ -1331,6 +1342,7 @@ __all__ = [
"SystemMessageContent",
"SystemMessageContentTypedDict",
"SystemMessageTypedDict",
"TTL",
"Tokenizer",
"TooManyRequestsResponseErrorData",
"TooManyRequestsResponseErrorDataTypedDict",
@@ -1401,6 +1413,7 @@ _dynamic_imports: dict[str, str] = {
"BadGatewayResponseErrorDataTypedDict": ".badgatewayresponseerrordata",
"BadRequestResponseErrorData": ".badrequestresponseerrordata",
"BadRequestResponseErrorDataTypedDict": ".badrequestresponseerrordata",
"ChatCompletionFinishReason": ".chatcompletionfinishreason",
"ChatErrorError": ".chaterror",
"ChatErrorErrorTypedDict": ".chaterror",
"Code": ".chaterror",
@@ -1417,6 +1430,8 @@ _dynamic_imports: dict[str, str] = {
"ChatGenerationParamsStop": ".chatgenerationparams",
"ChatGenerationParamsStopTypedDict": ".chatgenerationparams",
"ChatGenerationParamsTypedDict": ".chatgenerationparams",
"Debug": ".chatgenerationparams",
"DebugTypedDict": ".chatgenerationparams",
"Effort": ".chatgenerationparams",
"Reasoning": ".chatgenerationparams",
"ReasoningTypedDict": ".chatgenerationparams",
@@ -1429,10 +1444,12 @@ _dynamic_imports: dict[str, str] = {
"ChatMessageContentItem": ".chatmessagecontentitem",
"ChatMessageContentItemTypedDict": ".chatmessagecontentitem",
"ChatMessageContentItemAudio": ".chatmessagecontentitemaudio",
"ChatMessageContentItemAudioFormat": ".chatmessagecontentitemaudio",
"ChatMessageContentItemAudioInputAudio": ".chatmessagecontentitemaudio",
"ChatMessageContentItemAudioInputAudioTypedDict": ".chatmessagecontentitemaudio",
"ChatMessageContentItemAudioTypedDict": ".chatmessagecontentitemaudio",
"ChatMessageContentItemCacheControl": ".chatmessagecontentitemcachecontrol",
"ChatMessageContentItemCacheControlTypedDict": ".chatmessagecontentitemcachecontrol",
"TTL": ".chatmessagecontentitemcachecontrol",
"ChatMessageContentItemImage": ".chatmessagecontentitemimage",
"ChatMessageContentItemImageDetail": ".chatmessagecontentitemimage",
"ChatMessageContentItemImageTypedDict": ".chatmessagecontentitemimage",
@@ -1462,11 +1479,10 @@ _dynamic_imports: dict[str, str] = {
"ChatMessageToolCallTypedDict": ".chatmessagetoolcall",
"ChatResponse": ".chatresponse",
"ChatResponseTypedDict": ".chatresponse",
"ChatCompletionFinishReason": ".chatresponsechoice",
"ChatResponseChoice": ".chatresponsechoice",
"ChatResponseChoiceTypedDict": ".chatresponsechoice",
"ChatStreamingChoice": ".chatresponsechoice",
"ChatStreamingChoiceTypedDict": ".chatresponsechoice",
"ChatStreamingChoice": ".chatstreamingchoice",
"ChatStreamingChoiceTypedDict": ".chatstreamingchoice",
"ChatStreamingMessageChunk": ".chatstreamingmessagechunk",
"ChatStreamingMessageChunkRole": ".chatstreamingmessagechunk",
"ChatStreamingMessageChunkTypedDict": ".chatstreamingmessagechunk",
@@ -1713,6 +1729,7 @@ _dynamic_imports: dict[str, str] = {
"Engine": ".openresponsesrequest",
"IDFileParser": ".openresponsesrequest",
"IDModeration": ".openresponsesrequest",
"IDResponseHealing": ".openresponsesrequest",
"IDWeb": ".openresponsesrequest",
"Ignore": ".openresponsesrequest",
"IgnoreTypedDict": ".openresponsesrequest",
@@ -1737,6 +1754,8 @@ _dynamic_imports: dict[str, str] = {
"PluginFileParserTypedDict": ".openresponsesrequest",
"PluginModeration": ".openresponsesrequest",
"PluginModerationTypedDict": ".openresponsesrequest",
"PluginResponseHealing": ".openresponsesrequest",
"PluginResponseHealingTypedDict": ".openresponsesrequest",
"PluginTypedDict": ".openresponsesrequest",
"PluginWeb": ".openresponsesrequest",
"PluginWebTypedDict": ".openresponsesrequest",
@@ -0,0 +1,17 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
ChatCompletionFinishReason = Union[
Literal[
"tool_calls",
"stop",
"length",
"content_filter",
"error",
],
UnrecognizedStr,
]
@@ -21,9 +21,9 @@ from openrouter.types import (
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_const, validate_open_enum
from openrouter.utils import get_discriminator, validate_const, validate_open_enum
import pydantic
from pydantic import model_serializer
from pydantic import 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
@@ -134,16 +134,16 @@ ChatGenerationParamsResponseFormatUnionTypedDict = TypeAliasType(
)
ChatGenerationParamsResponseFormatUnion = TypeAliasType(
"ChatGenerationParamsResponseFormatUnion",
ChatGenerationParamsResponseFormatUnion = Annotated[
Union[
ChatGenerationParamsResponseFormatText,
ChatGenerationParamsResponseFormatJSONObject,
ChatGenerationParamsResponseFormatPython,
ResponseFormatJSONSchema,
ResponseFormatTextGrammar,
Annotated[ChatGenerationParamsResponseFormatText, Tag("text")],
Annotated[ChatGenerationParamsResponseFormatJSONObject, Tag("json_object")],
Annotated[ResponseFormatJSONSchema, Tag("json_schema")],
Annotated[ResponseFormatTextGrammar, Tag("grammar")],
Annotated[ChatGenerationParamsResponseFormatPython, Tag("python")],
],
)
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
ChatGenerationParamsStopTypedDict = TypeAliasType(
@@ -156,6 +156,14 @@ ChatGenerationParamsStop = TypeAliasType(
)
class DebugTypedDict(TypedDict):
echo_upstream_body: NotRequired[bool]
class Debug(BaseModel):
echo_upstream_body: Optional[bool] = None
class ChatGenerationParamsTypedDict(TypedDict):
messages: List[MessageTypedDict]
model: NotRequired[str]
@@ -179,6 +187,7 @@ class ChatGenerationParamsTypedDict(TypedDict):
tools: NotRequired[List[ToolDefinitionJSONTypedDict]]
top_p: NotRequired[Nullable[float]]
user: NotRequired[str]
debug: NotRequired[DebugTypedDict]
class ChatGenerationParams(BaseModel):
@@ -226,6 +235,8 @@ class ChatGenerationParams(BaseModel):
user: Optional[str] = None
debug: Optional[Debug] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
@@ -250,6 +261,7 @@ class ChatGenerationParams(BaseModel):
"tools",
"top_p",
"user",
"debug",
]
nullable_fields = [
"frequency_penalty",
@@ -26,9 +26,9 @@ from typing_extensions import Annotated, TypeAliasType
ChatMessageContentItemTypedDict = TypeAliasType(
"ChatMessageContentItemTypedDict",
Union[
ChatMessageContentItemTextTypedDict,
ChatMessageContentItemImageTypedDict,
ChatMessageContentItemAudioTypedDict,
ChatMessageContentItemTextTypedDict,
ChatMessageContentItemVideoTypedDict,
],
)
@@ -1,42 +1,23 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import validate_const, validate_open_enum
from openrouter.types import BaseModel
from openrouter.utils import validate_const
import pydantic
from pydantic.functional_validators import AfterValidator, PlainValidator
from typing import Literal, Union
from pydantic.functional_validators import AfterValidator
from typing import Literal
from typing_extensions import Annotated, TypedDict
ChatMessageContentItemAudioFormat = Union[
Literal[
"wav",
"mp3",
"flac",
"m4a",
"ogg",
"pcm16",
"pcm24",
],
UnrecognizedStr,
]
class ChatMessageContentItemAudioInputAudioTypedDict(TypedDict):
data: str
format_: ChatMessageContentItemAudioFormat
format_: str
class ChatMessageContentItemAudioInputAudio(BaseModel):
data: str
format_: Annotated[
Annotated[
ChatMessageContentItemAudioFormat, PlainValidator(validate_open_enum(False))
],
pydantic.Field(alias="format"),
]
format_: Annotated[str, pydantic.Field(alias="format")]
class ChatMessageContentItemAudioTypedDict(TypedDict):
@@ -0,0 +1,32 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
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 typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
TTL = Union[
Literal[
"5m",
"1h",
],
UnrecognizedStr,
]
class ChatMessageContentItemCacheControlTypedDict(TypedDict):
type: Literal["ephemeral"]
ttl: NotRequired[TTL]
class ChatMessageContentItemCacheControl(BaseModel):
TYPE: Annotated[
Annotated[Literal["ephemeral"], AfterValidator(validate_const("ephemeral"))],
pydantic.Field(alias="type"),
] = "ephemeral"
ttl: Annotated[Optional[TTL], PlainValidator(validate_open_enum(False))] = None
@@ -1,17 +1,22 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatmessagecontentitemcachecontrol import (
ChatMessageContentItemCacheControl,
ChatMessageContentItemCacheControlTypedDict,
)
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 import Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
class ChatMessageContentItemTextTypedDict(TypedDict):
text: str
type: Literal["text"]
cache_control: NotRequired[ChatMessageContentItemCacheControlTypedDict]
class ChatMessageContentItemText(BaseModel):
@@ -21,3 +26,5 @@ class ChatMessageContentItemText(BaseModel):
Annotated[Literal["text"], AfterValidator(validate_const("text"))],
pydantic.Field(alias="type"),
] = "text"
cache_control: Optional[ChatMessageContentItemCacheControl] = None
@@ -2,8 +2,9 @@
from __future__ import annotations
from openrouter.types import BaseModel
from openrouter.utils import validate_const
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
@@ -64,7 +65,10 @@ ChatMessageContentItemVideoTypedDict = TypeAliasType(
)
ChatMessageContentItemVideo = TypeAliasType(
"ChatMessageContentItemVideo",
Union[ChatMessageContentItemVideoInputVideo, ChatMessageContentItemVideoVideoURL],
)
ChatMessageContentItemVideo = Annotated[
Union[
Annotated[ChatMessageContentItemVideoInputVideo, Tag("input_video")],
Annotated[ChatMessageContentItemVideoVideoURL, Tag("video_url")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
@@ -2,41 +2,24 @@
from __future__ import annotations
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
from .chatcompletionfinishreason import ChatCompletionFinishReason
from .chatmessagetokenlogprobs import (
ChatMessageTokenLogprobs,
ChatMessageTokenLogprobsTypedDict,
)
from .chatstreamingmessagechunk import (
ChatStreamingMessageChunk,
ChatStreamingMessageChunkTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal, Union
from typing_extensions import Annotated, NotRequired, TypedDict
ChatCompletionFinishReason = Union[
Literal[
"tool_calls",
"stop",
"length",
"content_filter",
"error",
],
UnrecognizedStr,
]
class ChatResponseChoiceTypedDict(TypedDict):
finish_reason: Nullable[ChatCompletionFinishReason]
index: float
@@ -84,52 +67,3 @@ class ChatResponseChoice(BaseModel):
m[k] = val
return m
class ChatStreamingChoiceTypedDict(TypedDict):
delta: ChatStreamingMessageChunkTypedDict
finish_reason: Nullable[ChatCompletionFinishReason]
index: float
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
class ChatStreamingChoice(BaseModel):
delta: ChatStreamingMessageChunk
finish_reason: Annotated[
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
]
index: float
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["logprobs"]
nullable_fields = ["finish_reason", "logprobs"]
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,72 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatcompletionfinishreason import ChatCompletionFinishReason
from .chatmessagetokenlogprobs import (
ChatMessageTokenLogprobs,
ChatMessageTokenLogprobsTypedDict,
)
from .chatstreamingmessagechunk import (
ChatStreamingMessageChunk,
ChatStreamingMessageChunkTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
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
class ChatStreamingChoiceTypedDict(TypedDict):
delta: ChatStreamingMessageChunkTypedDict
finish_reason: Nullable[ChatCompletionFinishReason]
index: float
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
class ChatStreamingChoice(BaseModel):
delta: ChatStreamingMessageChunk
finish_reason: Annotated[
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
]
index: float
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["logprobs"]
nullable_fields = ["finish_reason", "logprobs"]
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
@@ -5,7 +5,7 @@ from .chatgenerationtokenusage import (
ChatGenerationTokenUsage,
ChatGenerationTokenUsageTypedDict,
)
from .chatresponsechoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
from .chatstreamingchoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
from openrouter.types import (
BaseModel,
Nullable,
+18 -5
View File
@@ -2,12 +2,19 @@
from __future__ import annotations
from .completionlogprobs import CompletionLogprobs, CompletionLogprobsTypedDict
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal, Union
from typing_extensions import Annotated, TypedDict
from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
CompletionFinishReason = Union[
@@ -25,6 +32,8 @@ class CompletionChoiceTypedDict(TypedDict):
index: float
logprobs: Nullable[CompletionLogprobsTypedDict]
finish_reason: Nullable[CompletionFinishReason]
native_finish_reason: NotRequired[str]
reasoning: NotRequired[Nullable[str]]
class CompletionChoice(BaseModel):
@@ -38,10 +47,14 @@ class CompletionChoice(BaseModel):
Nullable[CompletionFinishReason], PlainValidator(validate_open_enum(False))
]
native_finish_reason: Optional[str] = None
reasoning: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = []
nullable_fields = ["logprobs", "finish_reason"]
optional_fields = ["native_finish_reason", "reasoning"]
nullable_fields = ["logprobs", "finish_reason", "reasoning"]
null_default_fields = []
serialized = handler(self)
@@ -16,9 +16,9 @@ from openrouter.types import (
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_const
from openrouter.utils import get_discriminator, validate_const
import pydantic
from pydantic import model_serializer
from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import AfterValidator
from typing import Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -127,16 +127,16 @@ CompletionCreateParamsResponseFormatUnionTypedDict = TypeAliasType(
)
CompletionCreateParamsResponseFormatUnion = TypeAliasType(
"CompletionCreateParamsResponseFormatUnion",
CompletionCreateParamsResponseFormatUnion = Annotated[
Union[
CompletionCreateParamsResponseFormatText,
CompletionCreateParamsResponseFormatJSONObject,
CompletionCreateParamsResponseFormatPython,
ResponseFormatJSONSchema,
ResponseFormatTextGrammar,
Annotated[CompletionCreateParamsResponseFormatText, Tag("text")],
Annotated[CompletionCreateParamsResponseFormatJSONObject, Tag("json_object")],
Annotated[ResponseFormatJSONSchema, Tag("json_schema")],
Annotated[ResponseFormatTextGrammar, Tag("grammar")],
Annotated[CompletionCreateParamsResponseFormatPython, Tag("python")],
],
)
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class CompletionCreateParamsTypedDict(TypedDict):
@@ -17,6 +17,7 @@ class CompletionResponseTypedDict(TypedDict):
model: str
choices: List[CompletionChoiceTypedDict]
object: Literal["text_completion"]
provider: NotRequired[str]
system_fingerprint: NotRequired[str]
usage: NotRequired[CompletionUsageTypedDict]
@@ -38,6 +39,8 @@ class CompletionResponse(BaseModel):
pydantic.Field(alias="object"),
] = "text_completion"
provider: Optional[str] = None
system_fingerprint: Optional[str] = None
usage: Optional[CompletionUsage] = None
+10 -9
View File
@@ -10,8 +10,9 @@ from .systemmessage import SystemMessage, SystemMessageTypedDict
from .toolresponsemessage import ToolResponseMessage, ToolResponseMessageTypedDict
from .usermessage import UserMessage, UserMessageTypedDict
from openrouter.types import BaseModel
from openrouter.utils import validate_const
from openrouter.utils import get_discriminator, validate_const
import pydantic
from pydantic import Discriminator, Tag
from pydantic.functional_validators import AfterValidator
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -56,13 +57,13 @@ MessageTypedDict = TypeAliasType(
)
Message = TypeAliasType(
"Message",
Message = Annotated[
Union[
SystemMessage,
UserMessage,
MessageDeveloper,
ToolResponseMessage,
AssistantMessage,
Annotated[SystemMessage, Tag("system")],
Annotated[UserMessage, Tag("user")],
Annotated[MessageDeveloper, Tag("developer")],
Annotated[AssistantMessage, Tag("assistant")],
Annotated[ToolResponseMessage, Tag("tool")],
],
)
Discriminator(lambda m: get_discriminator(m, "role", "role")),
]
@@ -4,8 +4,10 @@ from __future__ import annotations
from .filecitation import FileCitation, FileCitationTypedDict
from .filepath import FilePath, FilePathTypedDict
from .urlcitation import URLCitation, URLCitationTypedDict
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union
from typing_extensions import TypeAliasType
from typing_extensions import Annotated, TypeAliasType
OpenAIResponsesAnnotationTypedDict = TypeAliasType(
@@ -14,6 +16,11 @@ OpenAIResponsesAnnotationTypedDict = TypeAliasType(
)
OpenAIResponsesAnnotation = TypeAliasType(
"OpenAIResponsesAnnotation", Union[FilePath, FileCitation, URLCitation]
)
OpenAIResponsesAnnotation = Annotated[
Union[
Annotated[FileCitation, Tag("file_citation")],
Annotated[URLCitation, Tag("url_citation")],
Annotated[FilePath, Tag("file_path")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
@@ -48,8 +48,8 @@ from openrouter.types import (
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from openrouter.utils import get_discriminator, validate_open_enum
from pydantic import 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
@@ -127,16 +127,19 @@ OpenResponsesNonStreamingResponseToolUnionTypedDict = TypeAliasType(
)
OpenResponsesNonStreamingResponseToolUnion = TypeAliasType(
"OpenResponsesNonStreamingResponseToolUnion",
OpenResponsesNonStreamingResponseToolUnion = Annotated[
Union[
OpenResponsesWebSearchPreviewTool,
OpenResponsesWebSearchPreview20250311Tool,
OpenResponsesWebSearchTool,
OpenResponsesWebSearch20250826Tool,
OpenResponsesNonStreamingResponseToolFunction,
Annotated[OpenResponsesNonStreamingResponseToolFunction, Tag("function")],
Annotated[OpenResponsesWebSearchPreviewTool, Tag("web_search_preview")],
Annotated[
OpenResponsesWebSearchPreview20250311Tool,
Tag("web_search_preview_2025_03_11"),
],
Annotated[OpenResponsesWebSearchTool, Tag("web_search")],
Annotated[OpenResponsesWebSearch20250826Tool, Tag("web_search_2025_08_26")],
],
)
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesNonStreamingResponseTypedDict(TypedDict):
@@ -44,9 +44,10 @@ from openrouter.types import (
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
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 Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -120,30 +121,24 @@ OpenResponsesRequestToolUnionTypedDict = TypeAliasType(
)
OpenResponsesRequestToolUnion = TypeAliasType(
"OpenResponsesRequestToolUnion",
OpenResponsesRequestToolUnion = Annotated[
Union[
OpenResponsesWebSearchPreviewTool,
OpenResponsesWebSearchPreview20250311Tool,
OpenResponsesWebSearchTool,
OpenResponsesWebSearch20250826Tool,
OpenResponsesRequestToolFunction,
Annotated[OpenResponsesRequestToolFunction, Tag("function")],
Annotated[OpenResponsesWebSearchPreviewTool, Tag("web_search_preview")],
Annotated[
OpenResponsesWebSearchPreview20250311Tool,
Tag("web_search_preview_2025_03_11"),
],
Annotated[OpenResponsesWebSearchTool, Tag("web_search")],
Annotated[OpenResponsesWebSearch20250826Tool, Tag("web_search_2025_08_26")],
],
)
ServiceTier = Union[
Literal[
"auto",
"default",
"flex",
"priority",
"scale",
],
UnrecognizedStr,
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
ServiceTier = Literal["auto",]
Truncation = Union[
Literal[
"auto",
@@ -353,6 +348,17 @@ class Provider(BaseModel):
return m
IDResponseHealing = Literal["response-healing",]
class PluginResponseHealingTypedDict(TypedDict):
id: IDResponseHealing
class PluginResponseHealing(BaseModel):
id: IDResponseHealing
IDFileParser = Literal["file-parser",]
@@ -434,11 +440,24 @@ class PluginModeration(BaseModel):
PluginTypedDict = TypeAliasType(
"PluginTypedDict",
Union[PluginModerationTypedDict, PluginFileParserTypedDict, PluginWebTypedDict],
Union[
PluginModerationTypedDict,
PluginResponseHealingTypedDict,
PluginFileParserTypedDict,
PluginWebTypedDict,
],
)
Plugin = TypeAliasType("Plugin", Union[PluginModeration, PluginFileParser, PluginWeb])
Plugin = Annotated[
Union[
Annotated[PluginModeration, Tag("moderation")],
Annotated[PluginWeb, Tag("web")],
Annotated[PluginFileParser, Tag("file-parser")],
Annotated[PluginResponseHealing, Tag("response-healing")],
],
Discriminator(lambda m: get_discriminator(m, "id", "id")),
]
class OpenResponsesRequestTypedDict(TypedDict):
@@ -468,8 +487,8 @@ class OpenResponsesRequestTypedDict(TypedDict):
include: NotRequired[Nullable[List[OpenAIResponsesIncludable]]]
background: NotRequired[Nullable[bool]]
safety_identifier: NotRequired[Nullable[str]]
store: NotRequired[Nullable[bool]]
service_tier: NotRequired[Nullable[ServiceTier]]
store: Literal[False]
service_tier: NotRequired[ServiceTier]
truncation: NotRequired[Nullable[Truncation]]
stream: NotRequired[bool]
provider: NotRequired[Nullable[ProviderTypedDict]]
@@ -533,11 +552,12 @@ class OpenResponsesRequest(BaseModel):
safety_identifier: OptionalNullable[str] = UNSET
store: OptionalNullable[bool] = UNSET
STORE: Annotated[
Annotated[Optional[Literal[False]], AfterValidator(validate_const(False))],
pydantic.Field(alias="store"),
] = False
service_tier: Annotated[
OptionalNullable[ServiceTier], PlainValidator(validate_open_enum(False))
] = UNSET
service_tier: Optional[ServiceTier] = "auto"
truncation: Annotated[
OptionalNullable[Truncation], PlainValidator(validate_open_enum(False))
@@ -599,8 +619,6 @@ class OpenResponsesRequest(BaseModel):
"include",
"background",
"safety_identifier",
"store",
"service_tier",
"truncation",
"provider",
]
@@ -59,8 +59,10 @@ from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentType
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from .responsesoutputitem import ResponsesOutputItem, ResponsesOutputItemTypedDict
from openrouter.types import BaseModel
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import List, Literal, Union
from typing_extensions import TypeAliasType, TypedDict
from typing_extensions import Annotated, TypeAliasType, TypedDict
TypeResponseReasoningSummaryPartDone = Literal["response.reasoning_summary_part.done",]
@@ -328,10 +330,14 @@ Part2TypedDict = TypeAliasType(
)
Part2 = TypeAliasType(
"Part2",
Union[ReasoningTextContent, OpenAIResponsesRefusalContent, ResponseOutputText],
)
Part2 = Annotated[
Union[
Annotated[ResponseOutputText, Tag("output_text")],
Annotated[ReasoningTextContent, Tag("reasoning_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesStreamEventResponseContentPartDoneTypedDict(TypedDict):
@@ -374,10 +380,14 @@ Part1TypedDict = TypeAliasType(
)
Part1 = TypeAliasType(
"Part1",
Union[ReasoningTextContent, OpenAIResponsesRefusalContent, ResponseOutputText],
)
Part1 = Annotated[
Union[
Annotated[ResponseOutputText, Tag("output_text")],
Annotated[ReasoningTextContent, Tag("reasoning_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesStreamEventResponseContentPartAddedTypedDict(TypedDict):
@@ -609,36 +619,97 @@ OpenResponsesStreamEventTypedDict = TypeAliasType(
r"""Union of all possible event types emitted during response streaming"""
OpenResponsesStreamEvent = TypeAliasType(
"OpenResponsesStreamEvent",
OpenResponsesStreamEvent = Annotated[
Union[
OpenResponsesStreamEventResponseCreated,
OpenResponsesStreamEventResponseInProgress,
OpenResponsesStreamEventResponseCompleted,
OpenResponsesStreamEventResponseIncomplete,
OpenResponsesStreamEventResponseFailed,
OpenResponsesStreamEventResponseOutputItemAdded,
OpenResponsesStreamEventResponseOutputItemDone,
OpenResponsesImageGenCallCompleted,
OpenResponsesImageGenCallGenerating,
OpenResponsesImageGenCallInProgress,
OpenResponsesErrorEvent,
OpenResponsesStreamEventResponseFunctionCallArgumentsDelta,
OpenResponsesStreamEventResponseRefusalDelta,
OpenResponsesReasoningSummaryPartAddedEvent,
OpenResponsesStreamEventResponseContentPartAdded,
OpenResponsesImageGenCallPartialImage,
OpenResponsesStreamEventResponseFunctionCallArgumentsDone,
OpenResponsesReasoningDeltaEvent,
OpenResponsesReasoningDoneEvent,
OpenResponsesStreamEventResponseRefusalDone,
OpenResponsesStreamEventResponseReasoningSummaryPartDone,
OpenResponsesReasoningSummaryTextDeltaEvent,
OpenResponsesReasoningSummaryTextDoneEvent,
OpenResponsesStreamEventResponseContentPartDone,
OpenResponsesStreamEventResponseOutputTextDelta,
OpenResponsesStreamEventResponseOutputTextDone,
OpenResponsesStreamEventResponseOutputTextAnnotationAdded,
Annotated[OpenResponsesStreamEventResponseCreated, Tag("response.created")],
Annotated[
OpenResponsesStreamEventResponseInProgress, Tag("response.in_progress")
],
Annotated[OpenResponsesStreamEventResponseCompleted, Tag("response.completed")],
Annotated[
OpenResponsesStreamEventResponseIncomplete, Tag("response.incomplete")
],
Annotated[OpenResponsesStreamEventResponseFailed, Tag("response.failed")],
Annotated[OpenResponsesErrorEvent, Tag("error")],
Annotated[
OpenResponsesStreamEventResponseOutputItemAdded,
Tag("response.output_item.added"),
],
Annotated[
OpenResponsesStreamEventResponseOutputItemDone,
Tag("response.output_item.done"),
],
Annotated[
OpenResponsesStreamEventResponseContentPartAdded,
Tag("response.content_part.added"),
],
Annotated[
OpenResponsesStreamEventResponseContentPartDone,
Tag("response.content_part.done"),
],
Annotated[
OpenResponsesStreamEventResponseOutputTextDelta,
Tag("response.output_text.delta"),
],
Annotated[
OpenResponsesStreamEventResponseOutputTextDone,
Tag("response.output_text.done"),
],
Annotated[
OpenResponsesStreamEventResponseRefusalDelta, Tag("response.refusal.delta")
],
Annotated[
OpenResponsesStreamEventResponseRefusalDone, Tag("response.refusal.done")
],
Annotated[
OpenResponsesStreamEventResponseOutputTextAnnotationAdded,
Tag("response.output_text.annotation.added"),
],
Annotated[
OpenResponsesStreamEventResponseFunctionCallArgumentsDelta,
Tag("response.function_call_arguments.delta"),
],
Annotated[
OpenResponsesStreamEventResponseFunctionCallArgumentsDone,
Tag("response.function_call_arguments.done"),
],
Annotated[
OpenResponsesReasoningDeltaEvent, Tag("response.reasoning_text.delta")
],
Annotated[OpenResponsesReasoningDoneEvent, Tag("response.reasoning_text.done")],
Annotated[
OpenResponsesReasoningSummaryPartAddedEvent,
Tag("response.reasoning_summary_part.added"),
],
Annotated[
OpenResponsesStreamEventResponseReasoningSummaryPartDone,
Tag("response.reasoning_summary_part.done"),
],
Annotated[
OpenResponsesReasoningSummaryTextDeltaEvent,
Tag("response.reasoning_summary_text.delta"),
],
Annotated[
OpenResponsesReasoningSummaryTextDoneEvent,
Tag("response.reasoning_summary_text.done"),
],
Annotated[
OpenResponsesImageGenCallInProgress,
Tag("response.image_generation_call.in_progress"),
],
Annotated[
OpenResponsesImageGenCallGenerating,
Tag("response.image_generation_call.generating"),
],
Annotated[
OpenResponsesImageGenCallPartialImage,
Tag("response.image_generation_call.partial_image"),
],
Annotated[
OpenResponsesImageGenCallCompleted,
Tag("response.image_generation_call.completed"),
],
],
)
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""Union of all possible event types emitted during response streaming"""
+10 -4
View File
@@ -7,8 +7,10 @@ from .openairesponsesrefusalcontent import (
)
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from openrouter.types import BaseModel
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
OutputMessageRole = Literal["assistant",]
@@ -52,9 +54,13 @@ OutputMessageContentTypedDict = TypeAliasType(
)
OutputMessageContent = TypeAliasType(
"OutputMessageContent", Union[OpenAIResponsesRefusalContent, ResponseOutputText]
)
OutputMessageContent = Annotated[
Union[
Annotated[ResponseOutputText, Tag("output_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OutputMessageTypedDict(TypedDict):
+5 -1
View File
@@ -11,12 +11,14 @@ ProviderName = Union[
"AionLabs",
"Alibaba",
"Amazon Bedrock",
"Amazon Nova",
"Anthropic",
"Arcee",
"Arcee AI",
"AtlasCloud",
"Avian",
"Azure",
"BaseTen",
"BytePlus",
"Black Forest Labs",
"Cerebras",
"Chutes",
@@ -31,6 +33,7 @@ ProviderName = Union[
"Fireworks",
"Friendli",
"GMICloud",
"GoPomelo",
"Google",
"Google AI Studio",
"Groq",
@@ -61,6 +64,7 @@ ProviderName = Union[
"SambaNova",
"SiliconFlow",
"Stealth",
"StreamLake",
"Switchpoint",
"Targon",
"Together",
@@ -10,8 +10,10 @@ from .responsesformattextjsonschemaconfig import (
ResponsesFormatTextJSONSchemaConfig,
ResponsesFormatTextJSONSchemaConfigTypedDict,
)
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union
from typing_extensions import TypeAliasType
from typing_extensions import Annotated, TypeAliasType
ResponseFormatTextConfigTypedDict = TypeAliasType(
@@ -25,12 +27,12 @@ ResponseFormatTextConfigTypedDict = TypeAliasType(
r"""Text response format configuration"""
ResponseFormatTextConfig = TypeAliasType(
"ResponseFormatTextConfig",
ResponseFormatTextConfig = Annotated[
Union[
ResponsesFormatText,
ResponsesFormatJSONObject,
ResponsesFormatTextJSONSchemaConfig,
Annotated[ResponsesFormatText, Tag("text")],
Annotated[ResponsesFormatJSONObject, Tag("json_object")],
Annotated[ResponsesFormatTextJSONSchemaConfig, Tag("json_schema")],
],
)
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""Text response format configuration"""
@@ -25,8 +25,10 @@ from .responseswebsearchcalloutput import (
ResponsesWebSearchCallOutput,
ResponsesWebSearchCallOutputTypedDict,
)
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union
from typing_extensions import TypeAliasType
from typing_extensions import Annotated, TypeAliasType
ResponsesOutputItemTypedDict = TypeAliasType(
@@ -43,15 +45,15 @@ ResponsesOutputItemTypedDict = TypeAliasType(
r"""An output item from the response"""
ResponsesOutputItem = TypeAliasType(
"ResponsesOutputItem",
ResponsesOutputItem = Annotated[
Union[
ResponsesWebSearchCallOutput,
ResponsesOutputItemFileSearchCall,
ResponsesImageGenerationCall,
ResponsesOutputMessage,
ResponsesOutputItemReasoning,
ResponsesOutputItemFunctionCall,
Annotated[ResponsesOutputMessage, Tag("message")],
Annotated[ResponsesOutputItemReasoning, Tag("reasoning")],
Annotated[ResponsesOutputItemFunctionCall, Tag("function_call")],
Annotated[ResponsesWebSearchCallOutput, Tag("web_search_call")],
Annotated[ResponsesOutputItemFileSearchCall, Tag("file_search_call")],
Annotated[ResponsesImageGenerationCall, Tag("image_generation_call")],
],
)
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""An output item from the response"""
@@ -7,8 +7,10 @@ from .openairesponsesrefusalcontent import (
)
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from openrouter.types import BaseModel
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
ResponsesOutputMessageRole = Literal["assistant",]
@@ -52,10 +54,13 @@ ResponsesOutputMessageContentTypedDict = TypeAliasType(
)
ResponsesOutputMessageContent = TypeAliasType(
"ResponsesOutputMessageContent",
Union[OpenAIResponsesRefusalContent, ResponseOutputText],
)
ResponsesOutputMessageContent = Annotated[
Union[
Annotated[ResponseOutputText, Tag("output_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class ResponsesOutputMessageTypedDict(TypedDict):