openrouter 0.0.22__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openrouter/_version.py +2 -2
- openrouter/chat.py +70 -12
- openrouter/components/__init__.py +328 -81
- openrouter/components/_schema0.py +3 -2
- openrouter/components/_schema3.py +229 -0
- openrouter/components/chatgenerationparams.py +211 -53
- openrouter/components/chatgenerationtokenusage.py +3 -0
- openrouter/components/chatmessagetokenlogprob.py +4 -4
- openrouter/components/chatresponsechoice.py +6 -1
- openrouter/components/chatstreamingmessagechunk.py +12 -1
- openrouter/components/openresponseseasyinputmessage.py +93 -20
- openrouter/components/openresponsesinput.py +2 -2
- openrouter/components/openresponsesinputmessageitem.py +87 -14
- openrouter/components/openresponsesnonstreamingresponse.py +20 -9
- openrouter/components/openresponsesreasoning.py +1 -0
- openrouter/components/openresponsesrequest.py +141 -88
- openrouter/components/parameter.py +1 -0
- openrouter/components/pdfparserengine.py +16 -0
- openrouter/components/pdfparseroptions.py +25 -0
- openrouter/components/percentilelatencycutoffs.py +71 -0
- openrouter/components/percentilestats.py +34 -0
- openrouter/components/percentilethroughputcutoffs.py +71 -0
- openrouter/components/preferredmaxlatency.py +21 -0
- openrouter/components/preferredminthroughput.py +22 -0
- openrouter/components/providername.py +3 -2
- openrouter/components/providerpreferences.py +355 -0
- openrouter/components/providersort.py +0 -1
- openrouter/components/providersortconfig.py +71 -0
- openrouter/components/providersortunion.py +23 -0
- openrouter/components/publicendpoint.py +11 -0
- openrouter/components/responseinputvideo.py +26 -0
- openrouter/components/responseoutputtext.py +36 -1
- openrouter/components/responsesoutputitem.py +1 -1
- openrouter/components/responsesoutputitemreasoning.py +43 -3
- openrouter/components/responsesoutputmodality.py +14 -0
- openrouter/components/websearchengine.py +15 -0
- openrouter/embeddings.py +6 -8
- openrouter/operations/__init__.py +0 -33
- openrouter/operations/createembeddings.py +7 -258
- openrouter/operations/getgeneration.py +6 -0
- openrouter/operations/getparameters.py +5 -78
- openrouter/parameters.py +2 -2
- openrouter/responses.py +114 -14
- {openrouter-0.0.22.dist-info → openrouter-0.1.2.dist-info}/METADATA +1 -1
- {openrouter-0.0.22.dist-info → openrouter-0.1.2.dist-info}/RECORD +48 -34
- {openrouter-0.0.22.dist-info → openrouter-0.1.2.dist-info}/WHEEL +1 -1
- {openrouter-0.0.22.dist-info → openrouter-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {openrouter-0.0.22.dist-info → openrouter-0.1.2.dist-info}/top_level.txt +0 -0
|
@@ -36,12 +36,12 @@ Schema0Enum = Union[
|
|
|
36
36
|
"Fireworks",
|
|
37
37
|
"Friendli",
|
|
38
38
|
"GMICloud",
|
|
39
|
-
"GoPomelo",
|
|
40
39
|
"Google",
|
|
41
40
|
"Google AI Studio",
|
|
42
41
|
"Groq",
|
|
43
42
|
"Hyperbolic",
|
|
44
43
|
"Inception",
|
|
44
|
+
"Inceptron",
|
|
45
45
|
"InferenceNet",
|
|
46
46
|
"Infermatic",
|
|
47
47
|
"Inflection",
|
|
@@ -66,13 +66,14 @@ Schema0Enum = Union[
|
|
|
66
66
|
"Phala",
|
|
67
67
|
"Relace",
|
|
68
68
|
"SambaNova",
|
|
69
|
+
"Seed",
|
|
69
70
|
"SiliconFlow",
|
|
70
71
|
"Sourceful",
|
|
71
72
|
"Stealth",
|
|
72
73
|
"StreamLake",
|
|
73
74
|
"Switchpoint",
|
|
74
|
-
"Targon",
|
|
75
75
|
"Together",
|
|
76
|
+
"Upstage",
|
|
76
77
|
"Venice",
|
|
77
78
|
"WandB",
|
|
78
79
|
"Xiaomi",
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from openrouter.types import (
|
|
5
|
+
BaseModel,
|
|
6
|
+
Nullable,
|
|
7
|
+
OptionalNullable,
|
|
8
|
+
UNSET,
|
|
9
|
+
UNSET_SENTINEL,
|
|
10
|
+
UnrecognizedStr,
|
|
11
|
+
)
|
|
12
|
+
from openrouter.utils import get_discriminator, validate_const, validate_open_enum
|
|
13
|
+
import pydantic
|
|
14
|
+
from pydantic import Discriminator, Tag, model_serializer
|
|
15
|
+
from pydantic.functional_validators import AfterValidator, PlainValidator
|
|
16
|
+
from typing import Literal, Optional, Union
|
|
17
|
+
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Schema5 = Union[
|
|
21
|
+
Literal[
|
|
22
|
+
"unknown",
|
|
23
|
+
"openai-responses-v1",
|
|
24
|
+
"azure-openai-responses-v1",
|
|
25
|
+
"xai-responses-v1",
|
|
26
|
+
"anthropic-claude-v1",
|
|
27
|
+
"google-gemini-v1",
|
|
28
|
+
],
|
|
29
|
+
UnrecognizedStr,
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Schema3ReasoningTextTypedDict(TypedDict):
|
|
34
|
+
type: Literal["reasoning.text"]
|
|
35
|
+
text: NotRequired[Nullable[str]]
|
|
36
|
+
signature: NotRequired[Nullable[str]]
|
|
37
|
+
id: NotRequired[Nullable[str]]
|
|
38
|
+
format_: NotRequired[Nullable[Schema5]]
|
|
39
|
+
index: NotRequired[float]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Schema3ReasoningText(BaseModel):
|
|
43
|
+
TYPE: Annotated[
|
|
44
|
+
Annotated[
|
|
45
|
+
Literal["reasoning.text"], AfterValidator(validate_const("reasoning.text"))
|
|
46
|
+
],
|
|
47
|
+
pydantic.Field(alias="type"),
|
|
48
|
+
] = "reasoning.text"
|
|
49
|
+
|
|
50
|
+
text: OptionalNullable[str] = UNSET
|
|
51
|
+
|
|
52
|
+
signature: OptionalNullable[str] = UNSET
|
|
53
|
+
|
|
54
|
+
id: OptionalNullable[str] = UNSET
|
|
55
|
+
|
|
56
|
+
format_: Annotated[
|
|
57
|
+
Annotated[OptionalNullable[Schema5], PlainValidator(validate_open_enum(False))],
|
|
58
|
+
pydantic.Field(alias="format"),
|
|
59
|
+
] = UNSET
|
|
60
|
+
|
|
61
|
+
index: Optional[float] = None
|
|
62
|
+
|
|
63
|
+
@model_serializer(mode="wrap")
|
|
64
|
+
def serialize_model(self, handler):
|
|
65
|
+
optional_fields = ["text", "signature", "id", "format", "index"]
|
|
66
|
+
nullable_fields = ["text", "signature", "id", "format"]
|
|
67
|
+
null_default_fields = []
|
|
68
|
+
|
|
69
|
+
serialized = handler(self)
|
|
70
|
+
|
|
71
|
+
m = {}
|
|
72
|
+
|
|
73
|
+
for n, f in type(self).model_fields.items():
|
|
74
|
+
k = f.alias or n
|
|
75
|
+
val = serialized.get(k)
|
|
76
|
+
serialized.pop(k, None)
|
|
77
|
+
|
|
78
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
79
|
+
is_set = (
|
|
80
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
81
|
+
or k in null_default_fields
|
|
82
|
+
) # pylint: disable=no-member
|
|
83
|
+
|
|
84
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
85
|
+
m[k] = val
|
|
86
|
+
elif val != UNSET_SENTINEL and (
|
|
87
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
88
|
+
):
|
|
89
|
+
m[k] = val
|
|
90
|
+
|
|
91
|
+
return m
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class Schema3ReasoningEncryptedTypedDict(TypedDict):
|
|
95
|
+
data: str
|
|
96
|
+
type: Literal["reasoning.encrypted"]
|
|
97
|
+
id: NotRequired[Nullable[str]]
|
|
98
|
+
format_: NotRequired[Nullable[Schema5]]
|
|
99
|
+
index: NotRequired[float]
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class Schema3ReasoningEncrypted(BaseModel):
|
|
103
|
+
data: str
|
|
104
|
+
|
|
105
|
+
TYPE: Annotated[
|
|
106
|
+
Annotated[
|
|
107
|
+
Literal["reasoning.encrypted"],
|
|
108
|
+
AfterValidator(validate_const("reasoning.encrypted")),
|
|
109
|
+
],
|
|
110
|
+
pydantic.Field(alias="type"),
|
|
111
|
+
] = "reasoning.encrypted"
|
|
112
|
+
|
|
113
|
+
id: OptionalNullable[str] = UNSET
|
|
114
|
+
|
|
115
|
+
format_: Annotated[
|
|
116
|
+
Annotated[OptionalNullable[Schema5], PlainValidator(validate_open_enum(False))],
|
|
117
|
+
pydantic.Field(alias="format"),
|
|
118
|
+
] = UNSET
|
|
119
|
+
|
|
120
|
+
index: Optional[float] = None
|
|
121
|
+
|
|
122
|
+
@model_serializer(mode="wrap")
|
|
123
|
+
def serialize_model(self, handler):
|
|
124
|
+
optional_fields = ["id", "format", "index"]
|
|
125
|
+
nullable_fields = ["id", "format"]
|
|
126
|
+
null_default_fields = []
|
|
127
|
+
|
|
128
|
+
serialized = handler(self)
|
|
129
|
+
|
|
130
|
+
m = {}
|
|
131
|
+
|
|
132
|
+
for n, f in type(self).model_fields.items():
|
|
133
|
+
k = f.alias or n
|
|
134
|
+
val = serialized.get(k)
|
|
135
|
+
serialized.pop(k, None)
|
|
136
|
+
|
|
137
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
138
|
+
is_set = (
|
|
139
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
140
|
+
or k in null_default_fields
|
|
141
|
+
) # pylint: disable=no-member
|
|
142
|
+
|
|
143
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
144
|
+
m[k] = val
|
|
145
|
+
elif val != UNSET_SENTINEL and (
|
|
146
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
147
|
+
):
|
|
148
|
+
m[k] = val
|
|
149
|
+
|
|
150
|
+
return m
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class Schema3ReasoningSummaryTypedDict(TypedDict):
|
|
154
|
+
summary: str
|
|
155
|
+
type: Literal["reasoning.summary"]
|
|
156
|
+
id: NotRequired[Nullable[str]]
|
|
157
|
+
format_: NotRequired[Nullable[Schema5]]
|
|
158
|
+
index: NotRequired[float]
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class Schema3ReasoningSummary(BaseModel):
|
|
162
|
+
summary: str
|
|
163
|
+
|
|
164
|
+
TYPE: Annotated[
|
|
165
|
+
Annotated[
|
|
166
|
+
Literal["reasoning.summary"],
|
|
167
|
+
AfterValidator(validate_const("reasoning.summary")),
|
|
168
|
+
],
|
|
169
|
+
pydantic.Field(alias="type"),
|
|
170
|
+
] = "reasoning.summary"
|
|
171
|
+
|
|
172
|
+
id: OptionalNullable[str] = UNSET
|
|
173
|
+
|
|
174
|
+
format_: Annotated[
|
|
175
|
+
Annotated[OptionalNullable[Schema5], PlainValidator(validate_open_enum(False))],
|
|
176
|
+
pydantic.Field(alias="format"),
|
|
177
|
+
] = UNSET
|
|
178
|
+
|
|
179
|
+
index: Optional[float] = None
|
|
180
|
+
|
|
181
|
+
@model_serializer(mode="wrap")
|
|
182
|
+
def serialize_model(self, handler):
|
|
183
|
+
optional_fields = ["id", "format", "index"]
|
|
184
|
+
nullable_fields = ["id", "format"]
|
|
185
|
+
null_default_fields = []
|
|
186
|
+
|
|
187
|
+
serialized = handler(self)
|
|
188
|
+
|
|
189
|
+
m = {}
|
|
190
|
+
|
|
191
|
+
for n, f in type(self).model_fields.items():
|
|
192
|
+
k = f.alias or n
|
|
193
|
+
val = serialized.get(k)
|
|
194
|
+
serialized.pop(k, None)
|
|
195
|
+
|
|
196
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
197
|
+
is_set = (
|
|
198
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
199
|
+
or k in null_default_fields
|
|
200
|
+
) # pylint: disable=no-member
|
|
201
|
+
|
|
202
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
203
|
+
m[k] = val
|
|
204
|
+
elif val != UNSET_SENTINEL and (
|
|
205
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
206
|
+
):
|
|
207
|
+
m[k] = val
|
|
208
|
+
|
|
209
|
+
return m
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
Schema3TypedDict = TypeAliasType(
|
|
213
|
+
"Schema3TypedDict",
|
|
214
|
+
Union[
|
|
215
|
+
Schema3ReasoningSummaryTypedDict,
|
|
216
|
+
Schema3ReasoningEncryptedTypedDict,
|
|
217
|
+
Schema3ReasoningTextTypedDict,
|
|
218
|
+
],
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
Schema3 = Annotated[
|
|
223
|
+
Union[
|
|
224
|
+
Annotated[Schema3ReasoningSummary, Tag("reasoning.summary")],
|
|
225
|
+
Annotated[Schema3ReasoningEncrypted, Tag("reasoning.encrypted")],
|
|
226
|
+
Annotated[Schema3ReasoningText, Tag("reasoning.text")],
|
|
227
|
+
],
|
|
228
|
+
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
|
229
|
+
]
|
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
from ._schema0 import Schema0, Schema0TypedDict
|
|
5
5
|
from .chatstreamoptions import ChatStreamOptions, ChatStreamOptionsTypedDict
|
|
6
6
|
from .message import Message, MessageTypedDict
|
|
7
|
+
from .providersortunion import ProviderSortUnion, ProviderSortUnionTypedDict
|
|
7
8
|
from .reasoningsummaryverbosity import ReasoningSummaryVerbosity
|
|
8
9
|
from .responseformatjsonschema import (
|
|
9
10
|
ResponseFormatJSONSchema,
|
|
@@ -55,16 +56,6 @@ Quantizations = Union[
|
|
|
55
56
|
]
|
|
56
57
|
|
|
57
58
|
|
|
58
|
-
Sort = Union[
|
|
59
|
-
Literal[
|
|
60
|
-
"price",
|
|
61
|
-
"throughput",
|
|
62
|
-
"latency",
|
|
63
|
-
],
|
|
64
|
-
UnrecognizedStr,
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
|
|
68
59
|
class ChatGenerationParamsMaxPriceTypedDict(TypedDict):
|
|
69
60
|
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
|
70
61
|
|
|
@@ -89,6 +80,124 @@ class ChatGenerationParamsMaxPrice(BaseModel):
|
|
|
89
80
|
request: Optional[Any] = None
|
|
90
81
|
|
|
91
82
|
|
|
83
|
+
class ChatGenerationParamsPreferredMinThroughputTypedDict(TypedDict):
|
|
84
|
+
p50: NotRequired[Nullable[float]]
|
|
85
|
+
p75: NotRequired[Nullable[float]]
|
|
86
|
+
p90: NotRequired[Nullable[float]]
|
|
87
|
+
p99: NotRequired[Nullable[float]]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class ChatGenerationParamsPreferredMinThroughput(BaseModel):
|
|
91
|
+
p50: OptionalNullable[float] = UNSET
|
|
92
|
+
|
|
93
|
+
p75: OptionalNullable[float] = UNSET
|
|
94
|
+
|
|
95
|
+
p90: OptionalNullable[float] = UNSET
|
|
96
|
+
|
|
97
|
+
p99: OptionalNullable[float] = UNSET
|
|
98
|
+
|
|
99
|
+
@model_serializer(mode="wrap")
|
|
100
|
+
def serialize_model(self, handler):
|
|
101
|
+
optional_fields = ["p50", "p75", "p90", "p99"]
|
|
102
|
+
nullable_fields = ["p50", "p75", "p90", "p99"]
|
|
103
|
+
null_default_fields = []
|
|
104
|
+
|
|
105
|
+
serialized = handler(self)
|
|
106
|
+
|
|
107
|
+
m = {}
|
|
108
|
+
|
|
109
|
+
for n, f in type(self).model_fields.items():
|
|
110
|
+
k = f.alias or n
|
|
111
|
+
val = serialized.get(k)
|
|
112
|
+
serialized.pop(k, None)
|
|
113
|
+
|
|
114
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
115
|
+
is_set = (
|
|
116
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
117
|
+
or k in null_default_fields
|
|
118
|
+
) # pylint: disable=no-member
|
|
119
|
+
|
|
120
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
121
|
+
m[k] = val
|
|
122
|
+
elif val != UNSET_SENTINEL and (
|
|
123
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
124
|
+
):
|
|
125
|
+
m[k] = val
|
|
126
|
+
|
|
127
|
+
return m
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
ChatGenerationParamsPreferredMinThroughputUnionTypedDict = TypeAliasType(
|
|
131
|
+
"ChatGenerationParamsPreferredMinThroughputUnionTypedDict",
|
|
132
|
+
Union[ChatGenerationParamsPreferredMinThroughputTypedDict, float],
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
ChatGenerationParamsPreferredMinThroughputUnion = TypeAliasType(
|
|
137
|
+
"ChatGenerationParamsPreferredMinThroughputUnion",
|
|
138
|
+
Union[ChatGenerationParamsPreferredMinThroughput, float],
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class ChatGenerationParamsPreferredMaxLatencyTypedDict(TypedDict):
|
|
143
|
+
p50: NotRequired[Nullable[float]]
|
|
144
|
+
p75: NotRequired[Nullable[float]]
|
|
145
|
+
p90: NotRequired[Nullable[float]]
|
|
146
|
+
p99: NotRequired[Nullable[float]]
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class ChatGenerationParamsPreferredMaxLatency(BaseModel):
|
|
150
|
+
p50: OptionalNullable[float] = UNSET
|
|
151
|
+
|
|
152
|
+
p75: OptionalNullable[float] = UNSET
|
|
153
|
+
|
|
154
|
+
p90: OptionalNullable[float] = UNSET
|
|
155
|
+
|
|
156
|
+
p99: OptionalNullable[float] = UNSET
|
|
157
|
+
|
|
158
|
+
@model_serializer(mode="wrap")
|
|
159
|
+
def serialize_model(self, handler):
|
|
160
|
+
optional_fields = ["p50", "p75", "p90", "p99"]
|
|
161
|
+
nullable_fields = ["p50", "p75", "p90", "p99"]
|
|
162
|
+
null_default_fields = []
|
|
163
|
+
|
|
164
|
+
serialized = handler(self)
|
|
165
|
+
|
|
166
|
+
m = {}
|
|
167
|
+
|
|
168
|
+
for n, f in type(self).model_fields.items():
|
|
169
|
+
k = f.alias or n
|
|
170
|
+
val = serialized.get(k)
|
|
171
|
+
serialized.pop(k, None)
|
|
172
|
+
|
|
173
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
174
|
+
is_set = (
|
|
175
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
176
|
+
or k in null_default_fields
|
|
177
|
+
) # pylint: disable=no-member
|
|
178
|
+
|
|
179
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
180
|
+
m[k] = val
|
|
181
|
+
elif val != UNSET_SENTINEL and (
|
|
182
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
183
|
+
):
|
|
184
|
+
m[k] = val
|
|
185
|
+
|
|
186
|
+
return m
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
ChatGenerationParamsPreferredMaxLatencyUnionTypedDict = TypeAliasType(
|
|
190
|
+
"ChatGenerationParamsPreferredMaxLatencyUnionTypedDict",
|
|
191
|
+
Union[ChatGenerationParamsPreferredMaxLatencyTypedDict, float],
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
ChatGenerationParamsPreferredMaxLatencyUnion = TypeAliasType(
|
|
196
|
+
"ChatGenerationParamsPreferredMaxLatencyUnion",
|
|
197
|
+
Union[ChatGenerationParamsPreferredMaxLatency, float],
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
|
|
92
201
|
class ChatGenerationParamsProviderTypedDict(TypedDict):
|
|
93
202
|
allow_fallbacks: NotRequired[Nullable[bool]]
|
|
94
203
|
r"""Whether to allow backup providers to serve requests
|
|
@@ -114,14 +223,18 @@ class ChatGenerationParamsProviderTypedDict(TypedDict):
|
|
|
114
223
|
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
|
115
224
|
quantizations: NotRequired[Nullable[List[Quantizations]]]
|
|
116
225
|
r"""A list of quantization levels to filter the provider by."""
|
|
117
|
-
sort: NotRequired[Nullable[
|
|
226
|
+
sort: NotRequired[Nullable[ProviderSortUnionTypedDict]]
|
|
118
227
|
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
|
119
228
|
max_price: NotRequired[ChatGenerationParamsMaxPriceTypedDict]
|
|
120
229
|
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
r"""
|
|
230
|
+
preferred_min_throughput: NotRequired[
|
|
231
|
+
Nullable[ChatGenerationParamsPreferredMinThroughputUnionTypedDict]
|
|
232
|
+
]
|
|
233
|
+
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
|
|
234
|
+
preferred_max_latency: NotRequired[
|
|
235
|
+
Nullable[ChatGenerationParamsPreferredMaxLatencyUnionTypedDict]
|
|
236
|
+
]
|
|
237
|
+
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
|
|
125
238
|
|
|
126
239
|
|
|
127
240
|
class ChatGenerationParamsProvider(BaseModel):
|
|
@@ -163,19 +276,21 @@ class ChatGenerationParamsProvider(BaseModel):
|
|
|
163
276
|
] = UNSET
|
|
164
277
|
r"""A list of quantization levels to filter the provider by."""
|
|
165
278
|
|
|
166
|
-
sort:
|
|
167
|
-
OptionalNullable[Sort], PlainValidator(validate_open_enum(False))
|
|
168
|
-
] = UNSET
|
|
279
|
+
sort: OptionalNullable[ProviderSortUnion] = UNSET
|
|
169
280
|
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
|
170
281
|
|
|
171
282
|
max_price: Optional[ChatGenerationParamsMaxPrice] = None
|
|
172
283
|
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
|
173
284
|
|
|
174
|
-
|
|
175
|
-
|
|
285
|
+
preferred_min_throughput: OptionalNullable[
|
|
286
|
+
ChatGenerationParamsPreferredMinThroughputUnion
|
|
287
|
+
] = UNSET
|
|
288
|
+
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
|
|
176
289
|
|
|
177
|
-
|
|
178
|
-
|
|
290
|
+
preferred_max_latency: OptionalNullable[
|
|
291
|
+
ChatGenerationParamsPreferredMaxLatencyUnion
|
|
292
|
+
] = UNSET
|
|
293
|
+
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
|
|
179
294
|
|
|
180
295
|
@model_serializer(mode="wrap")
|
|
181
296
|
def serialize_model(self, handler):
|
|
@@ -191,8 +306,8 @@ class ChatGenerationParamsProvider(BaseModel):
|
|
|
191
306
|
"quantizations",
|
|
192
307
|
"sort",
|
|
193
308
|
"max_price",
|
|
194
|
-
"
|
|
195
|
-
"
|
|
309
|
+
"preferred_min_throughput",
|
|
310
|
+
"preferred_max_latency",
|
|
196
311
|
]
|
|
197
312
|
nullable_fields = [
|
|
198
313
|
"allow_fallbacks",
|
|
@@ -205,8 +320,8 @@ class ChatGenerationParamsProvider(BaseModel):
|
|
|
205
320
|
"ignore",
|
|
206
321
|
"quantizations",
|
|
207
322
|
"sort",
|
|
208
|
-
"
|
|
209
|
-
"
|
|
323
|
+
"preferred_min_throughput",
|
|
324
|
+
"preferred_max_latency",
|
|
210
325
|
]
|
|
211
326
|
null_default_fields = []
|
|
212
327
|
|
|
@@ -252,7 +367,7 @@ class ChatGenerationParamsPluginResponseHealing(BaseModel):
|
|
|
252
367
|
enabled: Optional[bool] = None
|
|
253
368
|
|
|
254
369
|
|
|
255
|
-
|
|
370
|
+
PdfEngine = Union[
|
|
256
371
|
Literal[
|
|
257
372
|
"mistral-ocr",
|
|
258
373
|
"pdf-text",
|
|
@@ -262,22 +377,20 @@ ChatGenerationParamsPdfEngine = Union[
|
|
|
262
377
|
]
|
|
263
378
|
|
|
264
379
|
|
|
265
|
-
class
|
|
266
|
-
engine: NotRequired[
|
|
380
|
+
class PdfTypedDict(TypedDict):
|
|
381
|
+
engine: NotRequired[PdfEngine]
|
|
267
382
|
|
|
268
383
|
|
|
269
|
-
class
|
|
384
|
+
class Pdf(BaseModel):
|
|
270
385
|
engine: Annotated[
|
|
271
|
-
Optional[
|
|
272
|
-
PlainValidator(validate_open_enum(False)),
|
|
386
|
+
Optional[PdfEngine], PlainValidator(validate_open_enum(False))
|
|
273
387
|
] = None
|
|
274
388
|
|
|
275
389
|
|
|
276
390
|
class ChatGenerationParamsPluginFileParserTypedDict(TypedDict):
|
|
277
391
|
id: Literal["file-parser"]
|
|
278
392
|
enabled: NotRequired[bool]
|
|
279
|
-
|
|
280
|
-
pdf: NotRequired[ChatGenerationParamsPdfTypedDict]
|
|
393
|
+
pdf: NotRequired[PdfTypedDict]
|
|
281
394
|
|
|
282
395
|
|
|
283
396
|
class ChatGenerationParamsPluginFileParser(BaseModel):
|
|
@@ -290,12 +403,10 @@ class ChatGenerationParamsPluginFileParser(BaseModel):
|
|
|
290
403
|
|
|
291
404
|
enabled: Optional[bool] = None
|
|
292
405
|
|
|
293
|
-
|
|
406
|
+
pdf: Optional[Pdf] = None
|
|
294
407
|
|
|
295
|
-
pdf: Optional[ChatGenerationParamsPdf] = None
|
|
296
408
|
|
|
297
|
-
|
|
298
|
-
ChatGenerationParamsEngine = Union[
|
|
409
|
+
Engine = Union[
|
|
299
410
|
Literal[
|
|
300
411
|
"native",
|
|
301
412
|
"exa",
|
|
@@ -309,7 +420,7 @@ class ChatGenerationParamsPluginWebTypedDict(TypedDict):
|
|
|
309
420
|
enabled: NotRequired[bool]
|
|
310
421
|
max_results: NotRequired[float]
|
|
311
422
|
search_prompt: NotRequired[str]
|
|
312
|
-
engine: NotRequired[
|
|
423
|
+
engine: NotRequired[Engine]
|
|
313
424
|
|
|
314
425
|
|
|
315
426
|
class ChatGenerationParamsPluginWeb(BaseModel):
|
|
@@ -324,9 +435,9 @@ class ChatGenerationParamsPluginWeb(BaseModel):
|
|
|
324
435
|
|
|
325
436
|
search_prompt: Optional[str] = None
|
|
326
437
|
|
|
327
|
-
engine: Annotated[
|
|
328
|
-
|
|
329
|
-
|
|
438
|
+
engine: Annotated[Optional[Engine], PlainValidator(validate_open_enum(False))] = (
|
|
439
|
+
None
|
|
440
|
+
)
|
|
330
441
|
|
|
331
442
|
|
|
332
443
|
class ChatGenerationParamsPluginModerationTypedDict(TypedDict):
|
|
@@ -340,11 +451,31 @@ class ChatGenerationParamsPluginModeration(BaseModel):
|
|
|
340
451
|
] = "moderation"
|
|
341
452
|
|
|
342
453
|
|
|
454
|
+
class ChatGenerationParamsPluginAutoRouterTypedDict(TypedDict):
|
|
455
|
+
id: Literal["auto-router"]
|
|
456
|
+
enabled: NotRequired[bool]
|
|
457
|
+
allowed_models: NotRequired[List[str]]
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
class ChatGenerationParamsPluginAutoRouter(BaseModel):
|
|
461
|
+
ID: Annotated[
|
|
462
|
+
Annotated[
|
|
463
|
+
Literal["auto-router"], AfterValidator(validate_const("auto-router"))
|
|
464
|
+
],
|
|
465
|
+
pydantic.Field(alias="id"),
|
|
466
|
+
] = "auto-router"
|
|
467
|
+
|
|
468
|
+
enabled: Optional[bool] = None
|
|
469
|
+
|
|
470
|
+
allowed_models: Optional[List[str]] = None
|
|
471
|
+
|
|
472
|
+
|
|
343
473
|
ChatGenerationParamsPluginUnionTypedDict = TypeAliasType(
|
|
344
474
|
"ChatGenerationParamsPluginUnionTypedDict",
|
|
345
475
|
Union[
|
|
346
476
|
ChatGenerationParamsPluginModerationTypedDict,
|
|
347
477
|
ChatGenerationParamsPluginResponseHealingTypedDict,
|
|
478
|
+
ChatGenerationParamsPluginAutoRouterTypedDict,
|
|
348
479
|
ChatGenerationParamsPluginFileParserTypedDict,
|
|
349
480
|
ChatGenerationParamsPluginWebTypedDict,
|
|
350
481
|
],
|
|
@@ -353,6 +484,7 @@ ChatGenerationParamsPluginUnionTypedDict = TypeAliasType(
|
|
|
353
484
|
|
|
354
485
|
ChatGenerationParamsPluginUnion = Annotated[
|
|
355
486
|
Union[
|
|
487
|
+
Annotated[ChatGenerationParamsPluginAutoRouter, Tag("auto-router")],
|
|
356
488
|
Annotated[ChatGenerationParamsPluginModeration, Tag("moderation")],
|
|
357
489
|
Annotated[ChatGenerationParamsPluginWeb, Tag("web")],
|
|
358
490
|
Annotated[ChatGenerationParamsPluginFileParser, Tag("file-parser")],
|
|
@@ -362,7 +494,7 @@ ChatGenerationParamsPluginUnion = Annotated[
|
|
|
362
494
|
]
|
|
363
495
|
|
|
364
496
|
|
|
365
|
-
|
|
497
|
+
Route = Union[
|
|
366
498
|
Literal[
|
|
367
499
|
"fallback",
|
|
368
500
|
"sort",
|
|
@@ -373,12 +505,12 @@ ChatGenerationParamsRoute = Union[
|
|
|
373
505
|
|
|
374
506
|
Effort = Union[
|
|
375
507
|
Literal[
|
|
376
|
-
"none",
|
|
377
|
-
"minimal",
|
|
378
|
-
"low",
|
|
379
|
-
"medium",
|
|
380
|
-
"high",
|
|
381
508
|
"xhigh",
|
|
509
|
+
"high",
|
|
510
|
+
"medium",
|
|
511
|
+
"low",
|
|
512
|
+
"minimal",
|
|
513
|
+
"none",
|
|
382
514
|
],
|
|
383
515
|
UnrecognizedStr,
|
|
384
516
|
]
|
|
@@ -507,14 +639,32 @@ class Debug(BaseModel):
|
|
|
507
639
|
echo_upstream_body: Optional[bool] = None
|
|
508
640
|
|
|
509
641
|
|
|
642
|
+
ChatGenerationParamsImageConfigTypedDict = TypeAliasType(
|
|
643
|
+
"ChatGenerationParamsImageConfigTypedDict", Union[str, float]
|
|
644
|
+
)
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
ChatGenerationParamsImageConfig = TypeAliasType(
|
|
648
|
+
"ChatGenerationParamsImageConfig", Union[str, float]
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
Modality = Union[
|
|
653
|
+
Literal[
|
|
654
|
+
"text",
|
|
655
|
+
"image",
|
|
656
|
+
],
|
|
657
|
+
UnrecognizedStr,
|
|
658
|
+
]
|
|
659
|
+
|
|
660
|
+
|
|
510
661
|
class ChatGenerationParamsTypedDict(TypedDict):
|
|
511
662
|
messages: List[MessageTypedDict]
|
|
512
663
|
provider: NotRequired[Nullable[ChatGenerationParamsProviderTypedDict]]
|
|
513
664
|
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
|
514
665
|
plugins: NotRequired[List[ChatGenerationParamsPluginUnionTypedDict]]
|
|
515
666
|
r"""Plugins you want to enable for this request, including their settings."""
|
|
516
|
-
route: NotRequired[Nullable[
|
|
517
|
-
r"""Routing strategy for multiple models: \"fallback\" (default) uses secondary models as backups, \"sort\" sorts all endpoints together by routing criteria."""
|
|
667
|
+
route: NotRequired[Nullable[Route]]
|
|
518
668
|
user: NotRequired[str]
|
|
519
669
|
session_id: NotRequired[str]
|
|
520
670
|
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."""
|
|
@@ -539,6 +689,8 @@ class ChatGenerationParamsTypedDict(TypedDict):
|
|
|
539
689
|
tools: NotRequired[List[ToolDefinitionJSONTypedDict]]
|
|
540
690
|
top_p: NotRequired[Nullable[float]]
|
|
541
691
|
debug: NotRequired[DebugTypedDict]
|
|
692
|
+
image_config: NotRequired[Dict[str, ChatGenerationParamsImageConfigTypedDict]]
|
|
693
|
+
modalities: NotRequired[List[Modality]]
|
|
542
694
|
|
|
543
695
|
|
|
544
696
|
class ChatGenerationParams(BaseModel):
|
|
@@ -551,10 +703,8 @@ class ChatGenerationParams(BaseModel):
|
|
|
551
703
|
r"""Plugins you want to enable for this request, including their settings."""
|
|
552
704
|
|
|
553
705
|
route: Annotated[
|
|
554
|
-
OptionalNullable[
|
|
555
|
-
PlainValidator(validate_open_enum(False)),
|
|
706
|
+
OptionalNullable[Route], PlainValidator(validate_open_enum(False))
|
|
556
707
|
] = UNSET
|
|
557
|
-
r"""Routing strategy for multiple models: \"fallback\" (default) uses secondary models as backups, \"sort\" sorts all endpoints together by routing criteria."""
|
|
558
708
|
|
|
559
709
|
user: Optional[str] = None
|
|
560
710
|
|
|
@@ -603,6 +753,12 @@ class ChatGenerationParams(BaseModel):
|
|
|
603
753
|
|
|
604
754
|
debug: Optional[Debug] = None
|
|
605
755
|
|
|
756
|
+
image_config: Optional[Dict[str, ChatGenerationParamsImageConfig]] = None
|
|
757
|
+
|
|
758
|
+
modalities: Optional[
|
|
759
|
+
List[Annotated[Modality, PlainValidator(validate_open_enum(False))]]
|
|
760
|
+
] = None
|
|
761
|
+
|
|
606
762
|
@model_serializer(mode="wrap")
|
|
607
763
|
def serialize_model(self, handler):
|
|
608
764
|
optional_fields = [
|
|
@@ -632,6 +788,8 @@ class ChatGenerationParams(BaseModel):
|
|
|
632
788
|
"tools",
|
|
633
789
|
"top_p",
|
|
634
790
|
"debug",
|
|
791
|
+
"image_config",
|
|
792
|
+
"modalities",
|
|
635
793
|
]
|
|
636
794
|
nullable_fields = [
|
|
637
795
|
"provider",
|