openrouter 0.0.17__py3-none-any.whl → 0.0.19__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 (71) hide show
  1. openrouter/_version.py +3 -3
  2. openrouter/analytics.py +0 -2
  3. openrouter/api_keys.py +4 -24
  4. openrouter/basesdk.py +0 -6
  5. openrouter/chat.py +14 -154
  6. openrouter/completions.py +0 -2
  7. openrouter/components/__init__.py +75 -276
  8. openrouter/components/chatgenerationparams.py +17 -389
  9. openrouter/components/chatmessagecontentitem.py +1 -1
  10. openrouter/components/chatmessagecontentitemaudio.py +25 -6
  11. openrouter/components/chatmessagecontentitemtext.py +2 -9
  12. openrouter/components/chatmessagecontentitemvideo.py +5 -9
  13. openrouter/components/chatresponsechoice.py +67 -6
  14. openrouter/components/chatstreamingmessagechunk.py +1 -12
  15. openrouter/components/chatstreamingresponsechunk.py +1 -1
  16. openrouter/components/completionchoice.py +5 -18
  17. openrouter/components/completioncreateparams.py +10 -10
  18. openrouter/components/completionresponse.py +0 -3
  19. openrouter/components/message.py +9 -10
  20. openrouter/components/openairesponsesannotation.py +4 -11
  21. openrouter/components/openairesponsesreasoningeffort.py +0 -1
  22. openrouter/components/openresponsesnonstreamingresponse.py +10 -13
  23. openrouter/components/openresponsesrequest.py +120 -194
  24. openrouter/components/openresponsesstreamevent.py +39 -110
  25. openrouter/components/outputmessage.py +4 -10
  26. openrouter/components/parameter.py +0 -1
  27. openrouter/components/providername.py +1 -8
  28. openrouter/components/providersort.py +1 -0
  29. openrouter/components/publicendpoint.py +49 -49
  30. openrouter/components/publicpricing.py +49 -49
  31. openrouter/components/responseformattextconfig.py +7 -9
  32. openrouter/components/responsesoutputitem.py +10 -12
  33. openrouter/components/responsesoutputmessage.py +5 -10
  34. openrouter/credits.py +0 -4
  35. openrouter/embeddings.py +8 -10
  36. openrouter/endpoints.py +0 -4
  37. openrouter/generations.py +0 -2
  38. openrouter/models_.py +0 -6
  39. openrouter/oauth.py +0 -4
  40. openrouter/operations/__init__.py +34 -10
  41. openrouter/operations/createembeddings.py +247 -16
  42. openrouter/operations/getcredits.py +0 -19
  43. openrouter/operations/getparameters.py +71 -5
  44. openrouter/operations/updatekeys.py +2 -2
  45. openrouter/parameters.py +2 -4
  46. openrouter/providers.py +0 -2
  47. openrouter/responses.py +36 -74
  48. openrouter/sdk.py +0 -13
  49. openrouter/sdkconfiguration.py +0 -2
  50. openrouter/utils/forms.py +10 -21
  51. openrouter/utils/queryparams.py +2 -14
  52. openrouter/utils/retries.py +5 -69
  53. {openrouter-0.0.17.dist-info → openrouter-0.0.19.dist-info}/METADATA +1 -1
  54. {openrouter-0.0.17.dist-info → openrouter-0.0.19.dist-info}/RECORD +57 -71
  55. openrouter/components/_schema0.py +0 -93
  56. openrouter/components/_schema3.py +0 -228
  57. openrouter/components/chatcompletionfinishreason.py +0 -17
  58. openrouter/components/chatmessagecontentitemcachecontrol.py +0 -32
  59. openrouter/components/chatstreamingchoice.py +0 -72
  60. openrouter/components/pdfparserengine.py +0 -16
  61. openrouter/components/pdfparseroptions.py +0 -25
  62. openrouter/components/providerpreferences.py +0 -375
  63. openrouter/components/providersortconfig.py +0 -71
  64. openrouter/components/providersortunion.py +0 -23
  65. openrouter/components/websearchengine.py +0 -15
  66. openrouter/models/__init__.py +0 -3
  67. openrouter/models/internal/__init__.py +0 -54
  68. openrouter/models/internal/globals.py +0 -41
  69. {openrouter-0.0.17.dist-info → openrouter-0.0.19.dist-info}/WHEEL +0 -0
  70. {openrouter-0.0.17.dist-info → openrouter-0.0.19.dist-info}/licenses/LICENSE +0 -0
  71. {openrouter-0.0.17.dist-info → openrouter-0.0.19.dist-info}/top_level.txt +0 -0
openrouter/embeddings.py CHANGED
@@ -28,7 +28,8 @@ class Embeddings(BaseSDK):
28
28
  user: Optional[str] = None,
29
29
  provider: Optional[
30
30
  Union[
31
- components.ProviderPreferences, components.ProviderPreferencesTypedDict
31
+ operations.CreateEmbeddingsProvider,
32
+ operations.CreateEmbeddingsProviderTypedDict,
32
33
  ]
33
34
  ] = None,
34
35
  input_type: Optional[str] = None,
@@ -47,7 +48,7 @@ class Embeddings(BaseSDK):
47
48
  :param encoding_format:
48
49
  :param dimensions:
49
50
  :param user:
50
- :param provider: Provider routing preferences for the request.
51
+ :param provider:
51
52
  :param input_type:
52
53
  :param retries: Override the default retry configuration for this method
53
54
  :param server_url: Override the default server URL for this method
@@ -72,7 +73,7 @@ class Embeddings(BaseSDK):
72
73
  dimensions=dimensions,
73
74
  user=user,
74
75
  provider=utils.get_pydantic_model(
75
- provider, Optional[components.ProviderPreferences]
76
+ provider, Optional[operations.CreateEmbeddingsProvider]
76
77
  ),
77
78
  input_type=input_type,
78
79
  )
@@ -95,7 +96,6 @@ class Embeddings(BaseSDK):
95
96
  get_serialized_body=lambda: utils.serialize_request_body(
96
97
  request, False, False, "json", operations.CreateEmbeddingsRequest
97
98
  ),
98
- allow_empty_value=None,
99
99
  timeout_ms=timeout_ms,
100
100
  )
101
101
 
@@ -215,7 +215,8 @@ class Embeddings(BaseSDK):
215
215
  user: Optional[str] = None,
216
216
  provider: Optional[
217
217
  Union[
218
- components.ProviderPreferences, components.ProviderPreferencesTypedDict
218
+ operations.CreateEmbeddingsProvider,
219
+ operations.CreateEmbeddingsProviderTypedDict,
219
220
  ]
220
221
  ] = None,
221
222
  input_type: Optional[str] = None,
@@ -234,7 +235,7 @@ class Embeddings(BaseSDK):
234
235
  :param encoding_format:
235
236
  :param dimensions:
236
237
  :param user:
237
- :param provider: Provider routing preferences for the request.
238
+ :param provider:
238
239
  :param input_type:
239
240
  :param retries: Override the default retry configuration for this method
240
241
  :param server_url: Override the default server URL for this method
@@ -259,7 +260,7 @@ class Embeddings(BaseSDK):
259
260
  dimensions=dimensions,
260
261
  user=user,
261
262
  provider=utils.get_pydantic_model(
262
- provider, Optional[components.ProviderPreferences]
263
+ provider, Optional[operations.CreateEmbeddingsProvider]
263
264
  ),
264
265
  input_type=input_type,
265
266
  )
@@ -282,7 +283,6 @@ class Embeddings(BaseSDK):
282
283
  get_serialized_body=lambda: utils.serialize_request_body(
283
284
  request, False, False, "json", operations.CreateEmbeddingsRequest
284
285
  ),
285
- allow_empty_value=None,
286
286
  timeout_ms=timeout_ms,
287
287
  )
288
288
 
@@ -431,7 +431,6 @@ class Embeddings(BaseSDK):
431
431
  accept_header_value="application/json",
432
432
  http_headers=http_headers,
433
433
  security=self.sdk_configuration.security,
434
- allow_empty_value=None,
435
434
  timeout_ms=timeout_ms,
436
435
  )
437
436
 
@@ -523,7 +522,6 @@ class Embeddings(BaseSDK):
523
522
  accept_header_value="application/json",
524
523
  http_headers=http_headers,
525
524
  security=self.sdk_configuration.security,
526
- allow_empty_value=None,
527
525
  timeout_ms=timeout_ms,
528
526
  )
529
527
 
openrouter/endpoints.py CHANGED
@@ -59,7 +59,6 @@ class Endpoints(BaseSDK):
59
59
  accept_header_value="application/json",
60
60
  http_headers=http_headers,
61
61
  security=self.sdk_configuration.security,
62
- allow_empty_value=None,
63
62
  timeout_ms=timeout_ms,
64
63
  )
65
64
 
@@ -159,7 +158,6 @@ class Endpoints(BaseSDK):
159
158
  accept_header_value="application/json",
160
159
  http_headers=http_headers,
161
160
  security=self.sdk_configuration.security,
162
- allow_empty_value=None,
163
161
  timeout_ms=timeout_ms,
164
162
  )
165
163
 
@@ -249,7 +247,6 @@ class Endpoints(BaseSDK):
249
247
  accept_header_value="application/json",
250
248
  http_headers=http_headers,
251
249
  security=self.sdk_configuration.security,
252
- allow_empty_value=None,
253
250
  timeout_ms=timeout_ms,
254
251
  )
255
252
 
@@ -336,7 +333,6 @@ class Endpoints(BaseSDK):
336
333
  accept_header_value="application/json",
337
334
  http_headers=http_headers,
338
335
  security=self.sdk_configuration.security,
339
- allow_empty_value=None,
340
336
  timeout_ms=timeout_ms,
341
337
  )
342
338
 
openrouter/generations.py CHANGED
@@ -56,7 +56,6 @@ class Generations(BaseSDK):
56
56
  accept_header_value="application/json",
57
57
  http_headers=http_headers,
58
58
  security=self.sdk_configuration.security,
59
- allow_empty_value=None,
60
59
  timeout_ms=timeout_ms,
61
60
  )
62
61
 
@@ -194,7 +193,6 @@ class Generations(BaseSDK):
194
193
  accept_header_value="application/json",
195
194
  http_headers=http_headers,
196
195
  security=self.sdk_configuration.security,
197
- allow_empty_value=None,
198
196
  timeout_ms=timeout_ms,
199
197
  )
200
198
 
openrouter/models_.py CHANGED
@@ -49,7 +49,6 @@ class Models(BaseSDK):
49
49
  accept_header_value="application/json",
50
50
  http_headers=http_headers,
51
51
  security=self.sdk_configuration.security,
52
- allow_empty_value=None,
53
52
  timeout_ms=timeout_ms,
54
53
  )
55
54
 
@@ -134,7 +133,6 @@ class Models(BaseSDK):
134
133
  accept_header_value="application/json",
135
134
  http_headers=http_headers,
136
135
  security=self.sdk_configuration.security,
137
- allow_empty_value=None,
138
136
  timeout_ms=timeout_ms,
139
137
  )
140
138
 
@@ -229,7 +227,6 @@ class Models(BaseSDK):
229
227
  accept_header_value="application/json",
230
228
  http_headers=http_headers,
231
229
  security=self.sdk_configuration.security,
232
- allow_empty_value=None,
233
230
  timeout_ms=timeout_ms,
234
231
  )
235
232
 
@@ -329,7 +326,6 @@ class Models(BaseSDK):
329
326
  accept_header_value="application/json",
330
327
  http_headers=http_headers,
331
328
  security=self.sdk_configuration.security,
332
- allow_empty_value=None,
333
329
  timeout_ms=timeout_ms,
334
330
  )
335
331
 
@@ -426,7 +422,6 @@ class Models(BaseSDK):
426
422
  security=utils.get_pydantic_model(
427
423
  security, operations.ListModelsUserSecurity
428
424
  ),
429
- allow_empty_value=None,
430
425
  timeout_ms=timeout_ms,
431
426
  )
432
427
 
@@ -521,7 +516,6 @@ class Models(BaseSDK):
521
516
  security=utils.get_pydantic_model(
522
517
  security, operations.ListModelsUserSecurity
523
518
  ),
524
- allow_empty_value=None,
525
519
  timeout_ms=timeout_ms,
526
520
  )
527
521
 
openrouter/oauth.py CHANGED
@@ -74,7 +74,6 @@ class OAuth(BaseSDK):
74
74
  "json",
75
75
  operations.ExchangeAuthCodeForAPIKeyRequest,
76
76
  ),
77
- allow_empty_value=None,
78
77
  timeout_ms=timeout_ms,
79
78
  )
80
79
 
@@ -195,7 +194,6 @@ class OAuth(BaseSDK):
195
194
  "json",
196
195
  operations.ExchangeAuthCodeForAPIKeyRequest,
197
196
  ),
198
- allow_empty_value=None,
199
197
  timeout_ms=timeout_ms,
200
198
  )
201
199
 
@@ -318,7 +316,6 @@ class OAuth(BaseSDK):
318
316
  get_serialized_body=lambda: utils.serialize_request_body(
319
317
  request, False, False, "json", operations.CreateAuthKeysCodeRequest
320
318
  ),
321
- allow_empty_value=None,
322
319
  timeout_ms=timeout_ms,
323
320
  )
324
321
 
@@ -441,7 +438,6 @@ class OAuth(BaseSDK):
441
438
  get_serialized_body=lambda: utils.serialize_request_body(
442
439
  request, False, False, "json", operations.CreateAuthKeysCodeRequest
443
440
  ),
444
- allow_empty_value=None,
445
441
  timeout_ms=timeout_ms,
446
442
  )
447
443
 
@@ -40,6 +40,8 @@ if TYPE_CHECKING:
40
40
  ContentTypedDict,
41
41
  CreateEmbeddingsData,
42
42
  CreateEmbeddingsDataTypedDict,
43
+ CreateEmbeddingsProvider,
44
+ CreateEmbeddingsProviderTypedDict,
43
45
  CreateEmbeddingsRequest,
44
46
  CreateEmbeddingsRequestTypedDict,
45
47
  CreateEmbeddingsResponse,
@@ -49,14 +51,22 @@ if TYPE_CHECKING:
49
51
  Embedding,
50
52
  EmbeddingTypedDict,
51
53
  EncodingFormat,
54
+ Ignore,
55
+ IgnoreTypedDict,
52
56
  ImageURL,
53
57
  ImageURLTypedDict,
54
58
  Input,
55
59
  InputTypedDict,
56
60
  InputUnion,
57
61
  InputUnionTypedDict,
62
+ MaxPrice,
63
+ MaxPriceTypedDict,
58
64
  Object,
59
65
  ObjectEmbedding,
66
+ Only,
67
+ OnlyTypedDict,
68
+ Order,
69
+ OrderTypedDict,
60
70
  TypeImageURL,
61
71
  TypeText,
62
72
  Usage,
@@ -90,12 +100,7 @@ if TYPE_CHECKING:
90
100
  ExchangeAuthCodeForAPIKeyResponse,
91
101
  ExchangeAuthCodeForAPIKeyResponseTypedDict,
92
102
  )
93
- from .getcredits import (
94
- GetCreditsData,
95
- GetCreditsDataTypedDict,
96
- GetCreditsResponse,
97
- GetCreditsResponseTypedDict,
98
- )
103
+ from .getcredits import GetCreditsResponse, GetCreditsResponseTypedDict
99
104
  from .getcurrentkey import (
100
105
  GetCurrentKeyData,
101
106
  GetCurrentKeyDataTypedDict,
@@ -125,6 +130,7 @@ if TYPE_CHECKING:
125
130
  from .getparameters import (
126
131
  GetParametersData,
127
132
  GetParametersDataTypedDict,
133
+ GetParametersProvider,
128
134
  GetParametersRequest,
129
135
  GetParametersRequestTypedDict,
130
136
  GetParametersResponse,
@@ -205,6 +211,8 @@ __all__ = [
205
211
  "CreateCoinbaseChargeSecurityTypedDict",
206
212
  "CreateEmbeddingsData",
207
213
  "CreateEmbeddingsDataTypedDict",
214
+ "CreateEmbeddingsProvider",
215
+ "CreateEmbeddingsProviderTypedDict",
208
216
  "CreateEmbeddingsRequest",
209
217
  "CreateEmbeddingsRequestTypedDict",
210
218
  "CreateEmbeddingsResponse",
@@ -234,8 +242,6 @@ __all__ = [
234
242
  "ExchangeAuthCodeForAPIKeyRequestTypedDict",
235
243
  "ExchangeAuthCodeForAPIKeyResponse",
236
244
  "ExchangeAuthCodeForAPIKeyResponseTypedDict",
237
- "GetCreditsData",
238
- "GetCreditsDataTypedDict",
239
245
  "GetCreditsResponse",
240
246
  "GetCreditsResponseTypedDict",
241
247
  "GetCurrentKeyData",
@@ -258,6 +264,7 @@ __all__ = [
258
264
  "GetModelsRequestTypedDict",
259
265
  "GetParametersData",
260
266
  "GetParametersDataTypedDict",
267
+ "GetParametersProvider",
261
268
  "GetParametersRequest",
262
269
  "GetParametersRequestTypedDict",
263
270
  "GetParametersResponse",
@@ -268,6 +275,8 @@ __all__ = [
268
275
  "GetUserActivityRequestTypedDict",
269
276
  "GetUserActivityResponse",
270
277
  "GetUserActivityResponseTypedDict",
278
+ "Ignore",
279
+ "IgnoreTypedDict",
271
280
  "ImageURL",
272
281
  "ImageURLTypedDict",
273
282
  "Input",
@@ -292,10 +301,16 @@ __all__ = [
292
301
  "ListRequestTypedDict",
293
302
  "ListResponse",
294
303
  "ListResponseTypedDict",
304
+ "MaxPrice",
305
+ "MaxPriceTypedDict",
295
306
  "Metadata",
296
307
  "MetadataTypedDict",
297
308
  "Object",
298
309
  "ObjectEmbedding",
310
+ "Only",
311
+ "OnlyTypedDict",
312
+ "Order",
313
+ "OrderTypedDict",
299
314
  "RateLimit",
300
315
  "RateLimitTypedDict",
301
316
  "SendChatCompletionRequestResponse",
@@ -350,6 +365,8 @@ _dynamic_imports: dict[str, str] = {
350
365
  "ContentTypedDict": ".createembeddings",
351
366
  "CreateEmbeddingsData": ".createembeddings",
352
367
  "CreateEmbeddingsDataTypedDict": ".createembeddings",
368
+ "CreateEmbeddingsProvider": ".createembeddings",
369
+ "CreateEmbeddingsProviderTypedDict": ".createembeddings",
353
370
  "CreateEmbeddingsRequest": ".createembeddings",
354
371
  "CreateEmbeddingsRequestTypedDict": ".createembeddings",
355
372
  "CreateEmbeddingsResponse": ".createembeddings",
@@ -359,14 +376,22 @@ _dynamic_imports: dict[str, str] = {
359
376
  "Embedding": ".createembeddings",
360
377
  "EmbeddingTypedDict": ".createembeddings",
361
378
  "EncodingFormat": ".createembeddings",
379
+ "Ignore": ".createembeddings",
380
+ "IgnoreTypedDict": ".createembeddings",
362
381
  "ImageURL": ".createembeddings",
363
382
  "ImageURLTypedDict": ".createembeddings",
364
383
  "Input": ".createembeddings",
365
384
  "InputTypedDict": ".createembeddings",
366
385
  "InputUnion": ".createembeddings",
367
386
  "InputUnionTypedDict": ".createembeddings",
387
+ "MaxPrice": ".createembeddings",
388
+ "MaxPriceTypedDict": ".createembeddings",
368
389
  "Object": ".createembeddings",
369
390
  "ObjectEmbedding": ".createembeddings",
391
+ "Only": ".createembeddings",
392
+ "OnlyTypedDict": ".createembeddings",
393
+ "Order": ".createembeddings",
394
+ "OrderTypedDict": ".createembeddings",
370
395
  "TypeImageURL": ".createembeddings",
371
396
  "TypeText": ".createembeddings",
372
397
  "Usage": ".createembeddings",
@@ -391,8 +416,6 @@ _dynamic_imports: dict[str, str] = {
391
416
  "ExchangeAuthCodeForAPIKeyRequestTypedDict": ".exchangeauthcodeforapikey",
392
417
  "ExchangeAuthCodeForAPIKeyResponse": ".exchangeauthcodeforapikey",
393
418
  "ExchangeAuthCodeForAPIKeyResponseTypedDict": ".exchangeauthcodeforapikey",
394
- "GetCreditsData": ".getcredits",
395
- "GetCreditsDataTypedDict": ".getcredits",
396
419
  "GetCreditsResponse": ".getcredits",
397
420
  "GetCreditsResponseTypedDict": ".getcredits",
398
421
  "GetCurrentKeyData": ".getcurrentkey",
@@ -418,6 +441,7 @@ _dynamic_imports: dict[str, str] = {
418
441
  "GetModelsRequestTypedDict": ".getmodels",
419
442
  "GetParametersData": ".getparameters",
420
443
  "GetParametersDataTypedDict": ".getparameters",
444
+ "GetParametersProvider": ".getparameters",
421
445
  "GetParametersRequest": ".getparameters",
422
446
  "GetParametersRequestTypedDict": ".getparameters",
423
447
  "GetParametersResponse": ".getparameters",
@@ -1,12 +1,24 @@
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 providerpreferences as components_providerpreferences
5
- from openrouter.types import BaseModel, UnrecognizedStr
6
- from openrouter.utils import get_discriminator, validate_open_enum
7
- from pydantic import Discriminator, Tag
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
+ )
18
+ from openrouter.utils import validate_open_enum
19
+ from pydantic import model_serializer
8
20
  from pydantic.functional_validators import PlainValidator
9
- from typing import List, Literal, Optional, Union
21
+ from typing import Any, List, Literal, Optional, Union
10
22
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
11
23
 
12
24
 
@@ -51,13 +63,7 @@ ContentTypedDict = TypeAliasType(
51
63
  )
52
64
 
53
65
 
54
- Content = Annotated[
55
- Union[
56
- Annotated[ContentText, Tag("text")],
57
- Annotated[ContentImageURL, Tag("image_url")],
58
- ],
59
- Discriminator(lambda m: get_discriminator(m, "type", "type")),
60
- ]
66
+ Content = TypeAliasType("Content", Union[ContentText, ContentImageURL])
61
67
 
62
68
 
63
69
  class InputTypedDict(TypedDict):
@@ -88,14 +94,240 @@ EncodingFormat = Union[
88
94
  ]
89
95
 
90
96
 
97
+ OrderTypedDict = TypeAliasType(
98
+ "OrderTypedDict", Union[components_providername.ProviderName, str]
99
+ )
100
+
101
+
102
+ Order = TypeAliasType(
103
+ "Order",
104
+ Union[
105
+ Annotated[
106
+ components_providername.ProviderName,
107
+ PlainValidator(validate_open_enum(False)),
108
+ ],
109
+ str,
110
+ ],
111
+ )
112
+
113
+
114
+ OnlyTypedDict = TypeAliasType(
115
+ "OnlyTypedDict", Union[components_providername.ProviderName, str]
116
+ )
117
+
118
+
119
+ Only = TypeAliasType(
120
+ "Only",
121
+ Union[
122
+ Annotated[
123
+ components_providername.ProviderName,
124
+ PlainValidator(validate_open_enum(False)),
125
+ ],
126
+ str,
127
+ ],
128
+ )
129
+
130
+
131
+ IgnoreTypedDict = TypeAliasType(
132
+ "IgnoreTypedDict", Union[components_providername.ProviderName, str]
133
+ )
134
+
135
+
136
+ Ignore = TypeAliasType(
137
+ "Ignore",
138
+ Union[
139
+ Annotated[
140
+ components_providername.ProviderName,
141
+ PlainValidator(validate_open_enum(False)),
142
+ ],
143
+ str,
144
+ ],
145
+ )
146
+
147
+
148
+ class MaxPriceTypedDict(TypedDict):
149
+ r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
150
+
151
+ prompt: NotRequired[Any]
152
+ r"""A value in string or number format that is a large number"""
153
+ completion: NotRequired[Any]
154
+ r"""A value in string or number format that is a large number"""
155
+ image: NotRequired[Any]
156
+ r"""A value in string or number format that is a large number"""
157
+ audio: NotRequired[Any]
158
+ r"""A value in string or number format that is a large number"""
159
+ request: NotRequired[Any]
160
+ r"""A value in string or number format that is a large number"""
161
+
162
+
163
+ class MaxPrice(BaseModel):
164
+ r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
165
+
166
+ prompt: Optional[Any] = None
167
+ r"""A value in string or number format that is a large number"""
168
+
169
+ completion: Optional[Any] = None
170
+ r"""A value in string or number format that is a large number"""
171
+
172
+ image: Optional[Any] = None
173
+ r"""A value in string or number format that is a large number"""
174
+
175
+ audio: Optional[Any] = None
176
+ r"""A value in string or number format that is a large number"""
177
+
178
+ request: Optional[Any] = None
179
+ r"""A value in string or number format that is a large number"""
180
+
181
+
182
+ class CreateEmbeddingsProviderTypedDict(TypedDict):
183
+ allow_fallbacks: NotRequired[Nullable[bool]]
184
+ r"""Whether to allow backup providers to serve requests
185
+ - true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
186
+ - false: use only the primary/custom provider, and return the upstream error if it's unavailable.
187
+
188
+ """
189
+ require_parameters: NotRequired[Nullable[bool]]
190
+ 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."""
191
+ data_collection: NotRequired[Nullable[components_datacollection.DataCollection]]
192
+ r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
193
+ - allow: (default) allow providers which store user data non-transiently and may train on it
194
+
195
+ - deny: use only providers which do not collect user data.
196
+ """
197
+ zdr: NotRequired[Nullable[bool]]
198
+ r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
199
+ enforce_distillable_text: NotRequired[Nullable[bool]]
200
+ 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."""
201
+ order: NotRequired[Nullable[List[OrderTypedDict]]]
202
+ 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."""
203
+ only: NotRequired[Nullable[List[OnlyTypedDict]]]
204
+ r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
205
+ ignore: NotRequired[Nullable[List[IgnoreTypedDict]]]
206
+ r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
207
+ quantizations: NotRequired[Nullable[List[components_quantization.Quantization]]]
208
+ r"""A list of quantization levels to filter the provider by."""
209
+ sort: NotRequired[Nullable[components_providersort.ProviderSort]]
210
+ r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
211
+ max_price: NotRequired[MaxPriceTypedDict]
212
+ r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
213
+
214
+
215
+ class CreateEmbeddingsProvider(BaseModel):
216
+ allow_fallbacks: OptionalNullable[bool] = UNSET
217
+ r"""Whether to allow backup providers to serve requests
218
+ - true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
219
+ - false: use only the primary/custom provider, and return the upstream error if it's unavailable.
220
+
221
+ """
222
+
223
+ require_parameters: OptionalNullable[bool] = UNSET
224
+ 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."""
225
+
226
+ data_collection: Annotated[
227
+ OptionalNullable[components_datacollection.DataCollection],
228
+ PlainValidator(validate_open_enum(False)),
229
+ ] = UNSET
230
+ r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
231
+ - allow: (default) allow providers which store user data non-transiently and may train on it
232
+
233
+ - deny: use only providers which do not collect user data.
234
+ """
235
+
236
+ zdr: OptionalNullable[bool] = UNSET
237
+ r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
238
+
239
+ enforce_distillable_text: OptionalNullable[bool] = UNSET
240
+ 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."""
241
+
242
+ order: OptionalNullable[List[Order]] = UNSET
243
+ 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."""
244
+
245
+ only: OptionalNullable[List[Only]] = UNSET
246
+ r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
247
+
248
+ ignore: OptionalNullable[List[Ignore]] = UNSET
249
+ r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
250
+
251
+ quantizations: OptionalNullable[
252
+ List[
253
+ Annotated[
254
+ components_quantization.Quantization,
255
+ PlainValidator(validate_open_enum(False)),
256
+ ]
257
+ ]
258
+ ] = UNSET
259
+ r"""A list of quantization levels to filter the provider by."""
260
+
261
+ sort: Annotated[
262
+ OptionalNullable[components_providersort.ProviderSort],
263
+ PlainValidator(validate_open_enum(False)),
264
+ ] = UNSET
265
+ r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
266
+
267
+ max_price: Optional[MaxPrice] = None
268
+ r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
269
+
270
+ @model_serializer(mode="wrap")
271
+ def serialize_model(self, handler):
272
+ optional_fields = [
273
+ "allow_fallbacks",
274
+ "require_parameters",
275
+ "data_collection",
276
+ "zdr",
277
+ "enforce_distillable_text",
278
+ "order",
279
+ "only",
280
+ "ignore",
281
+ "quantizations",
282
+ "sort",
283
+ "max_price",
284
+ ]
285
+ nullable_fields = [
286
+ "allow_fallbacks",
287
+ "require_parameters",
288
+ "data_collection",
289
+ "zdr",
290
+ "enforce_distillable_text",
291
+ "order",
292
+ "only",
293
+ "ignore",
294
+ "quantizations",
295
+ "sort",
296
+ ]
297
+ null_default_fields = []
298
+
299
+ serialized = handler(self)
300
+
301
+ m = {}
302
+
303
+ for n, f in type(self).model_fields.items():
304
+ k = f.alias or n
305
+ val = serialized.get(k)
306
+ serialized.pop(k, None)
307
+
308
+ optional_nullable = k in optional_fields and k in nullable_fields
309
+ is_set = (
310
+ self.__pydantic_fields_set__.intersection({n})
311
+ or k in null_default_fields
312
+ ) # pylint: disable=no-member
313
+
314
+ if val is not None and val != UNSET_SENTINEL:
315
+ m[k] = val
316
+ elif val != UNSET_SENTINEL and (
317
+ not k in optional_fields or (optional_nullable and is_set)
318
+ ):
319
+ m[k] = val
320
+
321
+ return m
322
+
323
+
91
324
  class CreateEmbeddingsRequestTypedDict(TypedDict):
92
325
  input: InputUnionTypedDict
93
326
  model: str
94
327
  encoding_format: NotRequired[EncodingFormat]
95
328
  dimensions: NotRequired[int]
96
329
  user: NotRequired[str]
97
- provider: NotRequired[components_providerpreferences.ProviderPreferencesTypedDict]
98
- r"""Provider routing preferences for the request."""
330
+ provider: NotRequired[CreateEmbeddingsProviderTypedDict]
99
331
  input_type: NotRequired[str]
100
332
 
101
333
 
@@ -112,8 +344,7 @@ class CreateEmbeddingsRequest(BaseModel):
112
344
 
113
345
  user: Optional[str] = None
114
346
 
115
- provider: Optional[components_providerpreferences.ProviderPreferences] = None
116
- r"""Provider routing preferences for the request."""
347
+ provider: Optional[CreateEmbeddingsProvider] = None
117
348
 
118
349
  input_type: Optional[str] = None
119
350
 
@@ -5,28 +5,9 @@ from openrouter.types import BaseModel
5
5
  from typing_extensions import TypedDict
6
6
 
7
7
 
8
- class GetCreditsDataTypedDict(TypedDict):
9
- total_credits: float
10
- r"""Total credits purchased"""
11
- total_usage: float
12
- r"""Total credits used"""
13
-
14
-
15
- class GetCreditsData(BaseModel):
16
- total_credits: float
17
- r"""Total credits purchased"""
18
-
19
- total_usage: float
20
- r"""Total credits used"""
21
-
22
-
23
8
  class GetCreditsResponseTypedDict(TypedDict):
24
9
  r"""Total credits purchased and used"""
25
10
 
26
- data: GetCreditsDataTypedDict
27
-
28
11
 
29
12
  class GetCreditsResponse(BaseModel):
30
13
  r"""Total credits purchased and used"""
31
-
32
- data: GetCreditsData