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
@@ -1,10 +1,8 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from ._schema0 import Schema0, Schema0TypedDict
5
4
  from .chatstreamoptions import ChatStreamOptions, ChatStreamOptionsTypedDict
6
5
  from .message import Message, MessageTypedDict
7
- from .providersortunion import ProviderSortUnion, ProviderSortUnionTypedDict
8
6
  from .reasoningsummaryverbosity import ReasoningSummaryVerbosity
9
7
  from .responseformatjsonschema import (
10
8
  ResponseFormatJSONSchema,
@@ -23,353 +21,21 @@ from openrouter.types import (
23
21
  UNSET_SENTINEL,
24
22
  UnrecognizedStr,
25
23
  )
26
- from openrouter.utils import get_discriminator, validate_const, validate_open_enum
24
+ from openrouter.utils import validate_const, validate_open_enum
27
25
  import pydantic
28
- from pydantic import Discriminator, Tag, model_serializer
26
+ from pydantic import model_serializer
29
27
  from pydantic.functional_validators import AfterValidator, PlainValidator
30
28
  from typing import Any, Dict, List, Literal, Optional, Union
31
29
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
32
30
 
33
31
 
34
- ChatGenerationParamsDataCollection = Union[
35
- Literal[
36
- "deny",
37
- "allow",
38
- ],
39
- UnrecognizedStr,
40
- ]
41
-
42
-
43
- Quantizations = Union[
44
- Literal[
45
- "int4",
46
- "int8",
47
- "fp4",
48
- "fp6",
49
- "fp8",
50
- "fp16",
51
- "bf16",
52
- "fp32",
53
- "unknown",
54
- ],
55
- UnrecognizedStr,
56
- ]
57
-
58
-
59
- class ChatGenerationParamsMaxPriceTypedDict(TypedDict):
60
- r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
61
-
62
- prompt: NotRequired[Any]
63
- completion: NotRequired[Any]
64
- image: NotRequired[Any]
65
- audio: NotRequired[Any]
66
- request: NotRequired[Any]
67
-
68
-
69
- class ChatGenerationParamsMaxPrice(BaseModel):
70
- r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
71
-
72
- prompt: Optional[Any] = None
73
-
74
- completion: Optional[Any] = None
75
-
76
- image: Optional[Any] = None
77
-
78
- audio: Optional[Any] = None
79
-
80
- request: Optional[Any] = None
81
-
82
-
83
- class ChatGenerationParamsProviderTypedDict(TypedDict):
84
- allow_fallbacks: NotRequired[Nullable[bool]]
85
- r"""Whether to allow backup providers to serve requests
86
- - true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
87
- - false: use only the primary/custom provider, and return the upstream error if it's unavailable.
88
-
89
- """
90
- require_parameters: NotRequired[Nullable[bool]]
91
- 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."""
92
- data_collection: NotRequired[Nullable[ChatGenerationParamsDataCollection]]
93
- r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
94
- - allow: (default) allow providers which store user data non-transiently and may train on it
95
-
96
- - deny: use only providers which do not collect user data.
97
- """
98
- zdr: NotRequired[Nullable[bool]]
99
- enforce_distillable_text: NotRequired[Nullable[bool]]
100
- order: NotRequired[Nullable[List[Schema0TypedDict]]]
101
- 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."""
102
- only: NotRequired[Nullable[List[Schema0TypedDict]]]
103
- r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
104
- ignore: NotRequired[Nullable[List[Schema0TypedDict]]]
105
- r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
106
- quantizations: NotRequired[Nullable[List[Quantizations]]]
107
- r"""A list of quantization levels to filter the provider by."""
108
- sort: NotRequired[Nullable[ProviderSortUnionTypedDict]]
109
- r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
110
- max_price: NotRequired[ChatGenerationParamsMaxPriceTypedDict]
111
- r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
112
- preferred_min_throughput: NotRequired[Nullable[float]]
113
- preferred_max_latency: NotRequired[Nullable[float]]
114
- min_throughput: NotRequired[Nullable[float]]
115
- max_latency: NotRequired[Nullable[float]]
116
-
117
-
118
- class ChatGenerationParamsProvider(BaseModel):
119
- allow_fallbacks: OptionalNullable[bool] = UNSET
120
- r"""Whether to allow backup providers to serve requests
121
- - true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
122
- - false: use only the primary/custom provider, and return the upstream error if it's unavailable.
123
-
124
- """
125
-
126
- require_parameters: OptionalNullable[bool] = UNSET
127
- 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."""
128
-
129
- data_collection: Annotated[
130
- OptionalNullable[ChatGenerationParamsDataCollection],
131
- PlainValidator(validate_open_enum(False)),
132
- ] = UNSET
133
- r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
134
- - allow: (default) allow providers which store user data non-transiently and may train on it
135
-
136
- - deny: use only providers which do not collect user data.
137
- """
138
-
139
- zdr: OptionalNullable[bool] = UNSET
140
-
141
- enforce_distillable_text: OptionalNullable[bool] = UNSET
142
-
143
- order: OptionalNullable[List[Schema0]] = UNSET
144
- 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."""
145
-
146
- only: OptionalNullable[List[Schema0]] = UNSET
147
- r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
148
-
149
- ignore: OptionalNullable[List[Schema0]] = UNSET
150
- r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
151
-
152
- quantizations: OptionalNullable[
153
- List[Annotated[Quantizations, PlainValidator(validate_open_enum(False))]]
154
- ] = UNSET
155
- r"""A list of quantization levels to filter the provider by."""
156
-
157
- sort: OptionalNullable[ProviderSortUnion] = UNSET
158
- r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
159
-
160
- max_price: Optional[ChatGenerationParamsMaxPrice] = None
161
- r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
162
-
163
- preferred_min_throughput: OptionalNullable[float] = UNSET
164
-
165
- preferred_max_latency: OptionalNullable[float] = UNSET
166
-
167
- min_throughput: OptionalNullable[float] = UNSET
168
-
169
- max_latency: OptionalNullable[float] = UNSET
170
-
171
- @model_serializer(mode="wrap")
172
- def serialize_model(self, handler):
173
- optional_fields = [
174
- "allow_fallbacks",
175
- "require_parameters",
176
- "data_collection",
177
- "zdr",
178
- "enforce_distillable_text",
179
- "order",
180
- "only",
181
- "ignore",
182
- "quantizations",
183
- "sort",
184
- "max_price",
185
- "preferred_min_throughput",
186
- "preferred_max_latency",
187
- "min_throughput",
188
- "max_latency",
189
- ]
190
- nullable_fields = [
191
- "allow_fallbacks",
192
- "require_parameters",
193
- "data_collection",
194
- "zdr",
195
- "enforce_distillable_text",
196
- "order",
197
- "only",
198
- "ignore",
199
- "quantizations",
200
- "sort",
201
- "preferred_min_throughput",
202
- "preferred_max_latency",
203
- "min_throughput",
204
- "max_latency",
205
- ]
206
- null_default_fields = []
207
-
208
- serialized = handler(self)
209
-
210
- m = {}
211
-
212
- for n, f in type(self).model_fields.items():
213
- k = f.alias or n
214
- val = serialized.get(k)
215
- serialized.pop(k, None)
216
-
217
- optional_nullable = k in optional_fields and k in nullable_fields
218
- is_set = (
219
- self.__pydantic_fields_set__.intersection({n})
220
- or k in null_default_fields
221
- ) # pylint: disable=no-member
222
-
223
- if val is not None and val != UNSET_SENTINEL:
224
- m[k] = val
225
- elif val != UNSET_SENTINEL and (
226
- not k in optional_fields or (optional_nullable and is_set)
227
- ):
228
- m[k] = val
229
-
230
- return m
231
-
232
-
233
- class ChatGenerationParamsPluginResponseHealingTypedDict(TypedDict):
234
- id: Literal["response-healing"]
235
- enabled: NotRequired[bool]
236
-
237
-
238
- class ChatGenerationParamsPluginResponseHealing(BaseModel):
239
- ID: Annotated[
240
- Annotated[
241
- Literal["response-healing"],
242
- AfterValidator(validate_const("response-healing")),
243
- ],
244
- pydantic.Field(alias="id"),
245
- ] = "response-healing"
246
-
247
- enabled: Optional[bool] = None
248
-
249
-
250
- PdfEngine = Union[
251
- Literal[
252
- "mistral-ocr",
253
- "pdf-text",
254
- "native",
255
- ],
256
- UnrecognizedStr,
257
- ]
258
-
259
-
260
- class PdfTypedDict(TypedDict):
261
- engine: NotRequired[PdfEngine]
262
-
263
-
264
- class Pdf(BaseModel):
265
- engine: Annotated[
266
- Optional[PdfEngine], PlainValidator(validate_open_enum(False))
267
- ] = None
268
-
269
-
270
- class ChatGenerationParamsPluginFileParserTypedDict(TypedDict):
271
- id: Literal["file-parser"]
272
- enabled: NotRequired[bool]
273
- pdf: NotRequired[PdfTypedDict]
274
-
275
-
276
- class ChatGenerationParamsPluginFileParser(BaseModel):
277
- ID: Annotated[
278
- Annotated[
279
- Literal["file-parser"], AfterValidator(validate_const("file-parser"))
280
- ],
281
- pydantic.Field(alias="id"),
282
- ] = "file-parser"
283
-
284
- enabled: Optional[bool] = None
285
-
286
- pdf: Optional[Pdf] = None
287
-
288
-
289
- Engine = Union[
290
- Literal[
291
- "native",
292
- "exa",
293
- ],
294
- UnrecognizedStr,
295
- ]
296
-
297
-
298
- class ChatGenerationParamsPluginWebTypedDict(TypedDict):
299
- id: Literal["web"]
300
- enabled: NotRequired[bool]
301
- max_results: NotRequired[float]
302
- search_prompt: NotRequired[str]
303
- engine: NotRequired[Engine]
304
-
305
-
306
- class ChatGenerationParamsPluginWeb(BaseModel):
307
- ID: Annotated[
308
- Annotated[Literal["web"], AfterValidator(validate_const("web"))],
309
- pydantic.Field(alias="id"),
310
- ] = "web"
311
-
312
- enabled: Optional[bool] = None
313
-
314
- max_results: Optional[float] = None
315
-
316
- search_prompt: Optional[str] = None
317
-
318
- engine: Annotated[Optional[Engine], PlainValidator(validate_open_enum(False))] = (
319
- None
320
- )
321
-
322
-
323
- class ChatGenerationParamsPluginModerationTypedDict(TypedDict):
324
- id: Literal["moderation"]
325
-
326
-
327
- class ChatGenerationParamsPluginModeration(BaseModel):
328
- ID: Annotated[
329
- Annotated[Literal["moderation"], AfterValidator(validate_const("moderation"))],
330
- pydantic.Field(alias="id"),
331
- ] = "moderation"
332
-
333
-
334
- ChatGenerationParamsPluginUnionTypedDict = TypeAliasType(
335
- "ChatGenerationParamsPluginUnionTypedDict",
336
- Union[
337
- ChatGenerationParamsPluginModerationTypedDict,
338
- ChatGenerationParamsPluginResponseHealingTypedDict,
339
- ChatGenerationParamsPluginFileParserTypedDict,
340
- ChatGenerationParamsPluginWebTypedDict,
341
- ],
342
- )
343
-
344
-
345
- ChatGenerationParamsPluginUnion = Annotated[
346
- Union[
347
- Annotated[ChatGenerationParamsPluginModeration, Tag("moderation")],
348
- Annotated[ChatGenerationParamsPluginWeb, Tag("web")],
349
- Annotated[ChatGenerationParamsPluginFileParser, Tag("file-parser")],
350
- Annotated[ChatGenerationParamsPluginResponseHealing, Tag("response-healing")],
351
- ],
352
- Discriminator(lambda m: get_discriminator(m, "id", "id")),
353
- ]
354
-
355
-
356
- Route = Union[
357
- Literal[
358
- "fallback",
359
- "sort",
360
- ],
361
- UnrecognizedStr,
362
- ]
363
-
364
-
365
32
  Effort = Union[
366
33
  Literal[
367
- "xhigh",
368
- "high",
369
- "medium",
370
- "low",
371
- "minimal",
372
34
  "none",
35
+ "minimal",
36
+ "low",
37
+ "medium",
38
+ "high",
373
39
  ],
374
40
  UnrecognizedStr,
375
41
  ]
@@ -468,16 +134,16 @@ ChatGenerationParamsResponseFormatUnionTypedDict = TypeAliasType(
468
134
  )
469
135
 
470
136
 
471
- ChatGenerationParamsResponseFormatUnion = Annotated[
137
+ ChatGenerationParamsResponseFormatUnion = TypeAliasType(
138
+ "ChatGenerationParamsResponseFormatUnion",
472
139
  Union[
473
- Annotated[ChatGenerationParamsResponseFormatText, Tag("text")],
474
- Annotated[ChatGenerationParamsResponseFormatJSONObject, Tag("json_object")],
475
- Annotated[ResponseFormatJSONSchema, Tag("json_schema")],
476
- Annotated[ResponseFormatTextGrammar, Tag("grammar")],
477
- Annotated[ChatGenerationParamsResponseFormatPython, Tag("python")],
140
+ ChatGenerationParamsResponseFormatText,
141
+ ChatGenerationParamsResponseFormatJSONObject,
142
+ ChatGenerationParamsResponseFormatPython,
143
+ ResponseFormatJSONSchema,
144
+ ResponseFormatTextGrammar,
478
145
  ],
479
- Discriminator(lambda m: get_discriminator(m, "type", "type")),
480
- ]
146
+ )
481
147
 
482
148
 
483
149
  ChatGenerationParamsStopTypedDict = TypeAliasType(
@@ -490,24 +156,8 @@ ChatGenerationParamsStop = TypeAliasType(
490
156
  )
491
157
 
492
158
 
493
- class DebugTypedDict(TypedDict):
494
- echo_upstream_body: NotRequired[bool]
495
-
496
-
497
- class Debug(BaseModel):
498
- echo_upstream_body: Optional[bool] = None
499
-
500
-
501
159
  class ChatGenerationParamsTypedDict(TypedDict):
502
160
  messages: List[MessageTypedDict]
503
- provider: NotRequired[Nullable[ChatGenerationParamsProviderTypedDict]]
504
- r"""When multiple model providers are available, optionally indicate your routing preference."""
505
- plugins: NotRequired[List[ChatGenerationParamsPluginUnionTypedDict]]
506
- r"""Plugins you want to enable for this request, including their settings."""
507
- route: NotRequired[Nullable[Route]]
508
- user: NotRequired[str]
509
- session_id: NotRequired[str]
510
- 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."""
511
161
  model: NotRequired[str]
512
162
  models: NotRequired[List[str]]
513
163
  frequency_penalty: NotRequired[Nullable[float]]
@@ -528,27 +178,12 @@ class ChatGenerationParamsTypedDict(TypedDict):
528
178
  tool_choice: NotRequired[Any]
529
179
  tools: NotRequired[List[ToolDefinitionJSONTypedDict]]
530
180
  top_p: NotRequired[Nullable[float]]
531
- debug: NotRequired[DebugTypedDict]
181
+ user: NotRequired[str]
532
182
 
533
183
 
534
184
  class ChatGenerationParams(BaseModel):
535
185
  messages: List[Message]
536
186
 
537
- provider: OptionalNullable[ChatGenerationParamsProvider] = UNSET
538
- r"""When multiple model providers are available, optionally indicate your routing preference."""
539
-
540
- plugins: Optional[List[ChatGenerationParamsPluginUnion]] = None
541
- r"""Plugins you want to enable for this request, including their settings."""
542
-
543
- route: Annotated[
544
- OptionalNullable[Route], PlainValidator(validate_open_enum(False))
545
- ] = UNSET
546
-
547
- user: Optional[str] = None
548
-
549
- session_id: Optional[str] = None
550
- r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters."""
551
-
552
187
  model: Optional[str] = None
553
188
 
554
189
  models: Optional[List[str]] = None
@@ -589,16 +224,11 @@ class ChatGenerationParams(BaseModel):
589
224
 
590
225
  top_p: OptionalNullable[float] = UNSET
591
226
 
592
- debug: Optional[Debug] = None
227
+ user: Optional[str] = None
593
228
 
594
229
  @model_serializer(mode="wrap")
595
230
  def serialize_model(self, handler):
596
231
  optional_fields = [
597
- "provider",
598
- "plugins",
599
- "route",
600
- "user",
601
- "session_id",
602
232
  "model",
603
233
  "models",
604
234
  "frequency_penalty",
@@ -619,11 +249,9 @@ class ChatGenerationParams(BaseModel):
619
249
  "tool_choice",
620
250
  "tools",
621
251
  "top_p",
622
- "debug",
252
+ "user",
623
253
  ]
624
254
  nullable_fields = [
625
- "provider",
626
- "route",
627
255
  "frequency_penalty",
628
256
  "logit_bias",
629
257
  "logprobs",
@@ -26,9 +26,9 @@ from typing_extensions import Annotated, TypeAliasType
26
26
  ChatMessageContentItemTypedDict = TypeAliasType(
27
27
  "ChatMessageContentItemTypedDict",
28
28
  Union[
29
+ ChatMessageContentItemTextTypedDict,
29
30
  ChatMessageContentItemImageTypedDict,
30
31
  ChatMessageContentItemAudioTypedDict,
31
- ChatMessageContentItemTextTypedDict,
32
32
  ChatMessageContentItemVideoTypedDict,
33
33
  ],
34
34
  )
@@ -1,23 +1,42 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from openrouter.types import BaseModel
5
- from openrouter.utils import validate_const
4
+ from openrouter.types import BaseModel, UnrecognizedStr
5
+ from openrouter.utils import validate_const, validate_open_enum
6
6
  import pydantic
7
- from pydantic.functional_validators import AfterValidator
8
- from typing import Literal
7
+ from pydantic.functional_validators import AfterValidator, PlainValidator
8
+ from typing import Literal, Union
9
9
  from typing_extensions import Annotated, TypedDict
10
10
 
11
11
 
12
+ ChatMessageContentItemAudioFormat = Union[
13
+ Literal[
14
+ "wav",
15
+ "mp3",
16
+ "flac",
17
+ "m4a",
18
+ "ogg",
19
+ "pcm16",
20
+ "pcm24",
21
+ ],
22
+ UnrecognizedStr,
23
+ ]
24
+
25
+
12
26
  class ChatMessageContentItemAudioInputAudioTypedDict(TypedDict):
13
27
  data: str
14
- format_: str
28
+ format_: ChatMessageContentItemAudioFormat
15
29
 
16
30
 
17
31
  class ChatMessageContentItemAudioInputAudio(BaseModel):
18
32
  data: str
19
33
 
20
- format_: Annotated[str, pydantic.Field(alias="format")]
34
+ format_: Annotated[
35
+ Annotated[
36
+ ChatMessageContentItemAudioFormat, PlainValidator(validate_open_enum(False))
37
+ ],
38
+ pydantic.Field(alias="format"),
39
+ ]
21
40
 
22
41
 
23
42
  class ChatMessageContentItemAudioTypedDict(TypedDict):
@@ -1,22 +1,17 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from .chatmessagecontentitemcachecontrol import (
5
- ChatMessageContentItemCacheControl,
6
- ChatMessageContentItemCacheControlTypedDict,
7
- )
8
4
  from openrouter.types import BaseModel
9
5
  from openrouter.utils import validate_const
10
6
  import pydantic
11
7
  from pydantic.functional_validators import AfterValidator
12
- from typing import Literal, Optional
13
- from typing_extensions import Annotated, NotRequired, TypedDict
8
+ from typing import Literal
9
+ from typing_extensions import Annotated, TypedDict
14
10
 
15
11
 
16
12
  class ChatMessageContentItemTextTypedDict(TypedDict):
17
13
  text: str
18
14
  type: Literal["text"]
19
- cache_control: NotRequired[ChatMessageContentItemCacheControlTypedDict]
20
15
 
21
16
 
22
17
  class ChatMessageContentItemText(BaseModel):
@@ -26,5 +21,3 @@ class ChatMessageContentItemText(BaseModel):
26
21
  Annotated[Literal["text"], AfterValidator(validate_const("text"))],
27
22
  pydantic.Field(alias="type"),
28
23
  ] = "text"
29
-
30
- cache_control: Optional[ChatMessageContentItemCacheControl] = None
@@ -2,9 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from openrouter.types import BaseModel
5
- from openrouter.utils import get_discriminator, validate_const
5
+ from openrouter.utils import validate_const
6
6
  import pydantic
7
- from pydantic import Discriminator, Tag
8
7
  from pydantic.functional_validators import AfterValidator
9
8
  from typing import Literal, Union
10
9
  from typing_extensions import Annotated, TypeAliasType, TypedDict
@@ -65,10 +64,7 @@ ChatMessageContentItemVideoTypedDict = TypeAliasType(
65
64
  )
66
65
 
67
66
 
68
- ChatMessageContentItemVideo = Annotated[
69
- Union[
70
- Annotated[ChatMessageContentItemVideoInputVideo, Tag("input_video")],
71
- Annotated[ChatMessageContentItemVideoVideoURL, Tag("video_url")],
72
- ],
73
- Discriminator(lambda m: get_discriminator(m, "type", "type")),
74
- ]
67
+ ChatMessageContentItemVideo = TypeAliasType(
68
+ "ChatMessageContentItemVideo",
69
+ Union[ChatMessageContentItemVideoInputVideo, ChatMessageContentItemVideoVideoURL],
70
+ )