mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-29 11:23:49 +08:00
feat: fix types and add reasoning_details to chat responses (#27)
This commit is contained in:
@@ -7,6 +7,17 @@ import sys
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ._schema0 import Schema0, Schema0Enum, Schema0TypedDict
|
||||
from ._schema3 import (
|
||||
Schema3,
|
||||
Schema3ReasoningEncrypted,
|
||||
Schema3ReasoningEncryptedTypedDict,
|
||||
Schema3ReasoningSummary,
|
||||
Schema3ReasoningSummaryTypedDict,
|
||||
Schema3ReasoningText,
|
||||
Schema3ReasoningTextTypedDict,
|
||||
Schema3TypedDict,
|
||||
Schema5,
|
||||
)
|
||||
from .activityitem import ActivityItem, ActivityItemTypedDict
|
||||
from .assistantmessage import (
|
||||
AssistantMessage,
|
||||
@@ -27,12 +38,8 @@ if TYPE_CHECKING:
|
||||
from .chatgenerationparams import (
|
||||
ChatGenerationParams,
|
||||
ChatGenerationParamsDataCollection,
|
||||
ChatGenerationParamsEngine,
|
||||
ChatGenerationParamsMaxPrice,
|
||||
ChatGenerationParamsMaxPriceTypedDict,
|
||||
ChatGenerationParamsPdf,
|
||||
ChatGenerationParamsPdfEngine,
|
||||
ChatGenerationParamsPdfTypedDict,
|
||||
ChatGenerationParamsPluginFileParser,
|
||||
ChatGenerationParamsPluginFileParserTypedDict,
|
||||
ChatGenerationParamsPluginModeration,
|
||||
@@ -53,17 +60,20 @@ if TYPE_CHECKING:
|
||||
ChatGenerationParamsResponseFormatTextTypedDict,
|
||||
ChatGenerationParamsResponseFormatUnion,
|
||||
ChatGenerationParamsResponseFormatUnionTypedDict,
|
||||
ChatGenerationParamsRoute,
|
||||
ChatGenerationParamsStop,
|
||||
ChatGenerationParamsStopTypedDict,
|
||||
ChatGenerationParamsTypedDict,
|
||||
Debug,
|
||||
DebugTypedDict,
|
||||
Effort,
|
||||
Engine,
|
||||
Pdf,
|
||||
PdfEngine,
|
||||
PdfTypedDict,
|
||||
Quantizations,
|
||||
Reasoning,
|
||||
ReasoningTypedDict,
|
||||
Sort,
|
||||
Route,
|
||||
)
|
||||
from .chatgenerationtokenusage import (
|
||||
ChatGenerationTokenUsage,
|
||||
@@ -448,17 +458,15 @@ if TYPE_CHECKING:
|
||||
IDModeration,
|
||||
IDResponseHealing,
|
||||
IDWeb,
|
||||
Ignore,
|
||||
IgnoreTypedDict,
|
||||
Only,
|
||||
OnlyTypedDict,
|
||||
OpenResponsesRequest,
|
||||
OpenResponsesRequestEngine,
|
||||
OpenResponsesRequestIgnore,
|
||||
OpenResponsesRequestIgnoreTypedDict,
|
||||
OpenResponsesRequestMaxPrice,
|
||||
OpenResponsesRequestMaxPriceTypedDict,
|
||||
OpenResponsesRequestPdf,
|
||||
OpenResponsesRequestPdfEngine,
|
||||
OpenResponsesRequestPdfTypedDict,
|
||||
OpenResponsesRequestOnly,
|
||||
OpenResponsesRequestOnlyTypedDict,
|
||||
OpenResponsesRequestOrder,
|
||||
OpenResponsesRequestOrderTypedDict,
|
||||
OpenResponsesRequestPluginFileParser,
|
||||
OpenResponsesRequestPluginFileParserTypedDict,
|
||||
OpenResponsesRequestPluginModeration,
|
||||
@@ -471,15 +479,14 @@ if TYPE_CHECKING:
|
||||
OpenResponsesRequestPluginWebTypedDict,
|
||||
OpenResponsesRequestProvider,
|
||||
OpenResponsesRequestProviderTypedDict,
|
||||
OpenResponsesRequestRoute,
|
||||
OpenResponsesRequestSort,
|
||||
OpenResponsesRequestSortTypedDict,
|
||||
OpenResponsesRequestToolFunction,
|
||||
OpenResponsesRequestToolFunctionTypedDict,
|
||||
OpenResponsesRequestToolUnion,
|
||||
OpenResponsesRequestToolUnionTypedDict,
|
||||
OpenResponsesRequestType,
|
||||
OpenResponsesRequestTypedDict,
|
||||
Order,
|
||||
OrderTypedDict,
|
||||
ServiceTier,
|
||||
Truncation,
|
||||
)
|
||||
@@ -613,13 +620,43 @@ if TYPE_CHECKING:
|
||||
PaymentRequiredResponseErrorData,
|
||||
PaymentRequiredResponseErrorDataTypedDict,
|
||||
)
|
||||
from .pdfparserengine import PDFParserEngine
|
||||
from .pdfparseroptions import PDFParserOptions, PDFParserOptionsTypedDict
|
||||
from .perrequestlimits import PerRequestLimits, PerRequestLimitsTypedDict
|
||||
from .providername import ProviderName
|
||||
from .provideroverloadedresponseerrordata import (
|
||||
ProviderOverloadedResponseErrorData,
|
||||
ProviderOverloadedResponseErrorDataTypedDict,
|
||||
)
|
||||
from .providerpreferences import (
|
||||
ProviderPreferences,
|
||||
ProviderPreferencesIgnore,
|
||||
ProviderPreferencesIgnoreTypedDict,
|
||||
ProviderPreferencesMaxPrice,
|
||||
ProviderPreferencesMaxPriceTypedDict,
|
||||
ProviderPreferencesOnly,
|
||||
ProviderPreferencesOnlyTypedDict,
|
||||
ProviderPreferencesOrder,
|
||||
ProviderPreferencesOrderTypedDict,
|
||||
ProviderPreferencesPartition,
|
||||
ProviderPreferencesProviderSort,
|
||||
ProviderPreferencesProviderSortConfig,
|
||||
ProviderPreferencesProviderSortConfigTypedDict,
|
||||
ProviderPreferencesSortUnion,
|
||||
ProviderPreferencesSortUnionTypedDict,
|
||||
ProviderPreferencesTypedDict,
|
||||
ProviderSortConfigEnum,
|
||||
ProviderSortConfigUnion,
|
||||
ProviderSortConfigUnionTypedDict,
|
||||
SortEnum,
|
||||
)
|
||||
from .providersort import ProviderSort
|
||||
from .providersortconfig import (
|
||||
Partition,
|
||||
ProviderSortConfig,
|
||||
ProviderSortConfigTypedDict,
|
||||
)
|
||||
from .providersortunion import ProviderSortUnion, ProviderSortUnionTypedDict
|
||||
from .publicendpoint import (
|
||||
Pricing,
|
||||
PricingTypedDict,
|
||||
@@ -809,6 +846,7 @@ if TYPE_CHECKING:
|
||||
UserMessageContentTypedDict,
|
||||
UserMessageTypedDict,
|
||||
)
|
||||
from .websearchengine import WebSearchEngine
|
||||
from .websearchpreviewtooluserlocation import (
|
||||
WebSearchPreviewToolUserLocation,
|
||||
WebSearchPreviewToolUserLocationType,
|
||||
@@ -835,12 +873,8 @@ __all__ = [
|
||||
"ChatErrorErrorTypedDict",
|
||||
"ChatGenerationParams",
|
||||
"ChatGenerationParamsDataCollection",
|
||||
"ChatGenerationParamsEngine",
|
||||
"ChatGenerationParamsMaxPrice",
|
||||
"ChatGenerationParamsMaxPriceTypedDict",
|
||||
"ChatGenerationParamsPdf",
|
||||
"ChatGenerationParamsPdfEngine",
|
||||
"ChatGenerationParamsPdfTypedDict",
|
||||
"ChatGenerationParamsPluginFileParser",
|
||||
"ChatGenerationParamsPluginFileParserTypedDict",
|
||||
"ChatGenerationParamsPluginModeration",
|
||||
@@ -861,7 +895,6 @@ __all__ = [
|
||||
"ChatGenerationParamsResponseFormatTextTypedDict",
|
||||
"ChatGenerationParamsResponseFormatUnion",
|
||||
"ChatGenerationParamsResponseFormatUnionTypedDict",
|
||||
"ChatGenerationParamsRoute",
|
||||
"ChatGenerationParamsStop",
|
||||
"ChatGenerationParamsStopTypedDict",
|
||||
"ChatGenerationParamsTypedDict",
|
||||
@@ -954,6 +987,7 @@ __all__ = [
|
||||
"EdgeNetworkTimeoutResponseErrorDataTypedDict",
|
||||
"Effort",
|
||||
"EndpointStatus",
|
||||
"Engine",
|
||||
"FileCitation",
|
||||
"FileCitationType",
|
||||
"FileCitationTypedDict",
|
||||
@@ -966,8 +1000,6 @@ __all__ = [
|
||||
"IDModeration",
|
||||
"IDResponseHealing",
|
||||
"IDWeb",
|
||||
"Ignore",
|
||||
"IgnoreTypedDict",
|
||||
"ImageGenerationStatus",
|
||||
"ImageURL",
|
||||
"ImageURLTypedDict",
|
||||
@@ -1006,8 +1038,6 @@ __all__ = [
|
||||
"NotFoundResponseErrorData",
|
||||
"NotFoundResponseErrorDataTypedDict",
|
||||
"Object",
|
||||
"Only",
|
||||
"OnlyTypedDict",
|
||||
"OpenAIResponsesAnnotation",
|
||||
"OpenAIResponsesAnnotationTypedDict",
|
||||
"OpenAIResponsesIncludable",
|
||||
@@ -1153,12 +1183,14 @@ __all__ = [
|
||||
"OpenResponsesReasoningType",
|
||||
"OpenResponsesReasoningTypedDict",
|
||||
"OpenResponsesRequest",
|
||||
"OpenResponsesRequestEngine",
|
||||
"OpenResponsesRequestIgnore",
|
||||
"OpenResponsesRequestIgnoreTypedDict",
|
||||
"OpenResponsesRequestMaxPrice",
|
||||
"OpenResponsesRequestMaxPriceTypedDict",
|
||||
"OpenResponsesRequestPdf",
|
||||
"OpenResponsesRequestPdfEngine",
|
||||
"OpenResponsesRequestPdfTypedDict",
|
||||
"OpenResponsesRequestOnly",
|
||||
"OpenResponsesRequestOnlyTypedDict",
|
||||
"OpenResponsesRequestOrder",
|
||||
"OpenResponsesRequestOrderTypedDict",
|
||||
"OpenResponsesRequestPluginFileParser",
|
||||
"OpenResponsesRequestPluginFileParserTypedDict",
|
||||
"OpenResponsesRequestPluginModeration",
|
||||
@@ -1171,7 +1203,8 @@ __all__ = [
|
||||
"OpenResponsesRequestPluginWebTypedDict",
|
||||
"OpenResponsesRequestProvider",
|
||||
"OpenResponsesRequestProviderTypedDict",
|
||||
"OpenResponsesRequestRoute",
|
||||
"OpenResponsesRequestSort",
|
||||
"OpenResponsesRequestSortTypedDict",
|
||||
"OpenResponsesRequestToolFunction",
|
||||
"OpenResponsesRequestToolFunctionTypedDict",
|
||||
"OpenResponsesRequestToolUnion",
|
||||
@@ -1237,8 +1270,6 @@ __all__ = [
|
||||
"OpenResponsesWebSearchToolFiltersTypedDict",
|
||||
"OpenResponsesWebSearchToolType",
|
||||
"OpenResponsesWebSearchToolTypedDict",
|
||||
"Order",
|
||||
"OrderTypedDict",
|
||||
"OutputItemImageGenerationCall",
|
||||
"OutputItemImageGenerationCallType",
|
||||
"OutputItemImageGenerationCallTypedDict",
|
||||
@@ -1256,15 +1287,22 @@ __all__ = [
|
||||
"OutputModality",
|
||||
"OutputTokensDetails",
|
||||
"OutputTokensDetailsTypedDict",
|
||||
"PDFParserEngine",
|
||||
"PDFParserOptions",
|
||||
"PDFParserOptionsTypedDict",
|
||||
"Parameter",
|
||||
"Part1",
|
||||
"Part1TypedDict",
|
||||
"Part2",
|
||||
"Part2TypedDict",
|
||||
"Partition",
|
||||
"PayloadTooLargeResponseErrorData",
|
||||
"PayloadTooLargeResponseErrorDataTypedDict",
|
||||
"PaymentRequiredResponseErrorData",
|
||||
"PaymentRequiredResponseErrorDataTypedDict",
|
||||
"Pdf",
|
||||
"PdfEngine",
|
||||
"PdfTypedDict",
|
||||
"PerRequestLimits",
|
||||
"PerRequestLimitsTypedDict",
|
||||
"Pricing",
|
||||
@@ -1276,7 +1314,30 @@ __all__ = [
|
||||
"ProviderName",
|
||||
"ProviderOverloadedResponseErrorData",
|
||||
"ProviderOverloadedResponseErrorDataTypedDict",
|
||||
"ProviderPreferences",
|
||||
"ProviderPreferencesIgnore",
|
||||
"ProviderPreferencesIgnoreTypedDict",
|
||||
"ProviderPreferencesMaxPrice",
|
||||
"ProviderPreferencesMaxPriceTypedDict",
|
||||
"ProviderPreferencesOnly",
|
||||
"ProviderPreferencesOnlyTypedDict",
|
||||
"ProviderPreferencesOrder",
|
||||
"ProviderPreferencesOrderTypedDict",
|
||||
"ProviderPreferencesPartition",
|
||||
"ProviderPreferencesProviderSort",
|
||||
"ProviderPreferencesProviderSortConfig",
|
||||
"ProviderPreferencesProviderSortConfigTypedDict",
|
||||
"ProviderPreferencesSortUnion",
|
||||
"ProviderPreferencesSortUnionTypedDict",
|
||||
"ProviderPreferencesTypedDict",
|
||||
"ProviderSort",
|
||||
"ProviderSortConfig",
|
||||
"ProviderSortConfigEnum",
|
||||
"ProviderSortConfigTypedDict",
|
||||
"ProviderSortConfigUnion",
|
||||
"ProviderSortConfigUnionTypedDict",
|
||||
"ProviderSortUnion",
|
||||
"ProviderSortUnionTypedDict",
|
||||
"PublicEndpoint",
|
||||
"PublicEndpointQuantization",
|
||||
"PublicEndpointTypedDict",
|
||||
@@ -1377,15 +1438,25 @@ __all__ = [
|
||||
"ResponsesWebSearchUserLocation",
|
||||
"ResponsesWebSearchUserLocationType",
|
||||
"ResponsesWebSearchUserLocationTypedDict",
|
||||
"Route",
|
||||
"Schema0",
|
||||
"Schema0Enum",
|
||||
"Schema0TypedDict",
|
||||
"Schema3",
|
||||
"Schema3ReasoningEncrypted",
|
||||
"Schema3ReasoningEncryptedTypedDict",
|
||||
"Schema3ReasoningSummary",
|
||||
"Schema3ReasoningSummaryTypedDict",
|
||||
"Schema3ReasoningText",
|
||||
"Schema3ReasoningTextTypedDict",
|
||||
"Schema3TypedDict",
|
||||
"Schema5",
|
||||
"Security",
|
||||
"SecurityTypedDict",
|
||||
"ServiceTier",
|
||||
"ServiceUnavailableResponseErrorData",
|
||||
"ServiceUnavailableResponseErrorDataTypedDict",
|
||||
"Sort",
|
||||
"SortEnum",
|
||||
"StreamOptions",
|
||||
"StreamOptionsTypedDict",
|
||||
"SystemMessage",
|
||||
@@ -1446,6 +1517,7 @@ __all__ = [
|
||||
"VideoURL1TypedDict",
|
||||
"VideoURL2",
|
||||
"VideoURL2TypedDict",
|
||||
"WebSearchEngine",
|
||||
"WebSearchPreviewToolUserLocation",
|
||||
"WebSearchPreviewToolUserLocationType",
|
||||
"WebSearchPreviewToolUserLocationTypedDict",
|
||||
@@ -1456,6 +1528,15 @@ _dynamic_imports: dict[str, str] = {
|
||||
"Schema0": "._schema0",
|
||||
"Schema0Enum": "._schema0",
|
||||
"Schema0TypedDict": "._schema0",
|
||||
"Schema3": "._schema3",
|
||||
"Schema3ReasoningEncrypted": "._schema3",
|
||||
"Schema3ReasoningEncryptedTypedDict": "._schema3",
|
||||
"Schema3ReasoningSummary": "._schema3",
|
||||
"Schema3ReasoningSummaryTypedDict": "._schema3",
|
||||
"Schema3ReasoningText": "._schema3",
|
||||
"Schema3ReasoningTextTypedDict": "._schema3",
|
||||
"Schema3TypedDict": "._schema3",
|
||||
"Schema5": "._schema3",
|
||||
"ActivityItem": ".activityitem",
|
||||
"ActivityItemTypedDict": ".activityitem",
|
||||
"AssistantMessage": ".assistantmessage",
|
||||
@@ -1473,12 +1554,8 @@ _dynamic_imports: dict[str, str] = {
|
||||
"CodeTypedDict": ".chaterror",
|
||||
"ChatGenerationParams": ".chatgenerationparams",
|
||||
"ChatGenerationParamsDataCollection": ".chatgenerationparams",
|
||||
"ChatGenerationParamsEngine": ".chatgenerationparams",
|
||||
"ChatGenerationParamsMaxPrice": ".chatgenerationparams",
|
||||
"ChatGenerationParamsMaxPriceTypedDict": ".chatgenerationparams",
|
||||
"ChatGenerationParamsPdf": ".chatgenerationparams",
|
||||
"ChatGenerationParamsPdfEngine": ".chatgenerationparams",
|
||||
"ChatGenerationParamsPdfTypedDict": ".chatgenerationparams",
|
||||
"ChatGenerationParamsPluginFileParser": ".chatgenerationparams",
|
||||
"ChatGenerationParamsPluginFileParserTypedDict": ".chatgenerationparams",
|
||||
"ChatGenerationParamsPluginModeration": ".chatgenerationparams",
|
||||
@@ -1499,17 +1576,20 @@ _dynamic_imports: dict[str, str] = {
|
||||
"ChatGenerationParamsResponseFormatTextTypedDict": ".chatgenerationparams",
|
||||
"ChatGenerationParamsResponseFormatUnion": ".chatgenerationparams",
|
||||
"ChatGenerationParamsResponseFormatUnionTypedDict": ".chatgenerationparams",
|
||||
"ChatGenerationParamsRoute": ".chatgenerationparams",
|
||||
"ChatGenerationParamsStop": ".chatgenerationparams",
|
||||
"ChatGenerationParamsStopTypedDict": ".chatgenerationparams",
|
||||
"ChatGenerationParamsTypedDict": ".chatgenerationparams",
|
||||
"Debug": ".chatgenerationparams",
|
||||
"DebugTypedDict": ".chatgenerationparams",
|
||||
"Effort": ".chatgenerationparams",
|
||||
"Engine": ".chatgenerationparams",
|
||||
"Pdf": ".chatgenerationparams",
|
||||
"PdfEngine": ".chatgenerationparams",
|
||||
"PdfTypedDict": ".chatgenerationparams",
|
||||
"Quantizations": ".chatgenerationparams",
|
||||
"Reasoning": ".chatgenerationparams",
|
||||
"ReasoningTypedDict": ".chatgenerationparams",
|
||||
"Sort": ".chatgenerationparams",
|
||||
"Route": ".chatgenerationparams",
|
||||
"ChatGenerationTokenUsage": ".chatgenerationtokenusage",
|
||||
"ChatGenerationTokenUsageTypedDict": ".chatgenerationtokenusage",
|
||||
"CompletionTokensDetails": ".chatgenerationtokenusage",
|
||||
@@ -1805,17 +1885,15 @@ _dynamic_imports: dict[str, str] = {
|
||||
"IDModeration": ".openresponsesrequest",
|
||||
"IDResponseHealing": ".openresponsesrequest",
|
||||
"IDWeb": ".openresponsesrequest",
|
||||
"Ignore": ".openresponsesrequest",
|
||||
"IgnoreTypedDict": ".openresponsesrequest",
|
||||
"Only": ".openresponsesrequest",
|
||||
"OnlyTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequest": ".openresponsesrequest",
|
||||
"OpenResponsesRequestEngine": ".openresponsesrequest",
|
||||
"OpenResponsesRequestIgnore": ".openresponsesrequest",
|
||||
"OpenResponsesRequestIgnoreTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestMaxPrice": ".openresponsesrequest",
|
||||
"OpenResponsesRequestMaxPriceTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestPdf": ".openresponsesrequest",
|
||||
"OpenResponsesRequestPdfEngine": ".openresponsesrequest",
|
||||
"OpenResponsesRequestPdfTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestOnly": ".openresponsesrequest",
|
||||
"OpenResponsesRequestOnlyTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestOrder": ".openresponsesrequest",
|
||||
"OpenResponsesRequestOrderTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestPluginFileParser": ".openresponsesrequest",
|
||||
"OpenResponsesRequestPluginFileParserTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestPluginModeration": ".openresponsesrequest",
|
||||
@@ -1828,15 +1906,14 @@ _dynamic_imports: dict[str, str] = {
|
||||
"OpenResponsesRequestPluginWebTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestProvider": ".openresponsesrequest",
|
||||
"OpenResponsesRequestProviderTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestRoute": ".openresponsesrequest",
|
||||
"OpenResponsesRequestSort": ".openresponsesrequest",
|
||||
"OpenResponsesRequestSortTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestToolFunction": ".openresponsesrequest",
|
||||
"OpenResponsesRequestToolFunctionTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestToolUnion": ".openresponsesrequest",
|
||||
"OpenResponsesRequestToolUnionTypedDict": ".openresponsesrequest",
|
||||
"OpenResponsesRequestType": ".openresponsesrequest",
|
||||
"OpenResponsesRequestTypedDict": ".openresponsesrequest",
|
||||
"Order": ".openresponsesrequest",
|
||||
"OrderTypedDict": ".openresponsesrequest",
|
||||
"ServiceTier": ".openresponsesrequest",
|
||||
"Truncation": ".openresponsesrequest",
|
||||
"OpenResponsesResponseText": ".openresponsesresponsetext",
|
||||
@@ -1945,12 +2022,40 @@ _dynamic_imports: dict[str, str] = {
|
||||
"PayloadTooLargeResponseErrorDataTypedDict": ".payloadtoolargeresponseerrordata",
|
||||
"PaymentRequiredResponseErrorData": ".paymentrequiredresponseerrordata",
|
||||
"PaymentRequiredResponseErrorDataTypedDict": ".paymentrequiredresponseerrordata",
|
||||
"PDFParserEngine": ".pdfparserengine",
|
||||
"PDFParserOptions": ".pdfparseroptions",
|
||||
"PDFParserOptionsTypedDict": ".pdfparseroptions",
|
||||
"PerRequestLimits": ".perrequestlimits",
|
||||
"PerRequestLimitsTypedDict": ".perrequestlimits",
|
||||
"ProviderName": ".providername",
|
||||
"ProviderOverloadedResponseErrorData": ".provideroverloadedresponseerrordata",
|
||||
"ProviderOverloadedResponseErrorDataTypedDict": ".provideroverloadedresponseerrordata",
|
||||
"ProviderPreferences": ".providerpreferences",
|
||||
"ProviderPreferencesIgnore": ".providerpreferences",
|
||||
"ProviderPreferencesIgnoreTypedDict": ".providerpreferences",
|
||||
"ProviderPreferencesMaxPrice": ".providerpreferences",
|
||||
"ProviderPreferencesMaxPriceTypedDict": ".providerpreferences",
|
||||
"ProviderPreferencesOnly": ".providerpreferences",
|
||||
"ProviderPreferencesOnlyTypedDict": ".providerpreferences",
|
||||
"ProviderPreferencesOrder": ".providerpreferences",
|
||||
"ProviderPreferencesOrderTypedDict": ".providerpreferences",
|
||||
"ProviderPreferencesPartition": ".providerpreferences",
|
||||
"ProviderPreferencesProviderSort": ".providerpreferences",
|
||||
"ProviderPreferencesProviderSortConfig": ".providerpreferences",
|
||||
"ProviderPreferencesProviderSortConfigTypedDict": ".providerpreferences",
|
||||
"ProviderPreferencesSortUnion": ".providerpreferences",
|
||||
"ProviderPreferencesSortUnionTypedDict": ".providerpreferences",
|
||||
"ProviderPreferencesTypedDict": ".providerpreferences",
|
||||
"ProviderSortConfigEnum": ".providerpreferences",
|
||||
"ProviderSortConfigUnion": ".providerpreferences",
|
||||
"ProviderSortConfigUnionTypedDict": ".providerpreferences",
|
||||
"SortEnum": ".providerpreferences",
|
||||
"ProviderSort": ".providersort",
|
||||
"Partition": ".providersortconfig",
|
||||
"ProviderSortConfig": ".providersortconfig",
|
||||
"ProviderSortConfigTypedDict": ".providersortconfig",
|
||||
"ProviderSortUnion": ".providersortunion",
|
||||
"ProviderSortUnionTypedDict": ".providersortunion",
|
||||
"Pricing": ".publicendpoint",
|
||||
"PricingTypedDict": ".publicendpoint",
|
||||
"PublicEndpoint": ".publicendpoint",
|
||||
@@ -2082,6 +2187,7 @@ _dynamic_imports: dict[str, str] = {
|
||||
"UserMessageContent": ".usermessage",
|
||||
"UserMessageContentTypedDict": ".usermessage",
|
||||
"UserMessageTypedDict": ".usermessage",
|
||||
"WebSearchEngine": ".websearchengine",
|
||||
"WebSearchPreviewToolUserLocation": ".websearchpreviewtooluserlocation",
|
||||
"WebSearchPreviewToolUserLocationType": ".websearchpreviewtooluserlocation",
|
||||
"WebSearchPreviewToolUserLocationTypedDict": ".websearchpreviewtooluserlocation",
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
"""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
|
||||
|
||||
|
||||
Schema5 = Union[
|
||||
Literal[
|
||||
"unknown",
|
||||
"openai-responses-v1",
|
||||
"xai-responses-v1",
|
||||
"anthropic-claude-v1",
|
||||
"google-gemini-v1",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class Schema3ReasoningTextTypedDict(TypedDict):
|
||||
type: Literal["reasoning.text"]
|
||||
text: NotRequired[Nullable[str]]
|
||||
signature: NotRequired[Nullable[str]]
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[Schema5]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class Schema3ReasoningText(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[Schema5], 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 Schema3ReasoningEncryptedTypedDict(TypedDict):
|
||||
data: str
|
||||
type: Literal["reasoning.encrypted"]
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[Schema5]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class Schema3ReasoningEncrypted(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[Schema5], 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 Schema3ReasoningSummaryTypedDict(TypedDict):
|
||||
summary: str
|
||||
type: Literal["reasoning.summary"]
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[Schema5]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class Schema3ReasoningSummary(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[Schema5], 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
|
||||
|
||||
|
||||
Schema3TypedDict = TypeAliasType(
|
||||
"Schema3TypedDict",
|
||||
Union[
|
||||
Schema3ReasoningSummaryTypedDict,
|
||||
Schema3ReasoningEncryptedTypedDict,
|
||||
Schema3ReasoningTextTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Schema3 = Annotated[
|
||||
Union[
|
||||
Annotated[Schema3ReasoningSummary, Tag("reasoning.summary")],
|
||||
Annotated[Schema3ReasoningEncrypted, Tag("reasoning.encrypted")],
|
||||
Annotated[Schema3ReasoningText, Tag("reasoning.text")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
from ._schema0 import Schema0, Schema0TypedDict
|
||||
from .chatstreamoptions import ChatStreamOptions, ChatStreamOptionsTypedDict
|
||||
from .message import Message, MessageTypedDict
|
||||
from .providersortunion import ProviderSortUnion, ProviderSortUnionTypedDict
|
||||
from .reasoningsummaryverbosity import ReasoningSummaryVerbosity
|
||||
from .responseformatjsonschema import (
|
||||
ResponseFormatJSONSchema,
|
||||
@@ -55,16 +56,6 @@ Quantizations = Union[
|
||||
]
|
||||
|
||||
|
||||
Sort = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
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."""
|
||||
|
||||
@@ -114,14 +105,14 @@ class ChatGenerationParamsProviderTypedDict(TypedDict):
|
||||
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
||||
quantizations: NotRequired[Nullable[List[Quantizations]]]
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
sort: NotRequired[Nullable[Sort]]
|
||||
sort: NotRequired[Nullable[ProviderSortUnionTypedDict]]
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
max_price: NotRequired[ChatGenerationParamsMaxPriceTypedDict]
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
preferred_min_throughput: NotRequired[Nullable[float]]
|
||||
preferred_max_latency: NotRequired[Nullable[float]]
|
||||
min_throughput: NotRequired[Nullable[float]]
|
||||
r"""The minimum throughput (in tokens per second) required for this request. Only providers serving the model with at least this throughput will be used."""
|
||||
max_latency: NotRequired[Nullable[float]]
|
||||
r"""The maximum latency (in seconds) allowed for this request. Only providers serving the model with better than this latency will be used."""
|
||||
|
||||
|
||||
class ChatGenerationParamsProvider(BaseModel):
|
||||
@@ -163,19 +154,19 @@ class ChatGenerationParamsProvider(BaseModel):
|
||||
] = UNSET
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
|
||||
sort: Annotated[
|
||||
OptionalNullable[Sort], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
sort: OptionalNullable[ProviderSortUnion] = UNSET
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
max_price: Optional[ChatGenerationParamsMaxPrice] = None
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
preferred_min_throughput: OptionalNullable[float] = UNSET
|
||||
|
||||
preferred_max_latency: OptionalNullable[float] = UNSET
|
||||
|
||||
min_throughput: OptionalNullable[float] = UNSET
|
||||
r"""The minimum throughput (in tokens per second) required for this request. Only providers serving the model with at least this throughput will be used."""
|
||||
|
||||
max_latency: OptionalNullable[float] = UNSET
|
||||
r"""The maximum latency (in seconds) allowed for this request. Only providers serving the model with better than this latency will be used."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
@@ -191,6 +182,8 @@ class ChatGenerationParamsProvider(BaseModel):
|
||||
"quantizations",
|
||||
"sort",
|
||||
"max_price",
|
||||
"preferred_min_throughput",
|
||||
"preferred_max_latency",
|
||||
"min_throughput",
|
||||
"max_latency",
|
||||
]
|
||||
@@ -205,6 +198,8 @@ class ChatGenerationParamsProvider(BaseModel):
|
||||
"ignore",
|
||||
"quantizations",
|
||||
"sort",
|
||||
"preferred_min_throughput",
|
||||
"preferred_max_latency",
|
||||
"min_throughput",
|
||||
"max_latency",
|
||||
]
|
||||
@@ -252,7 +247,7 @@ class ChatGenerationParamsPluginResponseHealing(BaseModel):
|
||||
enabled: Optional[bool] = None
|
||||
|
||||
|
||||
ChatGenerationParamsPdfEngine = Union[
|
||||
PdfEngine = Union[
|
||||
Literal[
|
||||
"mistral-ocr",
|
||||
"pdf-text",
|
||||
@@ -262,22 +257,20 @@ ChatGenerationParamsPdfEngine = Union[
|
||||
]
|
||||
|
||||
|
||||
class ChatGenerationParamsPdfTypedDict(TypedDict):
|
||||
engine: NotRequired[ChatGenerationParamsPdfEngine]
|
||||
class PdfTypedDict(TypedDict):
|
||||
engine: NotRequired[PdfEngine]
|
||||
|
||||
|
||||
class ChatGenerationParamsPdf(BaseModel):
|
||||
class Pdf(BaseModel):
|
||||
engine: Annotated[
|
||||
Optional[ChatGenerationParamsPdfEngine],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
Optional[PdfEngine], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginFileParserTypedDict(TypedDict):
|
||||
id: Literal["file-parser"]
|
||||
enabled: NotRequired[bool]
|
||||
max_files: NotRequired[float]
|
||||
pdf: NotRequired[ChatGenerationParamsPdfTypedDict]
|
||||
pdf: NotRequired[PdfTypedDict]
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginFileParser(BaseModel):
|
||||
@@ -290,12 +283,10 @@ class ChatGenerationParamsPluginFileParser(BaseModel):
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
|
||||
max_files: Optional[float] = None
|
||||
|
||||
pdf: Optional[ChatGenerationParamsPdf] = None
|
||||
pdf: Optional[Pdf] = None
|
||||
|
||||
|
||||
ChatGenerationParamsEngine = Union[
|
||||
Engine = Union[
|
||||
Literal[
|
||||
"native",
|
||||
"exa",
|
||||
@@ -309,7 +300,7 @@ class ChatGenerationParamsPluginWebTypedDict(TypedDict):
|
||||
enabled: NotRequired[bool]
|
||||
max_results: NotRequired[float]
|
||||
search_prompt: NotRequired[str]
|
||||
engine: NotRequired[ChatGenerationParamsEngine]
|
||||
engine: NotRequired[Engine]
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginWeb(BaseModel):
|
||||
@@ -324,9 +315,9 @@ class ChatGenerationParamsPluginWeb(BaseModel):
|
||||
|
||||
search_prompt: Optional[str] = None
|
||||
|
||||
engine: Annotated[
|
||||
Optional[ChatGenerationParamsEngine], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
engine: Annotated[Optional[Engine], PlainValidator(validate_open_enum(False))] = (
|
||||
None
|
||||
)
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginModerationTypedDict(TypedDict):
|
||||
@@ -362,7 +353,7 @@ ChatGenerationParamsPluginUnion = Annotated[
|
||||
]
|
||||
|
||||
|
||||
ChatGenerationParamsRoute = Union[
|
||||
Route = Union[
|
||||
Literal[
|
||||
"fallback",
|
||||
"sort",
|
||||
@@ -373,12 +364,12 @@ ChatGenerationParamsRoute = Union[
|
||||
|
||||
Effort = Union[
|
||||
Literal[
|
||||
"none",
|
||||
"minimal",
|
||||
"low",
|
||||
"medium",
|
||||
"high",
|
||||
"xhigh",
|
||||
"high",
|
||||
"medium",
|
||||
"low",
|
||||
"minimal",
|
||||
"none",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -513,8 +504,7 @@ class ChatGenerationParamsTypedDict(TypedDict):
|
||||
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."""
|
||||
route: NotRequired[Nullable[ChatGenerationParamsRoute]]
|
||||
r"""Routing strategy for multiple models: \"fallback\" (default) uses secondary models as backups, \"sort\" sorts all endpoints together by routing criteria."""
|
||||
route: NotRequired[Nullable[Route]]
|
||||
user: NotRequired[str]
|
||||
session_id: NotRequired[str]
|
||||
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters."""
|
||||
@@ -551,10 +541,8 @@ class ChatGenerationParams(BaseModel):
|
||||
r"""Plugins you want to enable for this request, including their settings."""
|
||||
|
||||
route: Annotated[
|
||||
OptionalNullable[ChatGenerationParamsRoute],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
OptionalNullable[Route], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
r"""Routing strategy for multiple models: \"fallback\" (default) uses secondary models as backups, \"sort\" sorts all endpoints together by routing criteria."""
|
||||
|
||||
user: Optional[str] = None
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from ._schema3 import Schema3, Schema3TypedDict
|
||||
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
||||
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||
from .chatmessagetokenlogprobs import (
|
||||
@@ -17,6 +18,7 @@ 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 List, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
@@ -24,6 +26,7 @@ class ChatResponseChoiceTypedDict(TypedDict):
|
||||
finish_reason: Nullable[ChatCompletionFinishReason]
|
||||
index: float
|
||||
message: AssistantMessageTypedDict
|
||||
reasoning_details: NotRequired[List[Schema3TypedDict]]
|
||||
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
||||
|
||||
|
||||
@@ -36,11 +39,13 @@ class ChatResponseChoice(BaseModel):
|
||||
|
||||
message: AssistantMessage
|
||||
|
||||
reasoning_details: Optional[List[Schema3]] = None
|
||||
|
||||
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["logprobs"]
|
||||
optional_fields = ["reasoning_details", "logprobs"]
|
||||
nullable_fields = ["finish_reason", "logprobs"]
|
||||
null_default_fields = []
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from ._schema3 import Schema3, Schema3TypedDict
|
||||
from .chatstreamingmessagetoolcall import (
|
||||
ChatStreamingMessageToolCall,
|
||||
ChatStreamingMessageToolCallTypedDict,
|
||||
@@ -26,6 +27,7 @@ class ChatStreamingMessageChunkTypedDict(TypedDict):
|
||||
reasoning: NotRequired[Nullable[str]]
|
||||
refusal: NotRequired[Nullable[str]]
|
||||
tool_calls: NotRequired[List[ChatStreamingMessageToolCallTypedDict]]
|
||||
reasoning_details: NotRequired[List[Schema3TypedDict]]
|
||||
|
||||
|
||||
class ChatStreamingMessageChunk(BaseModel):
|
||||
@@ -39,9 +41,18 @@ class ChatStreamingMessageChunk(BaseModel):
|
||||
|
||||
tool_calls: Optional[List[ChatStreamingMessageToolCall]] = None
|
||||
|
||||
reasoning_details: Optional[List[Schema3]] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["role", "content", "reasoning", "refusal", "tool_calls"]
|
||||
optional_fields = [
|
||||
"role",
|
||||
"content",
|
||||
"reasoning",
|
||||
"refusal",
|
||||
"tool_calls",
|
||||
"reasoning_details",
|
||||
]
|
||||
nullable_fields = ["content", "reasoning", "refusal"]
|
||||
null_default_fields = []
|
||||
|
||||
|
||||
@@ -33,9 +33,12 @@ from .openresponseswebsearchtool import (
|
||||
OpenResponsesWebSearchTool,
|
||||
OpenResponsesWebSearchToolTypedDict,
|
||||
)
|
||||
from .pdfparseroptions import PDFParserOptions, PDFParserOptionsTypedDict
|
||||
from .providername import ProviderName
|
||||
from .providersort import ProviderSort
|
||||
from .providersortconfig import ProviderSortConfig, ProviderSortConfigTypedDict
|
||||
from .quantization import Quantization
|
||||
from .websearchengine import WebSearchEngine
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
@@ -148,33 +151,57 @@ Truncation = Union[
|
||||
]
|
||||
|
||||
|
||||
OrderTypedDict = TypeAliasType("OrderTypedDict", Union[ProviderName, str])
|
||||
OpenResponsesRequestOrderTypedDict = TypeAliasType(
|
||||
"OpenResponsesRequestOrderTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
Order = TypeAliasType(
|
||||
"Order",
|
||||
OpenResponsesRequestOrder = TypeAliasType(
|
||||
"OpenResponsesRequestOrder",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
OnlyTypedDict = TypeAliasType("OnlyTypedDict", Union[ProviderName, str])
|
||||
OpenResponsesRequestOnlyTypedDict = TypeAliasType(
|
||||
"OpenResponsesRequestOnlyTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
Only = TypeAliasType(
|
||||
"Only",
|
||||
OpenResponsesRequestOnly = TypeAliasType(
|
||||
"OpenResponsesRequestOnly",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
IgnoreTypedDict = TypeAliasType("IgnoreTypedDict", Union[ProviderName, str])
|
||||
OpenResponsesRequestIgnoreTypedDict = TypeAliasType(
|
||||
"OpenResponsesRequestIgnoreTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
Ignore = TypeAliasType(
|
||||
"Ignore",
|
||||
OpenResponsesRequestIgnore = TypeAliasType(
|
||||
"OpenResponsesRequestIgnore",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesRequestSortTypedDict = TypeAliasType(
|
||||
"OpenResponsesRequestSortTypedDict",
|
||||
Union[ProviderSortConfigTypedDict, ProviderSort, Any],
|
||||
)
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
|
||||
OpenResponsesRequestSort = TypeAliasType(
|
||||
"OpenResponsesRequestSort",
|
||||
Union[
|
||||
ProviderSortConfig,
|
||||
Annotated[ProviderSort, PlainValidator(validate_open_enum(False))],
|
||||
Any,
|
||||
],
|
||||
)
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
|
||||
class OpenResponsesRequestMaxPriceTypedDict(TypedDict):
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
@@ -230,22 +257,26 @@ class OpenResponsesRequestProviderTypedDict(TypedDict):
|
||||
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]]
|
||||
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[OrderTypedDict]]]
|
||||
order: NotRequired[Nullable[List[OpenResponsesRequestOrderTypedDict]]]
|
||||
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[OnlyTypedDict]]]
|
||||
only: NotRequired[Nullable[List[OpenResponsesRequestOnlyTypedDict]]]
|
||||
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[IgnoreTypedDict]]]
|
||||
ignore: NotRequired[Nullable[List[OpenResponsesRequestIgnoreTypedDict]]]
|
||||
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[ProviderSort]]
|
||||
sort: NotRequired[Nullable[OpenResponsesRequestSortTypedDict]]
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
max_price: NotRequired[OpenResponsesRequestMaxPriceTypedDict]
|
||||
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[float]]
|
||||
r"""Preferred minimum throughput (in tokens per second). Endpoints below this threshold 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[float]]
|
||||
r"""Preferred maximum latency (in seconds). Endpoints above this threshold 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."""
|
||||
min_throughput: NotRequired[Nullable[float]]
|
||||
r"""The minimum throughput (in tokens per second) required for this request. Only providers serving the model with at least this throughput will be used."""
|
||||
r"""**DEPRECATED** Use preferred_min_throughput instead. Backwards-compatible alias for preferred_min_throughput."""
|
||||
max_latency: NotRequired[Nullable[float]]
|
||||
r"""The maximum latency (in seconds) allowed for this request. Only providers serving the model with better than this latency will be used."""
|
||||
r"""**DEPRECATED** Use preferred_max_latency instead. Backwards-compatible alias for preferred_max_latency."""
|
||||
|
||||
|
||||
class OpenResponsesRequestProvider(BaseModel):
|
||||
@@ -276,13 +307,13 @@ class OpenResponsesRequestProvider(BaseModel):
|
||||
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[Order]] = UNSET
|
||||
order: OptionalNullable[List[OpenResponsesRequestOrder]] = 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[Only]] = UNSET
|
||||
only: OptionalNullable[List[OpenResponsesRequestOnly]] = 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[Ignore]] = UNSET
|
||||
ignore: OptionalNullable[List[OpenResponsesRequestIgnore]] = 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[
|
||||
@@ -290,19 +321,33 @@ class OpenResponsesRequestProvider(BaseModel):
|
||||
] = UNSET
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
|
||||
sort: Annotated[
|
||||
OptionalNullable[ProviderSort], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
sort: OptionalNullable[OpenResponsesRequestSort] = UNSET
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
max_price: Optional[OpenResponsesRequestMaxPrice] = None
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
min_throughput: OptionalNullable[float] = UNSET
|
||||
r"""The minimum throughput (in tokens per second) required for this request. Only providers serving the model with at least this throughput will be used."""
|
||||
preferred_min_throughput: OptionalNullable[float] = UNSET
|
||||
r"""Preferred minimum throughput (in tokens per second). Endpoints below this threshold may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
|
||||
|
||||
max_latency: OptionalNullable[float] = UNSET
|
||||
r"""The maximum latency (in seconds) allowed for this request. Only providers serving the model with better than this latency will be used."""
|
||||
preferred_max_latency: OptionalNullable[float] = UNSET
|
||||
r"""Preferred maximum latency (in seconds). Endpoints above this threshold 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."""
|
||||
|
||||
min_throughput: Annotated[
|
||||
OptionalNullable[float],
|
||||
pydantic.Field(
|
||||
deprecated="warning: ** DEPRECATED ** - Use preferred_min_throughput instead.."
|
||||
),
|
||||
] = UNSET
|
||||
r"""**DEPRECATED** Use preferred_min_throughput instead. Backwards-compatible alias for preferred_min_throughput."""
|
||||
|
||||
max_latency: Annotated[
|
||||
OptionalNullable[float],
|
||||
pydantic.Field(
|
||||
deprecated="warning: ** DEPRECATED ** - Use preferred_max_latency instead.."
|
||||
),
|
||||
] = UNSET
|
||||
r"""**DEPRECATED** Use preferred_max_latency instead. Backwards-compatible alias for preferred_max_latency."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
@@ -318,6 +363,8 @@ class OpenResponsesRequestProvider(BaseModel):
|
||||
"quantizations",
|
||||
"sort",
|
||||
"max_price",
|
||||
"preferred_min_throughput",
|
||||
"preferred_max_latency",
|
||||
"min_throughput",
|
||||
"max_latency",
|
||||
]
|
||||
@@ -332,6 +379,8 @@ class OpenResponsesRequestProvider(BaseModel):
|
||||
"ignore",
|
||||
"quantizations",
|
||||
"sort",
|
||||
"preferred_min_throughput",
|
||||
"preferred_max_latency",
|
||||
"min_throughput",
|
||||
"max_latency",
|
||||
]
|
||||
@@ -381,33 +430,12 @@ class OpenResponsesRequestPluginResponseHealing(BaseModel):
|
||||
IDFileParser = Literal["file-parser",]
|
||||
|
||||
|
||||
OpenResponsesRequestPdfEngine = Union[
|
||||
Literal[
|
||||
"mistral-ocr",
|
||||
"pdf-text",
|
||||
"native",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesRequestPdfTypedDict(TypedDict):
|
||||
engine: NotRequired[OpenResponsesRequestPdfEngine]
|
||||
|
||||
|
||||
class OpenResponsesRequestPdf(BaseModel):
|
||||
engine: Annotated[
|
||||
Optional[OpenResponsesRequestPdfEngine],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = None
|
||||
|
||||
|
||||
class OpenResponsesRequestPluginFileParserTypedDict(TypedDict):
|
||||
id: IDFileParser
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the file-parser plugin for this request. Defaults to true."""
|
||||
max_files: NotRequired[float]
|
||||
pdf: NotRequired[OpenResponsesRequestPdfTypedDict]
|
||||
pdf: NotRequired[PDFParserOptionsTypedDict]
|
||||
r"""Options for PDF parsing."""
|
||||
|
||||
|
||||
class OpenResponsesRequestPluginFileParser(BaseModel):
|
||||
@@ -416,30 +444,21 @@ class OpenResponsesRequestPluginFileParser(BaseModel):
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the file-parser plugin for this request. Defaults to true."""
|
||||
|
||||
max_files: Optional[float] = None
|
||||
|
||||
pdf: Optional[OpenResponsesRequestPdf] = None
|
||||
pdf: Optional[PDFParserOptions] = None
|
||||
r"""Options for PDF parsing."""
|
||||
|
||||
|
||||
IDWeb = Literal["web",]
|
||||
|
||||
|
||||
OpenResponsesRequestEngine = Union[
|
||||
Literal[
|
||||
"native",
|
||||
"exa",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesRequestPluginWebTypedDict(TypedDict):
|
||||
id: IDWeb
|
||||
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[OpenResponsesRequestEngine]
|
||||
engine: NotRequired[WebSearchEngine]
|
||||
r"""The search engine to use for web search."""
|
||||
|
||||
|
||||
class OpenResponsesRequestPluginWeb(BaseModel):
|
||||
@@ -453,8 +472,9 @@ class OpenResponsesRequestPluginWeb(BaseModel):
|
||||
search_prompt: Optional[str] = None
|
||||
|
||||
engine: Annotated[
|
||||
Optional[OpenResponsesRequestEngine], PlainValidator(validate_open_enum(False))
|
||||
Optional[WebSearchEngine], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""The search engine to use for web search."""
|
||||
|
||||
|
||||
IDModeration = Literal["moderation",]
|
||||
@@ -490,16 +510,6 @@ OpenResponsesRequestPluginUnion = Annotated[
|
||||
]
|
||||
|
||||
|
||||
OpenResponsesRequestRoute = Union[
|
||||
Literal[
|
||||
"fallback",
|
||||
"sort",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Routing strategy for multiple models: \"fallback\" (default) uses secondary models as backups, \"sort\" sorts all endpoints together by routing criteria."""
|
||||
|
||||
|
||||
class OpenResponsesRequestTypedDict(TypedDict):
|
||||
r"""Request schema for Responses endpoint"""
|
||||
|
||||
@@ -535,8 +545,6 @@ class OpenResponsesRequestTypedDict(TypedDict):
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
plugins: NotRequired[List[OpenResponsesRequestPluginUnionTypedDict]]
|
||||
r"""Plugins you want to enable for this request, including their settings."""
|
||||
route: NotRequired[Nullable[OpenResponsesRequestRoute]]
|
||||
r"""Routing strategy for multiple models: \"fallback\" (default) uses secondary models as backups, \"sort\" sorts all endpoints together by routing criteria."""
|
||||
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]
|
||||
@@ -615,12 +623,6 @@ class OpenResponsesRequest(BaseModel):
|
||||
plugins: Optional[List[OpenResponsesRequestPluginUnion]] = None
|
||||
r"""Plugins you want to enable for this request, including their settings."""
|
||||
|
||||
route: Annotated[
|
||||
OptionalNullable[OpenResponsesRequestRoute],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""Routing strategy for multiple models: \"fallback\" (default) uses secondary models as backups, \"sort\" sorts all endpoints together by routing criteria."""
|
||||
|
||||
user: Optional[str] = None
|
||||
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."""
|
||||
|
||||
@@ -656,7 +658,6 @@ class OpenResponsesRequest(BaseModel):
|
||||
"stream",
|
||||
"provider",
|
||||
"plugins",
|
||||
"route",
|
||||
"user",
|
||||
"session_id",
|
||||
]
|
||||
@@ -676,7 +677,6 @@ class OpenResponsesRequest(BaseModel):
|
||||
"safety_identifier",
|
||||
"truncation",
|
||||
"provider",
|
||||
"route",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ Parameter = Union[
|
||||
"parallel_tool_calls",
|
||||
"include_reasoning",
|
||||
"reasoning",
|
||||
"reasoning_effort",
|
||||
"web_search_options",
|
||||
"verbosity",
|
||||
],
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
PDFParserEngine = Union[
|
||||
Literal[
|
||||
"mistral-ocr",
|
||||
"pdf-text",
|
||||
"native",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The engine to use for parsing PDF files."""
|
||||
@@ -0,0 +1,25 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .pdfparserengine import PDFParserEngine
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class PDFParserOptionsTypedDict(TypedDict):
|
||||
r"""Options for PDF parsing."""
|
||||
|
||||
engine: NotRequired[PDFParserEngine]
|
||||
r"""The engine to use for parsing PDF files."""
|
||||
|
||||
|
||||
class PDFParserOptions(BaseModel):
|
||||
r"""Options for PDF parsing."""
|
||||
|
||||
engine: Annotated[
|
||||
Optional[PDFParserEngine], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""The engine to use for parsing PDF files."""
|
||||
@@ -0,0 +1,375 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .datacollection import DataCollection
|
||||
from .providername import ProviderName
|
||||
from .providersort import ProviderSort
|
||||
from .quantization import Quantization
|
||||
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 List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ProviderPreferencesOrderTypedDict = TypeAliasType(
|
||||
"ProviderPreferencesOrderTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
ProviderPreferencesOrder = TypeAliasType(
|
||||
"ProviderPreferencesOrder",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
ProviderPreferencesOnlyTypedDict = TypeAliasType(
|
||||
"ProviderPreferencesOnlyTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
ProviderPreferencesOnly = TypeAliasType(
|
||||
"ProviderPreferencesOnly",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
ProviderPreferencesIgnoreTypedDict = TypeAliasType(
|
||||
"ProviderPreferencesIgnoreTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
ProviderPreferencesIgnore = TypeAliasType(
|
||||
"ProviderPreferencesIgnore",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
SortEnum = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
ProviderSortConfigEnum = Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
]
|
||||
|
||||
|
||||
ProviderPreferencesPartition = Union[
|
||||
Literal[
|
||||
"model",
|
||||
"none",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ProviderPreferencesProviderSortConfigTypedDict(TypedDict):
|
||||
by: NotRequired[Nullable[ProviderSort]]
|
||||
partition: NotRequired[Nullable[ProviderPreferencesPartition]]
|
||||
|
||||
|
||||
class ProviderPreferencesProviderSortConfig(BaseModel):
|
||||
by: Annotated[
|
||||
OptionalNullable[ProviderSort], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
partition: Annotated[
|
||||
OptionalNullable[ProviderPreferencesPartition],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["by", "partition"]
|
||||
nullable_fields = ["by", "partition"]
|
||||
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
|
||||
|
||||
|
||||
ProviderSortConfigUnionTypedDict = TypeAliasType(
|
||||
"ProviderSortConfigUnionTypedDict",
|
||||
Union[ProviderPreferencesProviderSortConfigTypedDict, ProviderSortConfigEnum],
|
||||
)
|
||||
|
||||
|
||||
ProviderSortConfigUnion = TypeAliasType(
|
||||
"ProviderSortConfigUnion",
|
||||
Union[ProviderPreferencesProviderSortConfig, ProviderSortConfigEnum],
|
||||
)
|
||||
|
||||
|
||||
ProviderPreferencesProviderSort = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
ProviderPreferencesSortUnionTypedDict = TypeAliasType(
|
||||
"ProviderPreferencesSortUnionTypedDict",
|
||||
Union[ProviderPreferencesProviderSort, ProviderSortConfigUnionTypedDict, SortEnum],
|
||||
)
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
|
||||
ProviderPreferencesSortUnion = TypeAliasType(
|
||||
"ProviderPreferencesSortUnion",
|
||||
Union[
|
||||
Annotated[
|
||||
ProviderPreferencesProviderSort, PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
ProviderSortConfigUnion,
|
||||
Annotated[SortEnum, 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 ProviderPreferencesMaxPriceTypedDict(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"""A value in string format that is a large number"""
|
||||
completion: NotRequired[str]
|
||||
r"""A value in string format that is a large number"""
|
||||
image: NotRequired[str]
|
||||
r"""A value in string format that is a large number"""
|
||||
audio: NotRequired[str]
|
||||
r"""A value in string format that is a large number"""
|
||||
request: NotRequired[str]
|
||||
r"""A value in string format that is a large number"""
|
||||
|
||||
|
||||
class ProviderPreferencesMaxPrice(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"""A value in string format that is a large number"""
|
||||
|
||||
completion: Optional[str] = None
|
||||
r"""A value in string format that is a large number"""
|
||||
|
||||
image: Optional[str] = None
|
||||
r"""A value in string format that is a large number"""
|
||||
|
||||
audio: Optional[str] = None
|
||||
r"""A value in string format that is a large number"""
|
||||
|
||||
request: Optional[str] = None
|
||||
r"""A value in string format that is a large number"""
|
||||
|
||||
|
||||
class ProviderPreferencesTypedDict(TypedDict):
|
||||
r"""Provider routing preferences for the request."""
|
||||
|
||||
allow_fallbacks: NotRequired[Nullable[bool]]
|
||||
r"""Whether to allow backup providers to serve requests
|
||||
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
|
||||
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
|
||||
|
||||
"""
|
||||
require_parameters: NotRequired[Nullable[bool]]
|
||||
r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest."""
|
||||
data_collection: NotRequired[Nullable[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]]
|
||||
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[ProviderPreferencesOrderTypedDict]]]
|
||||
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[ProviderPreferencesOnlyTypedDict]]]
|
||||
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[ProviderPreferencesIgnoreTypedDict]]]
|
||||
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[ProviderPreferencesSortUnionTypedDict]]
|
||||
max_price: NotRequired[ProviderPreferencesMaxPriceTypedDict]
|
||||
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[float]]
|
||||
r"""Preferred minimum throughput (in tokens per second). Endpoints below this threshold 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[float]]
|
||||
r"""Preferred maximum latency (in seconds). Endpoints above this threshold 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."""
|
||||
min_throughput: NotRequired[Nullable[float]]
|
||||
r"""**DEPRECATED** Use preferred_min_throughput instead. Backwards-compatible alias for preferred_min_throughput."""
|
||||
max_latency: NotRequired[Nullable[float]]
|
||||
r"""**DEPRECATED** Use preferred_max_latency instead. Backwards-compatible alias for preferred_max_latency."""
|
||||
|
||||
|
||||
class ProviderPreferences(BaseModel):
|
||||
r"""Provider routing preferences for the request."""
|
||||
|
||||
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[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[ProviderPreferencesOrder]] = 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[ProviderPreferencesOnly]] = 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[ProviderPreferencesIgnore]] = 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[Quantization, PlainValidator(validate_open_enum(False))]]
|
||||
] = UNSET
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
|
||||
sort: OptionalNullable[ProviderPreferencesSortUnion] = UNSET
|
||||
|
||||
max_price: Optional[ProviderPreferencesMaxPrice] = 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[float] = UNSET
|
||||
r"""Preferred minimum throughput (in tokens per second). Endpoints below this threshold 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[float] = UNSET
|
||||
r"""Preferred maximum latency (in seconds). Endpoints above this threshold 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."""
|
||||
|
||||
min_throughput: Annotated[
|
||||
OptionalNullable[float],
|
||||
pydantic.Field(
|
||||
deprecated="warning: ** DEPRECATED ** - Use preferred_min_throughput instead.."
|
||||
),
|
||||
] = UNSET
|
||||
r"""**DEPRECATED** Use preferred_min_throughput instead. Backwards-compatible alias for preferred_min_throughput."""
|
||||
|
||||
max_latency: Annotated[
|
||||
OptionalNullable[float],
|
||||
pydantic.Field(
|
||||
deprecated="warning: ** DEPRECATED ** - Use preferred_max_latency instead.."
|
||||
),
|
||||
] = UNSET
|
||||
r"""**DEPRECATED** Use preferred_max_latency instead. Backwards-compatible alias for preferred_max_latency."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"allow_fallbacks",
|
||||
"require_parameters",
|
||||
"data_collection",
|
||||
"zdr",
|
||||
"enforce_distillable_text",
|
||||
"order",
|
||||
"only",
|
||||
"ignore",
|
||||
"quantizations",
|
||||
"sort",
|
||||
"max_price",
|
||||
"preferred_min_throughput",
|
||||
"preferred_max_latency",
|
||||
"min_throughput",
|
||||
"max_latency",
|
||||
]
|
||||
nullable_fields = [
|
||||
"allow_fallbacks",
|
||||
"require_parameters",
|
||||
"data_collection",
|
||||
"zdr",
|
||||
"enforce_distillable_text",
|
||||
"order",
|
||||
"only",
|
||||
"ignore",
|
||||
"quantizations",
|
||||
"sort",
|
||||
"preferred_min_throughput",
|
||||
"preferred_max_latency",
|
||||
"min_throughput",
|
||||
"max_latency",
|
||||
]
|
||||
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
|
||||
@@ -13,4 +13,3 @@ ProviderSort = Union[
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .providersort import ProviderSort
|
||||
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
|
||||
|
||||
|
||||
Partition = Union[
|
||||
Literal[
|
||||
"model",
|
||||
"none",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ProviderSortConfigTypedDict(TypedDict):
|
||||
by: NotRequired[Nullable[ProviderSort]]
|
||||
partition: NotRequired[Nullable[Partition]]
|
||||
|
||||
|
||||
class ProviderSortConfig(BaseModel):
|
||||
by: Annotated[
|
||||
OptionalNullable[ProviderSort], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
partition: Annotated[
|
||||
OptionalNullable[Partition], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["by", "partition"]
|
||||
nullable_fields = ["by", "partition"]
|
||||
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,23 @@
|
||||
"""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,15 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
WebSearchEngine = Union[
|
||||
Literal[
|
||||
"native",
|
||||
"exa",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The search engine to use for web search."""
|
||||
Reference in New Issue
Block a user