openrouter 0.0.16__py3-none-any.whl → 0.0.17__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 +3 -3
- openrouter/analytics.py +2 -0
- openrouter/api_keys.py +24 -4
- openrouter/basesdk.py +6 -0
- openrouter/chat.py +154 -14
- openrouter/completions.py +2 -0
- openrouter/components/__init__.py +299 -76
- openrouter/components/_schema0.py +93 -0
- openrouter/components/_schema3.py +228 -0
- openrouter/components/chatgenerationparams.py +389 -16
- openrouter/components/chatmessagecontentitem.py +2 -1
- openrouter/components/chatmessagecontentitemaudio.py +6 -25
- openrouter/components/chatmessagecontentitemcachecontrol.py +32 -0
- openrouter/components/chatmessagecontentitemtext.py +9 -2
- openrouter/components/chatmessagecontentitemvideo.py +50 -9
- openrouter/components/chatresponsechoice.py +6 -1
- openrouter/components/chatstreamingmessagechunk.py +12 -1
- openrouter/components/completionchoice.py +18 -5
- openrouter/components/completioncreateparams.py +10 -10
- openrouter/components/completionresponse.py +3 -0
- openrouter/components/datacollection.py +19 -0
- openrouter/components/message.py +10 -9
- openrouter/components/openairesponsesannotation.py +11 -4
- openrouter/components/openairesponsesreasoningeffort.py +2 -0
- openrouter/components/openresponsesnonstreamingresponse.py +13 -10
- openrouter/components/openresponsesreasoning.py +1 -0
- openrouter/components/openresponsesrequest.py +194 -143
- openrouter/components/openresponsesstreamevent.py +110 -39
- openrouter/components/outputmessage.py +10 -4
- openrouter/components/parameter.py +1 -0
- openrouter/components/pdfparserengine.py +16 -0
- openrouter/components/pdfparseroptions.py +25 -0
- openrouter/components/providername.py +9 -26
- openrouter/components/providerpreferences.py +375 -0
- openrouter/components/providersort.py +15 -0
- openrouter/components/providersortconfig.py +71 -0
- openrouter/components/providersortunion.py +23 -0
- openrouter/components/publicendpoint.py +50 -45
- openrouter/components/publicpricing.py +50 -45
- openrouter/components/responseformattextconfig.py +9 -7
- openrouter/components/responsesoutputitem.py +12 -10
- openrouter/components/responsesoutputmessage.py +10 -5
- openrouter/components/websearchengine.py +15 -0
- openrouter/credits.py +4 -0
- openrouter/embeddings.py +34 -24
- openrouter/endpoints.py +4 -0
- openrouter/generations.py +2 -0
- openrouter/models/__init__.py +3 -0
- openrouter/models/internal/__init__.py +54 -0
- openrouter/models/internal/globals.py +41 -0
- openrouter/models_.py +6 -0
- openrouter/oauth.py +4 -0
- openrouter/operations/__init__.py +46 -49
- openrouter/operations/createembeddings.py +68 -264
- openrouter/operations/getcredits.py +19 -0
- openrouter/operations/getparameters.py +5 -77
- openrouter/operations/updatekeys.py +2 -2
- openrouter/parameters.py +4 -2
- openrouter/providers.py +2 -0
- openrouter/responses.py +74 -36
- openrouter/sdk.py +13 -0
- openrouter/sdkconfiguration.py +2 -0
- openrouter/utils/forms.py +21 -10
- openrouter/utils/queryparams.py +14 -2
- openrouter/utils/retries.py +69 -5
- {openrouter-0.0.16.dist-info → openrouter-0.0.17.dist-info}/METADATA +2 -1
- {openrouter-0.0.16.dist-info → openrouter-0.0.17.dist-info}/RECORD +70 -56
- {openrouter-0.0.16.dist-info → openrouter-0.0.17.dist-info}/WHEEL +0 -0
- {openrouter-0.0.16.dist-info → openrouter-0.0.17.dist-info}/licenses/LICENSE +0 -0
- {openrouter-0.0.16.dist-info → openrouter-0.0.17.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .datacollection import DataCollection
|
|
5
|
+
from .providername import ProviderName
|
|
6
|
+
from .providersort import ProviderSort
|
|
7
|
+
from .quantization import Quantization
|
|
8
|
+
from openrouter.types import (
|
|
9
|
+
BaseModel,
|
|
10
|
+
Nullable,
|
|
11
|
+
OptionalNullable,
|
|
12
|
+
UNSET,
|
|
13
|
+
UNSET_SENTINEL,
|
|
14
|
+
UnrecognizedStr,
|
|
15
|
+
)
|
|
16
|
+
from openrouter.utils import validate_open_enum
|
|
17
|
+
import pydantic
|
|
18
|
+
from pydantic import model_serializer
|
|
19
|
+
from pydantic.functional_validators import PlainValidator
|
|
20
|
+
from typing import List, Literal, Optional, Union
|
|
21
|
+
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
ProviderPreferencesOrderTypedDict = TypeAliasType(
|
|
25
|
+
"ProviderPreferencesOrderTypedDict", Union[ProviderName, str]
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
ProviderPreferencesOrder = TypeAliasType(
|
|
30
|
+
"ProviderPreferencesOrder",
|
|
31
|
+
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
ProviderPreferencesOnlyTypedDict = TypeAliasType(
|
|
36
|
+
"ProviderPreferencesOnlyTypedDict", Union[ProviderName, str]
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
ProviderPreferencesOnly = TypeAliasType(
|
|
41
|
+
"ProviderPreferencesOnly",
|
|
42
|
+
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
ProviderPreferencesIgnoreTypedDict = TypeAliasType(
|
|
47
|
+
"ProviderPreferencesIgnoreTypedDict", Union[ProviderName, str]
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
ProviderPreferencesIgnore = TypeAliasType(
|
|
52
|
+
"ProviderPreferencesIgnore",
|
|
53
|
+
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
SortEnum = Union[
|
|
58
|
+
Literal[
|
|
59
|
+
"price",
|
|
60
|
+
"throughput",
|
|
61
|
+
"latency",
|
|
62
|
+
],
|
|
63
|
+
UnrecognizedStr,
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
ProviderSortConfigEnum = Literal[
|
|
68
|
+
"price",
|
|
69
|
+
"throughput",
|
|
70
|
+
"latency",
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
ProviderPreferencesPartition = Union[
|
|
75
|
+
Literal[
|
|
76
|
+
"model",
|
|
77
|
+
"none",
|
|
78
|
+
],
|
|
79
|
+
UnrecognizedStr,
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class ProviderPreferencesProviderSortConfigTypedDict(TypedDict):
|
|
84
|
+
by: NotRequired[Nullable[ProviderSort]]
|
|
85
|
+
partition: NotRequired[Nullable[ProviderPreferencesPartition]]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class ProviderPreferencesProviderSortConfig(BaseModel):
|
|
89
|
+
by: Annotated[
|
|
90
|
+
OptionalNullable[ProviderSort], PlainValidator(validate_open_enum(False))
|
|
91
|
+
] = UNSET
|
|
92
|
+
|
|
93
|
+
partition: Annotated[
|
|
94
|
+
OptionalNullable[ProviderPreferencesPartition],
|
|
95
|
+
PlainValidator(validate_open_enum(False)),
|
|
96
|
+
] = UNSET
|
|
97
|
+
|
|
98
|
+
@model_serializer(mode="wrap")
|
|
99
|
+
def serialize_model(self, handler):
|
|
100
|
+
optional_fields = ["by", "partition"]
|
|
101
|
+
nullable_fields = ["by", "partition"]
|
|
102
|
+
null_default_fields = []
|
|
103
|
+
|
|
104
|
+
serialized = handler(self)
|
|
105
|
+
|
|
106
|
+
m = {}
|
|
107
|
+
|
|
108
|
+
for n, f in type(self).model_fields.items():
|
|
109
|
+
k = f.alias or n
|
|
110
|
+
val = serialized.get(k)
|
|
111
|
+
serialized.pop(k, None)
|
|
112
|
+
|
|
113
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
114
|
+
is_set = (
|
|
115
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
116
|
+
or k in null_default_fields
|
|
117
|
+
) # pylint: disable=no-member
|
|
118
|
+
|
|
119
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
120
|
+
m[k] = val
|
|
121
|
+
elif val != UNSET_SENTINEL and (
|
|
122
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
123
|
+
):
|
|
124
|
+
m[k] = val
|
|
125
|
+
|
|
126
|
+
return m
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
ProviderSortConfigUnionTypedDict = TypeAliasType(
|
|
130
|
+
"ProviderSortConfigUnionTypedDict",
|
|
131
|
+
Union[ProviderPreferencesProviderSortConfigTypedDict, ProviderSortConfigEnum],
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
ProviderSortConfigUnion = TypeAliasType(
|
|
136
|
+
"ProviderSortConfigUnion",
|
|
137
|
+
Union[ProviderPreferencesProviderSortConfig, ProviderSortConfigEnum],
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
ProviderPreferencesProviderSort = Union[
|
|
142
|
+
Literal[
|
|
143
|
+
"price",
|
|
144
|
+
"throughput",
|
|
145
|
+
"latency",
|
|
146
|
+
],
|
|
147
|
+
UnrecognizedStr,
|
|
148
|
+
]
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
ProviderPreferencesSortUnionTypedDict = TypeAliasType(
|
|
152
|
+
"ProviderPreferencesSortUnionTypedDict",
|
|
153
|
+
Union[ProviderPreferencesProviderSort, ProviderSortConfigUnionTypedDict, SortEnum],
|
|
154
|
+
)
|
|
155
|
+
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
ProviderPreferencesSortUnion = TypeAliasType(
|
|
159
|
+
"ProviderPreferencesSortUnion",
|
|
160
|
+
Union[
|
|
161
|
+
Annotated[
|
|
162
|
+
ProviderPreferencesProviderSort, PlainValidator(validate_open_enum(False))
|
|
163
|
+
],
|
|
164
|
+
ProviderSortConfigUnion,
|
|
165
|
+
Annotated[SortEnum, PlainValidator(validate_open_enum(False))],
|
|
166
|
+
],
|
|
167
|
+
)
|
|
168
|
+
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class ProviderPreferencesMaxPriceTypedDict(TypedDict):
|
|
172
|
+
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
|
173
|
+
|
|
174
|
+
prompt: NotRequired[str]
|
|
175
|
+
r"""A value in string format that is a large number"""
|
|
176
|
+
completion: NotRequired[str]
|
|
177
|
+
r"""A value in string format that is a large number"""
|
|
178
|
+
image: NotRequired[str]
|
|
179
|
+
r"""A value in string format that is a large number"""
|
|
180
|
+
audio: NotRequired[str]
|
|
181
|
+
r"""A value in string format that is a large number"""
|
|
182
|
+
request: NotRequired[str]
|
|
183
|
+
r"""A value in string format that is a large number"""
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class ProviderPreferencesMaxPrice(BaseModel):
|
|
187
|
+
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
|
188
|
+
|
|
189
|
+
prompt: Optional[str] = None
|
|
190
|
+
r"""A value in string format that is a large number"""
|
|
191
|
+
|
|
192
|
+
completion: Optional[str] = None
|
|
193
|
+
r"""A value in string format that is a large number"""
|
|
194
|
+
|
|
195
|
+
image: Optional[str] = None
|
|
196
|
+
r"""A value in string format that is a large number"""
|
|
197
|
+
|
|
198
|
+
audio: Optional[str] = None
|
|
199
|
+
r"""A value in string format that is a large number"""
|
|
200
|
+
|
|
201
|
+
request: Optional[str] = None
|
|
202
|
+
r"""A value in string format that is a large number"""
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
class ProviderPreferencesTypedDict(TypedDict):
|
|
206
|
+
r"""Provider routing preferences for the request."""
|
|
207
|
+
|
|
208
|
+
allow_fallbacks: NotRequired[Nullable[bool]]
|
|
209
|
+
r"""Whether to allow backup providers to serve requests
|
|
210
|
+
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
|
|
211
|
+
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
|
|
212
|
+
|
|
213
|
+
"""
|
|
214
|
+
require_parameters: NotRequired[Nullable[bool]]
|
|
215
|
+
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."""
|
|
216
|
+
data_collection: NotRequired[Nullable[DataCollection]]
|
|
217
|
+
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
|
218
|
+
- allow: (default) allow providers which store user data non-transiently and may train on it
|
|
219
|
+
|
|
220
|
+
- deny: use only providers which do not collect user data.
|
|
221
|
+
"""
|
|
222
|
+
zdr: NotRequired[Nullable[bool]]
|
|
223
|
+
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
|
|
224
|
+
enforce_distillable_text: NotRequired[Nullable[bool]]
|
|
225
|
+
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."""
|
|
226
|
+
order: NotRequired[Nullable[List[ProviderPreferencesOrderTypedDict]]]
|
|
227
|
+
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."""
|
|
228
|
+
only: NotRequired[Nullable[List[ProviderPreferencesOnlyTypedDict]]]
|
|
229
|
+
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
|
|
230
|
+
ignore: NotRequired[Nullable[List[ProviderPreferencesIgnoreTypedDict]]]
|
|
231
|
+
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
|
232
|
+
quantizations: NotRequired[Nullable[List[Quantization]]]
|
|
233
|
+
r"""A list of quantization levels to filter the provider by."""
|
|
234
|
+
sort: NotRequired[Nullable[ProviderPreferencesSortUnionTypedDict]]
|
|
235
|
+
max_price: NotRequired[ProviderPreferencesMaxPriceTypedDict]
|
|
236
|
+
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
|
237
|
+
preferred_min_throughput: NotRequired[Nullable[float]]
|
|
238
|
+
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."""
|
|
239
|
+
preferred_max_latency: NotRequired[Nullable[float]]
|
|
240
|
+
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."""
|
|
241
|
+
min_throughput: NotRequired[Nullable[float]]
|
|
242
|
+
r"""**DEPRECATED** Use preferred_min_throughput instead. Backwards-compatible alias for preferred_min_throughput."""
|
|
243
|
+
max_latency: NotRequired[Nullable[float]]
|
|
244
|
+
r"""**DEPRECATED** Use preferred_max_latency instead. Backwards-compatible alias for preferred_max_latency."""
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
class ProviderPreferences(BaseModel):
|
|
248
|
+
r"""Provider routing preferences for the request."""
|
|
249
|
+
|
|
250
|
+
allow_fallbacks: OptionalNullable[bool] = UNSET
|
|
251
|
+
r"""Whether to allow backup providers to serve requests
|
|
252
|
+
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
|
|
253
|
+
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
|
|
254
|
+
|
|
255
|
+
"""
|
|
256
|
+
|
|
257
|
+
require_parameters: OptionalNullable[bool] = UNSET
|
|
258
|
+
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."""
|
|
259
|
+
|
|
260
|
+
data_collection: Annotated[
|
|
261
|
+
OptionalNullable[DataCollection], PlainValidator(validate_open_enum(False))
|
|
262
|
+
] = UNSET
|
|
263
|
+
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
|
264
|
+
- allow: (default) allow providers which store user data non-transiently and may train on it
|
|
265
|
+
|
|
266
|
+
- deny: use only providers which do not collect user data.
|
|
267
|
+
"""
|
|
268
|
+
|
|
269
|
+
zdr: OptionalNullable[bool] = UNSET
|
|
270
|
+
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
|
|
271
|
+
|
|
272
|
+
enforce_distillable_text: OptionalNullable[bool] = UNSET
|
|
273
|
+
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."""
|
|
274
|
+
|
|
275
|
+
order: OptionalNullable[List[ProviderPreferencesOrder]] = UNSET
|
|
276
|
+
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."""
|
|
277
|
+
|
|
278
|
+
only: OptionalNullable[List[ProviderPreferencesOnly]] = UNSET
|
|
279
|
+
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
|
|
280
|
+
|
|
281
|
+
ignore: OptionalNullable[List[ProviderPreferencesIgnore]] = UNSET
|
|
282
|
+
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
|
283
|
+
|
|
284
|
+
quantizations: OptionalNullable[
|
|
285
|
+
List[Annotated[Quantization, PlainValidator(validate_open_enum(False))]]
|
|
286
|
+
] = UNSET
|
|
287
|
+
r"""A list of quantization levels to filter the provider by."""
|
|
288
|
+
|
|
289
|
+
sort: OptionalNullable[ProviderPreferencesSortUnion] = UNSET
|
|
290
|
+
|
|
291
|
+
max_price: Optional[ProviderPreferencesMaxPrice] = None
|
|
292
|
+
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
|
293
|
+
|
|
294
|
+
preferred_min_throughput: OptionalNullable[float] = UNSET
|
|
295
|
+
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."""
|
|
296
|
+
|
|
297
|
+
preferred_max_latency: OptionalNullable[float] = UNSET
|
|
298
|
+
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."""
|
|
299
|
+
|
|
300
|
+
min_throughput: Annotated[
|
|
301
|
+
OptionalNullable[float],
|
|
302
|
+
pydantic.Field(
|
|
303
|
+
deprecated="warning: ** DEPRECATED ** - Use preferred_min_throughput instead.."
|
|
304
|
+
),
|
|
305
|
+
] = UNSET
|
|
306
|
+
r"""**DEPRECATED** Use preferred_min_throughput instead. Backwards-compatible alias for preferred_min_throughput."""
|
|
307
|
+
|
|
308
|
+
max_latency: Annotated[
|
|
309
|
+
OptionalNullable[float],
|
|
310
|
+
pydantic.Field(
|
|
311
|
+
deprecated="warning: ** DEPRECATED ** - Use preferred_max_latency instead.."
|
|
312
|
+
),
|
|
313
|
+
] = UNSET
|
|
314
|
+
r"""**DEPRECATED** Use preferred_max_latency instead. Backwards-compatible alias for preferred_max_latency."""
|
|
315
|
+
|
|
316
|
+
@model_serializer(mode="wrap")
|
|
317
|
+
def serialize_model(self, handler):
|
|
318
|
+
optional_fields = [
|
|
319
|
+
"allow_fallbacks",
|
|
320
|
+
"require_parameters",
|
|
321
|
+
"data_collection",
|
|
322
|
+
"zdr",
|
|
323
|
+
"enforce_distillable_text",
|
|
324
|
+
"order",
|
|
325
|
+
"only",
|
|
326
|
+
"ignore",
|
|
327
|
+
"quantizations",
|
|
328
|
+
"sort",
|
|
329
|
+
"max_price",
|
|
330
|
+
"preferred_min_throughput",
|
|
331
|
+
"preferred_max_latency",
|
|
332
|
+
"min_throughput",
|
|
333
|
+
"max_latency",
|
|
334
|
+
]
|
|
335
|
+
nullable_fields = [
|
|
336
|
+
"allow_fallbacks",
|
|
337
|
+
"require_parameters",
|
|
338
|
+
"data_collection",
|
|
339
|
+
"zdr",
|
|
340
|
+
"enforce_distillable_text",
|
|
341
|
+
"order",
|
|
342
|
+
"only",
|
|
343
|
+
"ignore",
|
|
344
|
+
"quantizations",
|
|
345
|
+
"sort",
|
|
346
|
+
"preferred_min_throughput",
|
|
347
|
+
"preferred_max_latency",
|
|
348
|
+
"min_throughput",
|
|
349
|
+
"max_latency",
|
|
350
|
+
]
|
|
351
|
+
null_default_fields = []
|
|
352
|
+
|
|
353
|
+
serialized = handler(self)
|
|
354
|
+
|
|
355
|
+
m = {}
|
|
356
|
+
|
|
357
|
+
for n, f in type(self).model_fields.items():
|
|
358
|
+
k = f.alias or n
|
|
359
|
+
val = serialized.get(k)
|
|
360
|
+
serialized.pop(k, None)
|
|
361
|
+
|
|
362
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
363
|
+
is_set = (
|
|
364
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
365
|
+
or k in null_default_fields
|
|
366
|
+
) # pylint: disable=no-member
|
|
367
|
+
|
|
368
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
369
|
+
m[k] = val
|
|
370
|
+
elif val != UNSET_SENTINEL and (
|
|
371
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
372
|
+
):
|
|
373
|
+
m[k] = val
|
|
374
|
+
|
|
375
|
+
return m
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from openrouter.types import UnrecognizedStr
|
|
5
|
+
from typing import Literal, Union
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
ProviderSort = Union[
|
|
9
|
+
Literal[
|
|
10
|
+
"price",
|
|
11
|
+
"throughput",
|
|
12
|
+
"latency",
|
|
13
|
+
],
|
|
14
|
+
UnrecognizedStr,
|
|
15
|
+
]
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .providersort import ProviderSort
|
|
5
|
+
from openrouter.types import (
|
|
6
|
+
BaseModel,
|
|
7
|
+
Nullable,
|
|
8
|
+
OptionalNullable,
|
|
9
|
+
UNSET,
|
|
10
|
+
UNSET_SENTINEL,
|
|
11
|
+
UnrecognizedStr,
|
|
12
|
+
)
|
|
13
|
+
from openrouter.utils import validate_open_enum
|
|
14
|
+
from pydantic import model_serializer
|
|
15
|
+
from pydantic.functional_validators import PlainValidator
|
|
16
|
+
from typing import Literal, Union
|
|
17
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Partition = Union[
|
|
21
|
+
Literal[
|
|
22
|
+
"model",
|
|
23
|
+
"none",
|
|
24
|
+
],
|
|
25
|
+
UnrecognizedStr,
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ProviderSortConfigTypedDict(TypedDict):
|
|
30
|
+
by: NotRequired[Nullable[ProviderSort]]
|
|
31
|
+
partition: NotRequired[Nullable[Partition]]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ProviderSortConfig(BaseModel):
|
|
35
|
+
by: Annotated[
|
|
36
|
+
OptionalNullable[ProviderSort], PlainValidator(validate_open_enum(False))
|
|
37
|
+
] = UNSET
|
|
38
|
+
|
|
39
|
+
partition: Annotated[
|
|
40
|
+
OptionalNullable[Partition], PlainValidator(validate_open_enum(False))
|
|
41
|
+
] = UNSET
|
|
42
|
+
|
|
43
|
+
@model_serializer(mode="wrap")
|
|
44
|
+
def serialize_model(self, handler):
|
|
45
|
+
optional_fields = ["by", "partition"]
|
|
46
|
+
nullable_fields = ["by", "partition"]
|
|
47
|
+
null_default_fields = []
|
|
48
|
+
|
|
49
|
+
serialized = handler(self)
|
|
50
|
+
|
|
51
|
+
m = {}
|
|
52
|
+
|
|
53
|
+
for n, f in type(self).model_fields.items():
|
|
54
|
+
k = f.alias or n
|
|
55
|
+
val = serialized.get(k)
|
|
56
|
+
serialized.pop(k, None)
|
|
57
|
+
|
|
58
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
59
|
+
is_set = (
|
|
60
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
61
|
+
or k in null_default_fields
|
|
62
|
+
) # pylint: disable=no-member
|
|
63
|
+
|
|
64
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
65
|
+
m[k] = val
|
|
66
|
+
elif val != UNSET_SENTINEL and (
|
|
67
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
68
|
+
):
|
|
69
|
+
m[k] = val
|
|
70
|
+
|
|
71
|
+
return m
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .providersort import ProviderSort
|
|
5
|
+
from .providersortconfig import ProviderSortConfig, ProviderSortConfigTypedDict
|
|
6
|
+
from openrouter.utils import validate_open_enum
|
|
7
|
+
from pydantic.functional_validators import PlainValidator
|
|
8
|
+
from typing import Union
|
|
9
|
+
from typing_extensions import Annotated, TypeAliasType
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
ProviderSortUnionTypedDict = TypeAliasType(
|
|
13
|
+
"ProviderSortUnionTypedDict", Union[ProviderSortConfigTypedDict, ProviderSort]
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
ProviderSortUnion = TypeAliasType(
|
|
18
|
+
"ProviderSortUnion",
|
|
19
|
+
Union[
|
|
20
|
+
ProviderSortConfig,
|
|
21
|
+
Annotated[ProviderSort, PlainValidator(validate_open_enum(False))],
|
|
22
|
+
],
|
|
23
|
+
)
|
|
@@ -8,69 +8,74 @@ from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedSt
|
|
|
8
8
|
from openrouter.utils import validate_open_enum
|
|
9
9
|
from pydantic import model_serializer
|
|
10
10
|
from pydantic.functional_validators import PlainValidator
|
|
11
|
-
from typing import
|
|
11
|
+
from typing import List, Literal, Optional, Union
|
|
12
12
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class PricingTypedDict(TypedDict):
|
|
16
|
-
prompt:
|
|
17
|
-
r"""A value in string
|
|
18
|
-
completion:
|
|
19
|
-
r"""A value in string
|
|
20
|
-
request: NotRequired[
|
|
21
|
-
r"""A value in string
|
|
22
|
-
image: NotRequired[
|
|
23
|
-
r"""A value in string
|
|
24
|
-
|
|
25
|
-
r"""A value in string
|
|
26
|
-
|
|
27
|
-
r"""A value in string
|
|
28
|
-
|
|
29
|
-
r"""A value in string
|
|
30
|
-
|
|
31
|
-
r"""A value in string
|
|
32
|
-
|
|
33
|
-
r"""A value in string
|
|
34
|
-
|
|
35
|
-
r"""A value in string
|
|
36
|
-
|
|
37
|
-
r"""A value in string
|
|
16
|
+
prompt: str
|
|
17
|
+
r"""A value in string format that is a large number"""
|
|
18
|
+
completion: str
|
|
19
|
+
r"""A value in string format that is a large number"""
|
|
20
|
+
request: NotRequired[str]
|
|
21
|
+
r"""A value in string format that is a large number"""
|
|
22
|
+
image: NotRequired[str]
|
|
23
|
+
r"""A value in string format that is a large number"""
|
|
24
|
+
image_token: NotRequired[str]
|
|
25
|
+
r"""A value in string format that is a large number"""
|
|
26
|
+
image_output: NotRequired[str]
|
|
27
|
+
r"""A value in string format that is a large number"""
|
|
28
|
+
audio: NotRequired[str]
|
|
29
|
+
r"""A value in string format that is a large number"""
|
|
30
|
+
input_audio_cache: NotRequired[str]
|
|
31
|
+
r"""A value in string format that is a large number"""
|
|
32
|
+
web_search: NotRequired[str]
|
|
33
|
+
r"""A value in string format that is a large number"""
|
|
34
|
+
internal_reasoning: NotRequired[str]
|
|
35
|
+
r"""A value in string format that is a large number"""
|
|
36
|
+
input_cache_read: NotRequired[str]
|
|
37
|
+
r"""A value in string format that is a large number"""
|
|
38
|
+
input_cache_write: NotRequired[str]
|
|
39
|
+
r"""A value in string format that is a large number"""
|
|
38
40
|
discount: NotRequired[float]
|
|
39
41
|
|
|
40
42
|
|
|
41
43
|
class Pricing(BaseModel):
|
|
42
|
-
prompt:
|
|
43
|
-
r"""A value in string
|
|
44
|
+
prompt: str
|
|
45
|
+
r"""A value in string format that is a large number"""
|
|
44
46
|
|
|
45
|
-
completion:
|
|
46
|
-
r"""A value in string
|
|
47
|
+
completion: str
|
|
48
|
+
r"""A value in string format that is a large number"""
|
|
47
49
|
|
|
48
|
-
request: Optional[
|
|
49
|
-
r"""A value in string
|
|
50
|
+
request: Optional[str] = None
|
|
51
|
+
r"""A value in string format that is a large number"""
|
|
50
52
|
|
|
51
|
-
image: Optional[
|
|
52
|
-
r"""A value in string
|
|
53
|
+
image: Optional[str] = None
|
|
54
|
+
r"""A value in string format that is a large number"""
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
r"""A value in string
|
|
56
|
+
image_token: Optional[str] = None
|
|
57
|
+
r"""A value in string format that is a large number"""
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
r"""A value in string
|
|
59
|
+
image_output: Optional[str] = None
|
|
60
|
+
r"""A value in string format that is a large number"""
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
r"""A value in string
|
|
62
|
+
audio: Optional[str] = None
|
|
63
|
+
r"""A value in string format that is a large number"""
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
r"""A value in string
|
|
65
|
+
input_audio_cache: Optional[str] = None
|
|
66
|
+
r"""A value in string format that is a large number"""
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
r"""A value in string
|
|
68
|
+
web_search: Optional[str] = None
|
|
69
|
+
r"""A value in string format that is a large number"""
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
r"""A value in string
|
|
71
|
+
internal_reasoning: Optional[str] = None
|
|
72
|
+
r"""A value in string format that is a large number"""
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
r"""A value in string
|
|
74
|
+
input_cache_read: Optional[str] = None
|
|
75
|
+
r"""A value in string format that is a large number"""
|
|
76
|
+
|
|
77
|
+
input_cache_write: Optional[str] = None
|
|
78
|
+
r"""A value in string format that is a large number"""
|
|
74
79
|
|
|
75
80
|
discount: Optional[float] = None
|
|
76
81
|
|