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
@@ -0,0 +1,21 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .percentilelatencycutoffs import (
5
+ PercentileLatencyCutoffs,
6
+ PercentileLatencyCutoffsTypedDict,
7
+ )
8
+ from typing import Any, Union
9
+ from typing_extensions import TypeAliasType
10
+
11
+
12
+ PreferredMaxLatencyTypedDict = TypeAliasType(
13
+ "PreferredMaxLatencyTypedDict", Union[PercentileLatencyCutoffsTypedDict, float, Any]
14
+ )
15
+ r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
16
+
17
+
18
+ PreferredMaxLatency = TypeAliasType(
19
+ "PreferredMaxLatency", Union[PercentileLatencyCutoffs, float, Any]
20
+ )
21
+ r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
@@ -0,0 +1,22 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .percentilethroughputcutoffs import (
5
+ PercentileThroughputCutoffs,
6
+ PercentileThroughputCutoffsTypedDict,
7
+ )
8
+ from typing import Any, Union
9
+ from typing_extensions import TypeAliasType
10
+
11
+
12
+ PreferredMinThroughputTypedDict = TypeAliasType(
13
+ "PreferredMinThroughputTypedDict",
14
+ Union[PercentileThroughputCutoffsTypedDict, float, Any],
15
+ )
16
+ r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
17
+
18
+
19
+ PreferredMinThroughput = TypeAliasType(
20
+ "PreferredMinThroughput", Union[PercentileThroughputCutoffs, float, Any]
21
+ )
22
+ r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
@@ -33,12 +33,12 @@ ProviderName = Union[
33
33
  "Fireworks",
34
34
  "Friendli",
35
35
  "GMICloud",
36
- "GoPomelo",
37
36
  "Google",
38
37
  "Google AI Studio",
39
38
  "Groq",
40
39
  "Hyperbolic",
41
40
  "Inception",
41
+ "Inceptron",
42
42
  "InferenceNet",
43
43
  "Infermatic",
44
44
  "Inflection",
@@ -63,13 +63,14 @@ ProviderName = Union[
63
63
  "Phala",
64
64
  "Relace",
65
65
  "SambaNova",
66
+ "Seed",
66
67
  "SiliconFlow",
67
68
  "Sourceful",
68
69
  "Stealth",
69
70
  "StreamLake",
70
71
  "Switchpoint",
71
- "Targon",
72
72
  "Together",
73
+ "Upstage",
73
74
  "Venice",
74
75
  "WandB",
75
76
  "Xiaomi",
@@ -0,0 +1,355 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .datacollection import DataCollection
5
+ from .preferredmaxlatency import PreferredMaxLatency, PreferredMaxLatencyTypedDict
6
+ from .preferredminthroughput import (
7
+ PreferredMinThroughput,
8
+ PreferredMinThroughputTypedDict,
9
+ )
10
+ from .providername import ProviderName
11
+ from .providersort import ProviderSort
12
+ from .quantization import Quantization
13
+ from openrouter.types import (
14
+ BaseModel,
15
+ Nullable,
16
+ OptionalNullable,
17
+ UNSET,
18
+ UNSET_SENTINEL,
19
+ UnrecognizedStr,
20
+ )
21
+ from openrouter.utils import validate_open_enum
22
+ from pydantic import model_serializer
23
+ from pydantic.functional_validators import PlainValidator
24
+ from typing import List, Literal, Optional, Union
25
+ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
26
+
27
+
28
+ ProviderPreferencesOrderTypedDict = TypeAliasType(
29
+ "ProviderPreferencesOrderTypedDict", Union[ProviderName, str]
30
+ )
31
+
32
+
33
+ ProviderPreferencesOrder = TypeAliasType(
34
+ "ProviderPreferencesOrder",
35
+ Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
36
+ )
37
+
38
+
39
+ ProviderPreferencesOnlyTypedDict = TypeAliasType(
40
+ "ProviderPreferencesOnlyTypedDict", Union[ProviderName, str]
41
+ )
42
+
43
+
44
+ ProviderPreferencesOnly = TypeAliasType(
45
+ "ProviderPreferencesOnly",
46
+ Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
47
+ )
48
+
49
+
50
+ ProviderPreferencesIgnoreTypedDict = TypeAliasType(
51
+ "ProviderPreferencesIgnoreTypedDict", Union[ProviderName, str]
52
+ )
53
+
54
+
55
+ ProviderPreferencesIgnore = TypeAliasType(
56
+ "ProviderPreferencesIgnore",
57
+ Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
58
+ )
59
+
60
+
61
+ SortEnum = Union[
62
+ Literal[
63
+ "price",
64
+ "throughput",
65
+ "latency",
66
+ ],
67
+ UnrecognizedStr,
68
+ ]
69
+
70
+
71
+ ProviderSortConfigEnum = Literal[
72
+ "price",
73
+ "throughput",
74
+ "latency",
75
+ ]
76
+
77
+
78
+ ProviderPreferencesPartition = Union[
79
+ Literal[
80
+ "model",
81
+ "none",
82
+ ],
83
+ UnrecognizedStr,
84
+ ]
85
+
86
+
87
+ class ProviderPreferencesProviderSortConfigTypedDict(TypedDict):
88
+ by: NotRequired[Nullable[ProviderSort]]
89
+ partition: NotRequired[Nullable[ProviderPreferencesPartition]]
90
+
91
+
92
+ class ProviderPreferencesProviderSortConfig(BaseModel):
93
+ by: Annotated[
94
+ OptionalNullable[ProviderSort], PlainValidator(validate_open_enum(False))
95
+ ] = UNSET
96
+
97
+ partition: Annotated[
98
+ OptionalNullable[ProviderPreferencesPartition],
99
+ PlainValidator(validate_open_enum(False)),
100
+ ] = UNSET
101
+
102
+ @model_serializer(mode="wrap")
103
+ def serialize_model(self, handler):
104
+ optional_fields = ["by", "partition"]
105
+ nullable_fields = ["by", "partition"]
106
+ null_default_fields = []
107
+
108
+ serialized = handler(self)
109
+
110
+ m = {}
111
+
112
+ for n, f in type(self).model_fields.items():
113
+ k = f.alias or n
114
+ val = serialized.get(k)
115
+ serialized.pop(k, None)
116
+
117
+ optional_nullable = k in optional_fields and k in nullable_fields
118
+ is_set = (
119
+ self.__pydantic_fields_set__.intersection({n})
120
+ or k in null_default_fields
121
+ ) # pylint: disable=no-member
122
+
123
+ if val is not None and val != UNSET_SENTINEL:
124
+ m[k] = val
125
+ elif val != UNSET_SENTINEL and (
126
+ not k in optional_fields or (optional_nullable and is_set)
127
+ ):
128
+ m[k] = val
129
+
130
+ return m
131
+
132
+
133
+ ProviderSortConfigUnionTypedDict = TypeAliasType(
134
+ "ProviderSortConfigUnionTypedDict",
135
+ Union[ProviderPreferencesProviderSortConfigTypedDict, ProviderSortConfigEnum],
136
+ )
137
+
138
+
139
+ ProviderSortConfigUnion = TypeAliasType(
140
+ "ProviderSortConfigUnion",
141
+ Union[ProviderPreferencesProviderSortConfig, ProviderSortConfigEnum],
142
+ )
143
+
144
+
145
+ ProviderPreferencesProviderSort = Union[
146
+ Literal[
147
+ "price",
148
+ "throughput",
149
+ "latency",
150
+ ],
151
+ UnrecognizedStr,
152
+ ]
153
+
154
+
155
+ ProviderPreferencesSortUnionTypedDict = TypeAliasType(
156
+ "ProviderPreferencesSortUnionTypedDict",
157
+ Union[ProviderPreferencesProviderSort, ProviderSortConfigUnionTypedDict, SortEnum],
158
+ )
159
+ r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
160
+
161
+
162
+ ProviderPreferencesSortUnion = TypeAliasType(
163
+ "ProviderPreferencesSortUnion",
164
+ Union[
165
+ Annotated[
166
+ ProviderPreferencesProviderSort, PlainValidator(validate_open_enum(False))
167
+ ],
168
+ ProviderSortConfigUnion,
169
+ Annotated[SortEnum, PlainValidator(validate_open_enum(False))],
170
+ ],
171
+ )
172
+ r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
173
+
174
+
175
+ class ProviderPreferencesMaxPriceTypedDict(TypedDict):
176
+ r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
177
+
178
+ prompt: NotRequired[str]
179
+ r"""A value in string format that is a large number"""
180
+ completion: NotRequired[str]
181
+ r"""A value in string format that is a large number"""
182
+ image: NotRequired[str]
183
+ r"""A value in string format that is a large number"""
184
+ audio: NotRequired[str]
185
+ r"""A value in string format that is a large number"""
186
+ request: NotRequired[str]
187
+ r"""A value in string format that is a large number"""
188
+
189
+
190
+ class ProviderPreferencesMaxPrice(BaseModel):
191
+ r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
192
+
193
+ prompt: Optional[str] = None
194
+ r"""A value in string format that is a large number"""
195
+
196
+ completion: Optional[str] = None
197
+ r"""A value in string format that is a large number"""
198
+
199
+ image: Optional[str] = None
200
+ r"""A value in string format that is a large number"""
201
+
202
+ audio: Optional[str] = None
203
+ r"""A value in string format that is a large number"""
204
+
205
+ request: Optional[str] = None
206
+ r"""A value in string format that is a large number"""
207
+
208
+
209
+ class ProviderPreferencesTypedDict(TypedDict):
210
+ r"""Provider routing preferences for the request."""
211
+
212
+ allow_fallbacks: NotRequired[Nullable[bool]]
213
+ r"""Whether to allow backup providers to serve requests
214
+ - true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
215
+ - false: use only the primary/custom provider, and return the upstream error if it's unavailable.
216
+
217
+ """
218
+ require_parameters: NotRequired[Nullable[bool]]
219
+ 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."""
220
+ data_collection: NotRequired[Nullable[DataCollection]]
221
+ r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
222
+ - allow: (default) allow providers which store user data non-transiently and may train on it
223
+
224
+ - deny: use only providers which do not collect user data.
225
+ """
226
+ zdr: NotRequired[Nullable[bool]]
227
+ r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
228
+ enforce_distillable_text: NotRequired[Nullable[bool]]
229
+ 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."""
230
+ order: NotRequired[Nullable[List[ProviderPreferencesOrderTypedDict]]]
231
+ 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."""
232
+ only: NotRequired[Nullable[List[ProviderPreferencesOnlyTypedDict]]]
233
+ r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
234
+ ignore: NotRequired[Nullable[List[ProviderPreferencesIgnoreTypedDict]]]
235
+ r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
236
+ quantizations: NotRequired[Nullable[List[Quantization]]]
237
+ r"""A list of quantization levels to filter the provider by."""
238
+ sort: NotRequired[Nullable[ProviderPreferencesSortUnionTypedDict]]
239
+ max_price: NotRequired[ProviderPreferencesMaxPriceTypedDict]
240
+ r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
241
+ preferred_min_throughput: NotRequired[Nullable[PreferredMinThroughputTypedDict]]
242
+ r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
243
+ preferred_max_latency: NotRequired[Nullable[PreferredMaxLatencyTypedDict]]
244
+ r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
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[PreferredMinThroughput] = UNSET
295
+ r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
296
+
297
+ preferred_max_latency: OptionalNullable[PreferredMaxLatency] = UNSET
298
+ r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
299
+
300
+ @model_serializer(mode="wrap")
301
+ def serialize_model(self, handler):
302
+ optional_fields = [
303
+ "allow_fallbacks",
304
+ "require_parameters",
305
+ "data_collection",
306
+ "zdr",
307
+ "enforce_distillable_text",
308
+ "order",
309
+ "only",
310
+ "ignore",
311
+ "quantizations",
312
+ "sort",
313
+ "max_price",
314
+ "preferred_min_throughput",
315
+ "preferred_max_latency",
316
+ ]
317
+ nullable_fields = [
318
+ "allow_fallbacks",
319
+ "require_parameters",
320
+ "data_collection",
321
+ "zdr",
322
+ "enforce_distillable_text",
323
+ "order",
324
+ "only",
325
+ "ignore",
326
+ "quantizations",
327
+ "sort",
328
+ "preferred_min_throughput",
329
+ "preferred_max_latency",
330
+ ]
331
+ null_default_fields = []
332
+
333
+ serialized = handler(self)
334
+
335
+ m = {}
336
+
337
+ for n, f in type(self).model_fields.items():
338
+ k = f.alias or n
339
+ val = serialized.get(k)
340
+ serialized.pop(k, None)
341
+
342
+ optional_nullable = k in optional_fields and k in nullable_fields
343
+ is_set = (
344
+ self.__pydantic_fields_set__.intersection({n})
345
+ or k in null_default_fields
346
+ ) # pylint: disable=no-member
347
+
348
+ if val is not None and val != UNSET_SENTINEL:
349
+ m[k] = val
350
+ elif val != UNSET_SENTINEL and (
351
+ not k in optional_fields or (optional_nullable and is_set)
352
+ ):
353
+ m[k] = val
354
+
355
+ return m
@@ -13,4 +13,3 @@ ProviderSort = Union[
13
13
  ],
14
14
  UnrecognizedStr,
15
15
  ]
16
- r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
@@ -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
+ )
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
  from .endpointstatus import EndpointStatus
5
5
  from .parameter import Parameter
6
+ from .percentilestats import PercentileStats, PercentileStatsTypedDict
6
7
  from .providername import ProviderName
7
8
  from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr
8
9
  from openrouter.utils import validate_open_enum
@@ -111,6 +112,9 @@ class PublicEndpointTypedDict(TypedDict):
111
112
  supported_parameters: List[Parameter]
112
113
  uptime_last_30m: Nullable[float]
113
114
  supports_implicit_caching: bool
115
+ latency_last_30m: Nullable[PercentileStatsTypedDict]
116
+ r"""Latency percentiles in milliseconds over the last 30 minutes. Latency measures time to first token. Only visible when authenticated with an API key or cookie; returns null for unauthenticated requests."""
117
+ throughput_last_30m: Nullable[PercentileStatsTypedDict]
114
118
  status: NotRequired[EndpointStatus]
115
119
 
116
120
 
@@ -145,6 +149,11 @@ class PublicEndpoint(BaseModel):
145
149
 
146
150
  supports_implicit_caching: bool
147
151
 
152
+ latency_last_30m: Nullable[PercentileStats]
153
+ r"""Latency percentiles in milliseconds over the last 30 minutes. Latency measures time to first token. Only visible when authenticated with an API key or cookie; returns null for unauthenticated requests."""
154
+
155
+ throughput_last_30m: Nullable[PercentileStats]
156
+
148
157
  status: Annotated[
149
158
  Optional[EndpointStatus], PlainValidator(validate_open_enum(True))
150
159
  ] = None
@@ -157,6 +166,8 @@ class PublicEndpoint(BaseModel):
157
166
  "max_completion_tokens",
158
167
  "max_prompt_tokens",
159
168
  "uptime_last_30m",
169
+ "latency_last_30m",
170
+ "throughput_last_30m",
160
171
  ]
161
172
  null_default_fields = []
162
173
 
@@ -0,0 +1,26 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from openrouter.types import BaseModel
5
+ from typing import Literal
6
+ from typing_extensions import TypedDict
7
+
8
+
9
+ ResponseInputVideoType = Literal["input_video",]
10
+
11
+
12
+ class ResponseInputVideoTypedDict(TypedDict):
13
+ r"""Video input content item"""
14
+
15
+ type: ResponseInputVideoType
16
+ video_url: str
17
+ r"""A base64 data URL or remote URL that resolves to a video file"""
18
+
19
+
20
+ class ResponseInputVideo(BaseModel):
21
+ r"""Video input content item"""
22
+
23
+ type: ResponseInputVideoType
24
+
25
+ video_url: str
26
+ r"""A base64 data URL or remote URL that resolves to a video file"""
@@ -6,17 +6,50 @@ from .openairesponsesannotation import (
6
6
  OpenAIResponsesAnnotationTypedDict,
7
7
  )
8
8
  from openrouter.types import BaseModel
9
+ import pydantic
9
10
  from typing import List, Literal, Optional
10
- from typing_extensions import NotRequired, TypedDict
11
+ from typing_extensions import Annotated, NotRequired, TypedDict
11
12
 
12
13
 
13
14
  ResponseOutputTextType = Literal["output_text",]
14
15
 
15
16
 
17
+ class ResponseOutputTextTopLogprobTypedDict(TypedDict):
18
+ token: str
19
+ bytes_: List[float]
20
+ logprob: float
21
+
22
+
23
+ class ResponseOutputTextTopLogprob(BaseModel):
24
+ token: str
25
+
26
+ bytes_: Annotated[List[float], pydantic.Field(alias="bytes")]
27
+
28
+ logprob: float
29
+
30
+
31
+ class LogprobTypedDict(TypedDict):
32
+ token: str
33
+ bytes_: List[float]
34
+ logprob: float
35
+ top_logprobs: List[ResponseOutputTextTopLogprobTypedDict]
36
+
37
+
38
+ class Logprob(BaseModel):
39
+ token: str
40
+
41
+ bytes_: Annotated[List[float], pydantic.Field(alias="bytes")]
42
+
43
+ logprob: float
44
+
45
+ top_logprobs: List[ResponseOutputTextTopLogprob]
46
+
47
+
16
48
  class ResponseOutputTextTypedDict(TypedDict):
17
49
  type: ResponseOutputTextType
18
50
  text: str
19
51
  annotations: NotRequired[List[OpenAIResponsesAnnotationTypedDict]]
52
+ logprobs: NotRequired[List[LogprobTypedDict]]
20
53
 
21
54
 
22
55
  class ResponseOutputText(BaseModel):
@@ -25,3 +58,5 @@ class ResponseOutputText(BaseModel):
25
58
  text: str
26
59
 
27
60
  annotations: Optional[List[OpenAIResponsesAnnotation]] = None
61
+
62
+ logprobs: Optional[List[Logprob]] = None
@@ -38,8 +38,8 @@ ResponsesOutputItemTypedDict = TypeAliasType(
38
38
  ResponsesOutputItemFileSearchCallTypedDict,
39
39
  ResponsesImageGenerationCallTypedDict,
40
40
  ResponsesOutputMessageTypedDict,
41
- ResponsesOutputItemReasoningTypedDict,
42
41
  ResponsesOutputItemFunctionCallTypedDict,
42
+ ResponsesOutputItemReasoningTypedDict,
43
43
  ],
44
44
  )
45
45
  r"""An output item from the response"""