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.
Files changed (48) hide show
  1. openrouter/_version.py +2 -2
  2. openrouter/chat.py +70 -12
  3. openrouter/components/__init__.py +328 -81
  4. openrouter/components/_schema0.py +3 -2
  5. openrouter/components/_schema3.py +229 -0
  6. openrouter/components/chatgenerationparams.py +211 -53
  7. openrouter/components/chatgenerationtokenusage.py +3 -0
  8. openrouter/components/chatmessagetokenlogprob.py +4 -4
  9. openrouter/components/chatresponsechoice.py +6 -1
  10. openrouter/components/chatstreamingmessagechunk.py +12 -1
  11. openrouter/components/openresponseseasyinputmessage.py +93 -20
  12. openrouter/components/openresponsesinput.py +2 -2
  13. openrouter/components/openresponsesinputmessageitem.py +87 -14
  14. openrouter/components/openresponsesnonstreamingresponse.py +20 -9
  15. openrouter/components/openresponsesreasoning.py +1 -0
  16. openrouter/components/openresponsesrequest.py +141 -88
  17. openrouter/components/parameter.py +1 -0
  18. openrouter/components/pdfparserengine.py +16 -0
  19. openrouter/components/pdfparseroptions.py +25 -0
  20. openrouter/components/percentilelatencycutoffs.py +71 -0
  21. openrouter/components/percentilestats.py +34 -0
  22. openrouter/components/percentilethroughputcutoffs.py +71 -0
  23. openrouter/components/preferredmaxlatency.py +21 -0
  24. openrouter/components/preferredminthroughput.py +22 -0
  25. openrouter/components/providername.py +3 -2
  26. openrouter/components/providerpreferences.py +355 -0
  27. openrouter/components/providersort.py +0 -1
  28. openrouter/components/providersortconfig.py +71 -0
  29. openrouter/components/providersortunion.py +23 -0
  30. openrouter/components/publicendpoint.py +11 -0
  31. openrouter/components/responseinputvideo.py +26 -0
  32. openrouter/components/responseoutputtext.py +36 -1
  33. openrouter/components/responsesoutputitem.py +1 -1
  34. openrouter/components/responsesoutputitemreasoning.py +43 -3
  35. openrouter/components/responsesoutputmodality.py +14 -0
  36. openrouter/components/websearchengine.py +15 -0
  37. openrouter/embeddings.py +6 -8
  38. openrouter/operations/__init__.py +0 -33
  39. openrouter/operations/createembeddings.py +7 -258
  40. openrouter/operations/getgeneration.py +6 -0
  41. openrouter/operations/getparameters.py +5 -78
  42. openrouter/parameters.py +2 -2
  43. openrouter/responses.py +114 -14
  44. {openrouter-0.0.22.dist-info → openrouter-0.1.2.dist-info}/METADATA +1 -1
  45. {openrouter-0.0.22.dist-info → openrouter-0.1.2.dist-info}/RECORD +48 -34
  46. {openrouter-0.0.22.dist-info → openrouter-0.1.2.dist-info}/WHEEL +1 -1
  47. {openrouter-0.0.22.dist-info → openrouter-0.1.2.dist-info}/licenses/LICENSE +0 -0
  48. {openrouter-0.0.22.dist-info → openrouter-0.1.2.dist-info}/top_level.txt +0 -0
@@ -9,10 +9,14 @@ from openrouter.types import (
9
9
  OptionalNullable,
10
10
  UNSET,
11
11
  UNSET_SENTINEL,
12
+ UnrecognizedStr,
12
13
  )
14
+ from openrouter.utils import validate_open_enum
15
+ import pydantic
13
16
  from pydantic import model_serializer
17
+ from pydantic.functional_validators import PlainValidator
14
18
  from typing import List, Literal, Optional, Union
15
- from typing_extensions import NotRequired, TypeAliasType, TypedDict
19
+ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
16
20
 
17
21
 
18
22
  ResponsesOutputItemReasoningType = Literal["reasoning",]
@@ -47,6 +51,20 @@ ResponsesOutputItemReasoningStatusUnion = TypeAliasType(
47
51
  )
48
52
 
49
53
 
54
+ ResponsesOutputItemReasoningFormat = Union[
55
+ Literal[
56
+ "unknown",
57
+ "openai-responses-v1",
58
+ "azure-openai-responses-v1",
59
+ "xai-responses-v1",
60
+ "anthropic-claude-v1",
61
+ "google-gemini-v1",
62
+ ],
63
+ UnrecognizedStr,
64
+ ]
65
+ r"""The format of the reasoning content"""
66
+
67
+
50
68
  class ResponsesOutputItemReasoningTypedDict(TypedDict):
51
69
  r"""An output item containing reasoning"""
52
70
 
@@ -56,6 +74,10 @@ class ResponsesOutputItemReasoningTypedDict(TypedDict):
56
74
  content: NotRequired[List[ReasoningTextContentTypedDict]]
57
75
  encrypted_content: NotRequired[Nullable[str]]
58
76
  status: NotRequired[ResponsesOutputItemReasoningStatusUnionTypedDict]
77
+ signature: NotRequired[Nullable[str]]
78
+ r"""A signature for the reasoning content, used for verification"""
79
+ format_: NotRequired[Nullable[ResponsesOutputItemReasoningFormat]]
80
+ r"""The format of the reasoning content"""
59
81
 
60
82
 
61
83
  class ResponsesOutputItemReasoning(BaseModel):
@@ -73,10 +95,28 @@ class ResponsesOutputItemReasoning(BaseModel):
73
95
 
74
96
  status: Optional[ResponsesOutputItemReasoningStatusUnion] = None
75
97
 
98
+ signature: OptionalNullable[str] = UNSET
99
+ r"""A signature for the reasoning content, used for verification"""
100
+
101
+ format_: Annotated[
102
+ Annotated[
103
+ OptionalNullable[ResponsesOutputItemReasoningFormat],
104
+ PlainValidator(validate_open_enum(False)),
105
+ ],
106
+ pydantic.Field(alias="format"),
107
+ ] = UNSET
108
+ r"""The format of the reasoning content"""
109
+
76
110
  @model_serializer(mode="wrap")
77
111
  def serialize_model(self, handler):
78
- optional_fields = ["content", "encrypted_content", "status"]
79
- nullable_fields = ["encrypted_content"]
112
+ optional_fields = [
113
+ "content",
114
+ "encrypted_content",
115
+ "status",
116
+ "signature",
117
+ "format",
118
+ ]
119
+ nullable_fields = ["encrypted_content", "signature", "format"]
80
120
  null_default_fields = []
81
121
 
82
122
  serialized = handler(self)
@@ -0,0 +1,14 @@
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
+ ResponsesOutputModality = Union[
9
+ Literal[
10
+ "text",
11
+ "image",
12
+ ],
13
+ UnrecognizedStr,
14
+ ]
@@ -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
+ WebSearchEngine = Union[
9
+ Literal[
10
+ "native",
11
+ "exa",
12
+ ],
13
+ UnrecognizedStr,
14
+ ]
15
+ r"""The search engine to use for web search."""
openrouter/embeddings.py CHANGED
@@ -28,8 +28,7 @@ class Embeddings(BaseSDK):
28
28
  user: Optional[str] = None,
29
29
  provider: Optional[
30
30
  Union[
31
- operations.CreateEmbeddingsProvider,
32
- operations.CreateEmbeddingsProviderTypedDict,
31
+ components.ProviderPreferences, components.ProviderPreferencesTypedDict
33
32
  ]
34
33
  ] = None,
35
34
  input_type: Optional[str] = None,
@@ -48,7 +47,7 @@ class Embeddings(BaseSDK):
48
47
  :param encoding_format:
49
48
  :param dimensions:
50
49
  :param user:
51
- :param provider:
50
+ :param provider: Provider routing preferences for the request.
52
51
  :param input_type:
53
52
  :param retries: Override the default retry configuration for this method
54
53
  :param server_url: Override the default server URL for this method
@@ -73,7 +72,7 @@ class Embeddings(BaseSDK):
73
72
  dimensions=dimensions,
74
73
  user=user,
75
74
  provider=utils.get_pydantic_model(
76
- provider, Optional[operations.CreateEmbeddingsProvider]
75
+ provider, Optional[components.ProviderPreferences]
77
76
  ),
78
77
  input_type=input_type,
79
78
  )
@@ -216,8 +215,7 @@ class Embeddings(BaseSDK):
216
215
  user: Optional[str] = None,
217
216
  provider: Optional[
218
217
  Union[
219
- operations.CreateEmbeddingsProvider,
220
- operations.CreateEmbeddingsProviderTypedDict,
218
+ components.ProviderPreferences, components.ProviderPreferencesTypedDict
221
219
  ]
222
220
  ] = None,
223
221
  input_type: Optional[str] = None,
@@ -236,7 +234,7 @@ class Embeddings(BaseSDK):
236
234
  :param encoding_format:
237
235
  :param dimensions:
238
236
  :param user:
239
- :param provider:
237
+ :param provider: Provider routing preferences for the request.
240
238
  :param input_type:
241
239
  :param retries: Override the default retry configuration for this method
242
240
  :param server_url: Override the default server URL for this method
@@ -261,7 +259,7 @@ class Embeddings(BaseSDK):
261
259
  dimensions=dimensions,
262
260
  user=user,
263
261
  provider=utils.get_pydantic_model(
264
- provider, Optional[operations.CreateEmbeddingsProvider]
262
+ provider, Optional[components.ProviderPreferences]
265
263
  ),
266
264
  input_type=input_type,
267
265
  )
@@ -40,8 +40,6 @@ if TYPE_CHECKING:
40
40
  ContentTypedDict,
41
41
  CreateEmbeddingsData,
42
42
  CreateEmbeddingsDataTypedDict,
43
- CreateEmbeddingsProvider,
44
- CreateEmbeddingsProviderTypedDict,
45
43
  CreateEmbeddingsRequest,
46
44
  CreateEmbeddingsRequestTypedDict,
47
45
  CreateEmbeddingsResponse,
@@ -51,22 +49,14 @@ if TYPE_CHECKING:
51
49
  Embedding,
52
50
  EmbeddingTypedDict,
53
51
  EncodingFormat,
54
- Ignore,
55
- IgnoreTypedDict,
56
52
  ImageURL,
57
53
  ImageURLTypedDict,
58
54
  Input,
59
55
  InputTypedDict,
60
56
  InputUnion,
61
57
  InputUnionTypedDict,
62
- MaxPrice,
63
- MaxPriceTypedDict,
64
58
  Object,
65
59
  ObjectEmbedding,
66
- Only,
67
- OnlyTypedDict,
68
- Order,
69
- OrderTypedDict,
70
60
  TypeImageURL,
71
61
  TypeText,
72
62
  Usage,
@@ -135,7 +125,6 @@ if TYPE_CHECKING:
135
125
  from .getparameters import (
136
126
  GetParametersData,
137
127
  GetParametersDataTypedDict,
138
- GetParametersProvider,
139
128
  GetParametersRequest,
140
129
  GetParametersRequestTypedDict,
141
130
  GetParametersResponse,
@@ -216,8 +205,6 @@ __all__ = [
216
205
  "CreateCoinbaseChargeSecurityTypedDict",
217
206
  "CreateEmbeddingsData",
218
207
  "CreateEmbeddingsDataTypedDict",
219
- "CreateEmbeddingsProvider",
220
- "CreateEmbeddingsProviderTypedDict",
221
208
  "CreateEmbeddingsRequest",
222
209
  "CreateEmbeddingsRequestTypedDict",
223
210
  "CreateEmbeddingsResponse",
@@ -271,7 +258,6 @@ __all__ = [
271
258
  "GetModelsRequestTypedDict",
272
259
  "GetParametersData",
273
260
  "GetParametersDataTypedDict",
274
- "GetParametersProvider",
275
261
  "GetParametersRequest",
276
262
  "GetParametersRequestTypedDict",
277
263
  "GetParametersResponse",
@@ -282,8 +268,6 @@ __all__ = [
282
268
  "GetUserActivityRequestTypedDict",
283
269
  "GetUserActivityResponse",
284
270
  "GetUserActivityResponseTypedDict",
285
- "Ignore",
286
- "IgnoreTypedDict",
287
271
  "ImageURL",
288
272
  "ImageURLTypedDict",
289
273
  "Input",
@@ -308,16 +292,10 @@ __all__ = [
308
292
  "ListRequestTypedDict",
309
293
  "ListResponse",
310
294
  "ListResponseTypedDict",
311
- "MaxPrice",
312
- "MaxPriceTypedDict",
313
295
  "Metadata",
314
296
  "MetadataTypedDict",
315
297
  "Object",
316
298
  "ObjectEmbedding",
317
- "Only",
318
- "OnlyTypedDict",
319
- "Order",
320
- "OrderTypedDict",
321
299
  "RateLimit",
322
300
  "RateLimitTypedDict",
323
301
  "SendChatCompletionRequestResponse",
@@ -372,8 +350,6 @@ _dynamic_imports: dict[str, str] = {
372
350
  "ContentTypedDict": ".createembeddings",
373
351
  "CreateEmbeddingsData": ".createembeddings",
374
352
  "CreateEmbeddingsDataTypedDict": ".createembeddings",
375
- "CreateEmbeddingsProvider": ".createembeddings",
376
- "CreateEmbeddingsProviderTypedDict": ".createembeddings",
377
353
  "CreateEmbeddingsRequest": ".createembeddings",
378
354
  "CreateEmbeddingsRequestTypedDict": ".createembeddings",
379
355
  "CreateEmbeddingsResponse": ".createembeddings",
@@ -383,22 +359,14 @@ _dynamic_imports: dict[str, str] = {
383
359
  "Embedding": ".createembeddings",
384
360
  "EmbeddingTypedDict": ".createembeddings",
385
361
  "EncodingFormat": ".createembeddings",
386
- "Ignore": ".createembeddings",
387
- "IgnoreTypedDict": ".createembeddings",
388
362
  "ImageURL": ".createembeddings",
389
363
  "ImageURLTypedDict": ".createembeddings",
390
364
  "Input": ".createembeddings",
391
365
  "InputTypedDict": ".createembeddings",
392
366
  "InputUnion": ".createembeddings",
393
367
  "InputUnionTypedDict": ".createembeddings",
394
- "MaxPrice": ".createembeddings",
395
- "MaxPriceTypedDict": ".createembeddings",
396
368
  "Object": ".createembeddings",
397
369
  "ObjectEmbedding": ".createembeddings",
398
- "Only": ".createembeddings",
399
- "OnlyTypedDict": ".createembeddings",
400
- "Order": ".createembeddings",
401
- "OrderTypedDict": ".createembeddings",
402
370
  "TypeImageURL": ".createembeddings",
403
371
  "TypeText": ".createembeddings",
404
372
  "Usage": ".createembeddings",
@@ -450,7 +418,6 @@ _dynamic_imports: dict[str, str] = {
450
418
  "GetModelsRequestTypedDict": ".getmodels",
451
419
  "GetParametersData": ".getparameters",
452
420
  "GetParametersDataTypedDict": ".getparameters",
453
- "GetParametersProvider": ".getparameters",
454
421
  "GetParametersRequest": ".getparameters",
455
422
  "GetParametersRequestTypedDict": ".getparameters",
456
423
  "GetParametersResponse": ".getparameters",
@@ -1,22 +1,10 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from openrouter.components import (
5
- datacollection as components_datacollection,
6
- providername as components_providername,
7
- providersort as components_providersort,
8
- quantization as components_quantization,
9
- )
10
- from openrouter.types import (
11
- BaseModel,
12
- Nullable,
13
- OptionalNullable,
14
- UNSET,
15
- UNSET_SENTINEL,
16
- UnrecognizedStr,
17
- )
4
+ from openrouter.components import providerpreferences as components_providerpreferences
5
+ from openrouter.types import BaseModel, UnrecognizedStr
18
6
  from openrouter.utils import get_discriminator, validate_open_enum
19
- from pydantic import Discriminator, Tag, model_serializer
7
+ from pydantic import Discriminator, Tag
20
8
  from pydantic.functional_validators import PlainValidator
21
9
  from typing import List, Literal, Optional, Union
22
10
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -100,254 +88,14 @@ EncodingFormat = Union[
100
88
  ]
101
89
 
102
90
 
103
- OrderTypedDict = TypeAliasType(
104
- "OrderTypedDict", Union[components_providername.ProviderName, str]
105
- )
106
-
107
-
108
- Order = TypeAliasType(
109
- "Order",
110
- Union[
111
- Annotated[
112
- components_providername.ProviderName,
113
- PlainValidator(validate_open_enum(False)),
114
- ],
115
- str,
116
- ],
117
- )
118
-
119
-
120
- OnlyTypedDict = TypeAliasType(
121
- "OnlyTypedDict", Union[components_providername.ProviderName, str]
122
- )
123
-
124
-
125
- Only = TypeAliasType(
126
- "Only",
127
- Union[
128
- Annotated[
129
- components_providername.ProviderName,
130
- PlainValidator(validate_open_enum(False)),
131
- ],
132
- str,
133
- ],
134
- )
135
-
136
-
137
- IgnoreTypedDict = TypeAliasType(
138
- "IgnoreTypedDict", Union[components_providername.ProviderName, str]
139
- )
140
-
141
-
142
- Ignore = TypeAliasType(
143
- "Ignore",
144
- Union[
145
- Annotated[
146
- components_providername.ProviderName,
147
- PlainValidator(validate_open_enum(False)),
148
- ],
149
- str,
150
- ],
151
- )
152
-
153
-
154
- class MaxPriceTypedDict(TypedDict):
155
- r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
156
-
157
- prompt: NotRequired[str]
158
- r"""A value in string format that is a large number"""
159
- completion: NotRequired[str]
160
- r"""A value in string format that is a large number"""
161
- image: NotRequired[str]
162
- r"""A value in string format that is a large number"""
163
- audio: NotRequired[str]
164
- r"""A value in string format that is a large number"""
165
- request: NotRequired[str]
166
- r"""A value in string format that is a large number"""
167
-
168
-
169
- class MaxPrice(BaseModel):
170
- r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
171
-
172
- prompt: Optional[str] = None
173
- r"""A value in string format that is a large number"""
174
-
175
- completion: Optional[str] = None
176
- r"""A value in string format that is a large number"""
177
-
178
- image: Optional[str] = None
179
- r"""A value in string format that is a large number"""
180
-
181
- audio: Optional[str] = None
182
- r"""A value in string format that is a large number"""
183
-
184
- request: Optional[str] = None
185
- r"""A value in string format that is a large number"""
186
-
187
-
188
- class CreateEmbeddingsProviderTypedDict(TypedDict):
189
- allow_fallbacks: NotRequired[Nullable[bool]]
190
- r"""Whether to allow backup providers to serve requests
191
- - true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
192
- - false: use only the primary/custom provider, and return the upstream error if it's unavailable.
193
-
194
- """
195
- require_parameters: NotRequired[Nullable[bool]]
196
- 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."""
197
- data_collection: NotRequired[Nullable[components_datacollection.DataCollection]]
198
- r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
199
- - allow: (default) allow providers which store user data non-transiently and may train on it
200
-
201
- - deny: use only providers which do not collect user data.
202
- """
203
- zdr: NotRequired[Nullable[bool]]
204
- r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
205
- enforce_distillable_text: NotRequired[Nullable[bool]]
206
- 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."""
207
- order: NotRequired[Nullable[List[OrderTypedDict]]]
208
- 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."""
209
- only: NotRequired[Nullable[List[OnlyTypedDict]]]
210
- r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
211
- ignore: NotRequired[Nullable[List[IgnoreTypedDict]]]
212
- r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
213
- quantizations: NotRequired[Nullable[List[components_quantization.Quantization]]]
214
- r"""A list of quantization levels to filter the provider by."""
215
- sort: NotRequired[Nullable[components_providersort.ProviderSort]]
216
- r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
217
- max_price: NotRequired[MaxPriceTypedDict]
218
- r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
219
- min_throughput: NotRequired[Nullable[float]]
220
- 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."""
221
- max_latency: NotRequired[Nullable[float]]
222
- r"""The maximum latency (in seconds) allowed for this request. Only providers serving the model with better than this latency will be used."""
223
-
224
-
225
- class CreateEmbeddingsProvider(BaseModel):
226
- allow_fallbacks: OptionalNullable[bool] = UNSET
227
- r"""Whether to allow backup providers to serve requests
228
- - true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
229
- - false: use only the primary/custom provider, and return the upstream error if it's unavailable.
230
-
231
- """
232
-
233
- require_parameters: OptionalNullable[bool] = UNSET
234
- 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."""
235
-
236
- data_collection: Annotated[
237
- OptionalNullable[components_datacollection.DataCollection],
238
- PlainValidator(validate_open_enum(False)),
239
- ] = UNSET
240
- r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
241
- - allow: (default) allow providers which store user data non-transiently and may train on it
242
-
243
- - deny: use only providers which do not collect user data.
244
- """
245
-
246
- zdr: OptionalNullable[bool] = UNSET
247
- r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
248
-
249
- enforce_distillable_text: OptionalNullable[bool] = UNSET
250
- 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."""
251
-
252
- order: OptionalNullable[List[Order]] = UNSET
253
- 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."""
254
-
255
- only: OptionalNullable[List[Only]] = UNSET
256
- r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
257
-
258
- ignore: OptionalNullable[List[Ignore]] = UNSET
259
- r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
260
-
261
- quantizations: OptionalNullable[
262
- List[
263
- Annotated[
264
- components_quantization.Quantization,
265
- PlainValidator(validate_open_enum(False)),
266
- ]
267
- ]
268
- ] = UNSET
269
- r"""A list of quantization levels to filter the provider by."""
270
-
271
- sort: Annotated[
272
- OptionalNullable[components_providersort.ProviderSort],
273
- PlainValidator(validate_open_enum(False)),
274
- ] = UNSET
275
- r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
276
-
277
- max_price: Optional[MaxPrice] = None
278
- r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
279
-
280
- min_throughput: OptionalNullable[float] = UNSET
281
- 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."""
282
-
283
- max_latency: OptionalNullable[float] = UNSET
284
- r"""The maximum latency (in seconds) allowed for this request. Only providers serving the model with better than this latency will be used."""
285
-
286
- @model_serializer(mode="wrap")
287
- def serialize_model(self, handler):
288
- optional_fields = [
289
- "allow_fallbacks",
290
- "require_parameters",
291
- "data_collection",
292
- "zdr",
293
- "enforce_distillable_text",
294
- "order",
295
- "only",
296
- "ignore",
297
- "quantizations",
298
- "sort",
299
- "max_price",
300
- "min_throughput",
301
- "max_latency",
302
- ]
303
- nullable_fields = [
304
- "allow_fallbacks",
305
- "require_parameters",
306
- "data_collection",
307
- "zdr",
308
- "enforce_distillable_text",
309
- "order",
310
- "only",
311
- "ignore",
312
- "quantizations",
313
- "sort",
314
- "min_throughput",
315
- "max_latency",
316
- ]
317
- null_default_fields = []
318
-
319
- serialized = handler(self)
320
-
321
- m = {}
322
-
323
- for n, f in type(self).model_fields.items():
324
- k = f.alias or n
325
- val = serialized.get(k)
326
- serialized.pop(k, None)
327
-
328
- optional_nullable = k in optional_fields and k in nullable_fields
329
- is_set = (
330
- self.__pydantic_fields_set__.intersection({n})
331
- or k in null_default_fields
332
- ) # pylint: disable=no-member
333
-
334
- if val is not None and val != UNSET_SENTINEL:
335
- m[k] = val
336
- elif val != UNSET_SENTINEL and (
337
- not k in optional_fields or (optional_nullable and is_set)
338
- ):
339
- m[k] = val
340
-
341
- return m
342
-
343
-
344
91
  class CreateEmbeddingsRequestTypedDict(TypedDict):
345
92
  input: InputUnionTypedDict
346
93
  model: str
347
94
  encoding_format: NotRequired[EncodingFormat]
348
95
  dimensions: NotRequired[int]
349
96
  user: NotRequired[str]
350
- provider: NotRequired[CreateEmbeddingsProviderTypedDict]
97
+ provider: NotRequired[components_providerpreferences.ProviderPreferencesTypedDict]
98
+ r"""Provider routing preferences for the request."""
351
99
  input_type: NotRequired[str]
352
100
 
353
101
 
@@ -364,7 +112,8 @@ class CreateEmbeddingsRequest(BaseModel):
364
112
 
365
113
  user: Optional[str] = None
366
114
 
367
- provider: Optional[CreateEmbeddingsProvider] = None
115
+ provider: Optional[components_providerpreferences.ProviderPreferences] = None
116
+ r"""Provider routing preferences for the request."""
368
117
 
369
118
  input_type: Optional[str] = None
370
119
 
@@ -96,6 +96,8 @@ class GetGenerationDataTypedDict(TypedDict):
96
96
  r"""External user identifier"""
97
97
  api_type: Nullable[APIType]
98
98
  r"""Type of API used for the generation"""
99
+ router: Nullable[str]
100
+ r"""Router used for the request (e.g., openrouter/auto)"""
99
101
 
100
102
 
101
103
  class GetGenerationData(BaseModel):
@@ -197,6 +199,9 @@ class GetGenerationData(BaseModel):
197
199
  api_type: Annotated[Nullable[APIType], PlainValidator(validate_open_enum(False))]
198
200
  r"""Type of API used for the generation"""
199
201
 
202
+ router: Nullable[str]
203
+ r"""Router used for the request (e.g., openrouter/auto)"""
204
+
200
205
  @model_serializer(mode="wrap")
201
206
  def serialize_model(self, handler):
202
207
  optional_fields = []
@@ -226,6 +231,7 @@ class GetGenerationData(BaseModel):
226
231
  "native_finish_reason",
227
232
  "external_user",
228
233
  "api_type",
234
+ "router",
229
235
  ]
230
236
  null_default_fields = []
231
237