openrouter 0.1.2__py3-none-any.whl → 0.6.0__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 (84) hide show
  1. openrouter/_version.py +2 -2
  2. openrouter/analytics.py +28 -2
  3. openrouter/api_keys.py +210 -14
  4. openrouter/chat.py +192 -200
  5. openrouter/components/__init__.py +229 -285
  6. openrouter/components/_schema10.py +39 -0
  7. openrouter/components/_schema14.py +11 -0
  8. openrouter/components/_schema17.py +154 -0
  9. openrouter/components/{_schema3.py → _schema19.py} +28 -22
  10. openrouter/components/{_schema0.py → _schema5.py} +7 -5
  11. openrouter/components/assistantmessage.py +32 -1
  12. openrouter/components/chatgenerationparams.py +57 -343
  13. openrouter/components/chatmessagecontentitemimage.py +4 -4
  14. openrouter/components/chatresponsechoice.py +1 -6
  15. openrouter/components/chatstreamingmessagechunk.py +3 -3
  16. openrouter/components/developermessage.py +41 -0
  17. openrouter/components/message.py +6 -39
  18. openrouter/components/model.py +7 -1
  19. openrouter/components/openresponsesrequest.py +31 -39
  20. openrouter/components/outputmodality.py +1 -0
  21. openrouter/components/providername.py +2 -0
  22. openrouter/components/providerpreferences.py +2 -10
  23. openrouter/components/publicendpoint.py +8 -24
  24. openrouter/components/publicpricing.py +3 -24
  25. openrouter/credits.py +86 -14
  26. openrouter/embeddings.py +92 -20
  27. openrouter/endpoints.py +62 -2
  28. openrouter/generations.py +26 -0
  29. openrouter/guardrails.py +3367 -0
  30. openrouter/models_.py +120 -12
  31. openrouter/oauth.py +90 -22
  32. openrouter/operations/__init__.py +601 -30
  33. openrouter/operations/bulkassignkeystoguardrail.py +116 -0
  34. openrouter/operations/bulkassignmemberstoguardrail.py +116 -0
  35. openrouter/operations/bulkunassignkeysfromguardrail.py +116 -0
  36. openrouter/operations/bulkunassignmembersfromguardrail.py +116 -0
  37. openrouter/operations/createauthkeyscode.py +81 -3
  38. openrouter/operations/createcoinbasecharge.py +82 -2
  39. openrouter/operations/createembeddings.py +82 -3
  40. openrouter/operations/createguardrail.py +325 -0
  41. openrouter/operations/createkeys.py +81 -3
  42. openrouter/operations/createresponses.py +84 -3
  43. openrouter/operations/deleteguardrail.py +104 -0
  44. openrouter/operations/deletekeys.py +69 -3
  45. openrouter/operations/exchangeauthcodeforapikey.py +81 -3
  46. openrouter/operations/getcredits.py +70 -1
  47. openrouter/operations/getcurrentkey.py +81 -3
  48. openrouter/operations/getgeneration.py +248 -3
  49. openrouter/operations/getguardrail.py +228 -0
  50. openrouter/operations/getkey.py +64 -1
  51. openrouter/operations/getmodels.py +95 -5
  52. openrouter/operations/getuseractivity.py +62 -1
  53. openrouter/operations/list.py +63 -1
  54. openrouter/operations/listembeddingsmodels.py +74 -0
  55. openrouter/operations/listendpoints.py +65 -2
  56. openrouter/operations/listendpointszdr.py +70 -2
  57. openrouter/operations/listguardrailkeyassignments.py +192 -0
  58. openrouter/operations/listguardrailmemberassignments.py +187 -0
  59. openrouter/operations/listguardrails.py +238 -0
  60. openrouter/operations/listkeyassignments.py +180 -0
  61. openrouter/operations/listmemberassignments.py +175 -0
  62. openrouter/operations/listmodelscount.py +74 -0
  63. openrouter/operations/listmodelsuser.py +70 -2
  64. openrouter/operations/listproviders.py +70 -2
  65. openrouter/operations/sendchatcompletionrequest.py +87 -3
  66. openrouter/operations/updateguardrail.py +334 -0
  67. openrouter/operations/updatekeys.py +63 -0
  68. openrouter/providers.py +36 -2
  69. openrouter/responses.py +178 -148
  70. openrouter/sdk.py +5 -8
  71. openrouter/types/models.py +378 -0
  72. {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/METADATA +5 -1
  73. {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/RECORD +76 -63
  74. {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/WHEEL +1 -1
  75. openrouter/completions.py +0 -361
  76. openrouter/components/completionchoice.py +0 -82
  77. openrouter/components/completioncreateparams.py +0 -277
  78. openrouter/components/completionlogprobs.py +0 -54
  79. openrouter/components/completionresponse.py +0 -46
  80. openrouter/components/completionusage.py +0 -19
  81. openrouter/operations/getparameters.py +0 -123
  82. openrouter/parameters.py +0 -237
  83. {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/licenses/LICENSE +0 -0
  84. {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/top_level.txt +0 -0
@@ -3,13 +3,53 @@
3
3
  from __future__ import annotations
4
4
  from openrouter.components import providerpreferences as components_providerpreferences
5
5
  from openrouter.types import BaseModel, UnrecognizedStr
6
- from openrouter.utils import get_discriminator, validate_open_enum
6
+ from openrouter.utils import (
7
+ FieldMetadata,
8
+ HeaderMetadata,
9
+ RequestMetadata,
10
+ get_discriminator,
11
+ validate_open_enum,
12
+ )
13
+ import pydantic
7
14
  from pydantic import Discriminator, Tag
8
15
  from pydantic.functional_validators import PlainValidator
9
16
  from typing import List, Literal, Optional, Union
10
17
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
11
18
 
12
19
 
20
+ class CreateEmbeddingsGlobalsTypedDict(TypedDict):
21
+ http_referer: NotRequired[str]
22
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
23
+ This is used to track API usage per application.
24
+
25
+ """
26
+ x_title: NotRequired[str]
27
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
28
+
29
+ """
30
+
31
+
32
+ class CreateEmbeddingsGlobals(BaseModel):
33
+ http_referer: Annotated[
34
+ Optional[str],
35
+ pydantic.Field(alias="HTTP-Referer"),
36
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
37
+ ] = None
38
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
39
+ This is used to track API usage per application.
40
+
41
+ """
42
+
43
+ x_title: Annotated[
44
+ Optional[str],
45
+ pydantic.Field(alias="X-Title"),
46
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
47
+ ] = None
48
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
49
+
50
+ """
51
+
52
+
13
53
  TypeImageURL = Literal["image_url",]
14
54
 
15
55
 
@@ -88,7 +128,7 @@ EncodingFormat = Union[
88
128
  ]
89
129
 
90
130
 
91
- class CreateEmbeddingsRequestTypedDict(TypedDict):
131
+ class CreateEmbeddingsRequestBodyTypedDict(TypedDict):
92
132
  input: InputUnionTypedDict
93
133
  model: str
94
134
  encoding_format: NotRequired[EncodingFormat]
@@ -99,7 +139,7 @@ class CreateEmbeddingsRequestTypedDict(TypedDict):
99
139
  input_type: NotRequired[str]
100
140
 
101
141
 
102
- class CreateEmbeddingsRequest(BaseModel):
142
+ class CreateEmbeddingsRequestBody(BaseModel):
103
143
  input: InputUnion
104
144
 
105
145
  model: str
@@ -118,6 +158,45 @@ class CreateEmbeddingsRequest(BaseModel):
118
158
  input_type: Optional[str] = None
119
159
 
120
160
 
161
+ class CreateEmbeddingsRequestTypedDict(TypedDict):
162
+ request_body: CreateEmbeddingsRequestBodyTypedDict
163
+ http_referer: NotRequired[str]
164
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
165
+ This is used to track API usage per application.
166
+
167
+ """
168
+ x_title: NotRequired[str]
169
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
170
+
171
+ """
172
+
173
+
174
+ class CreateEmbeddingsRequest(BaseModel):
175
+ request_body: Annotated[
176
+ CreateEmbeddingsRequestBody,
177
+ FieldMetadata(request=RequestMetadata(media_type="application/json")),
178
+ ]
179
+
180
+ http_referer: Annotated[
181
+ Optional[str],
182
+ pydantic.Field(alias="HTTP-Referer"),
183
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
184
+ ] = None
185
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
186
+ This is used to track API usage per application.
187
+
188
+ """
189
+
190
+ x_title: Annotated[
191
+ Optional[str],
192
+ pydantic.Field(alias="X-Title"),
193
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
194
+ ] = None
195
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
196
+
197
+ """
198
+
199
+
121
200
  Object = Literal["list",]
122
201
 
123
202
 
@@ -0,0 +1,325 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from openrouter.types import (
5
+ BaseModel,
6
+ Nullable,
7
+ OptionalNullable,
8
+ UNSET,
9
+ UNSET_SENTINEL,
10
+ UnrecognizedStr,
11
+ )
12
+ from openrouter.utils import (
13
+ FieldMetadata,
14
+ HeaderMetadata,
15
+ RequestMetadata,
16
+ validate_open_enum,
17
+ )
18
+ import pydantic
19
+ from pydantic import model_serializer
20
+ from pydantic.functional_validators import PlainValidator
21
+ from typing import List, Literal, Optional, Union
22
+ from typing_extensions import Annotated, NotRequired, TypedDict
23
+
24
+
25
+ class CreateGuardrailGlobalsTypedDict(TypedDict):
26
+ http_referer: NotRequired[str]
27
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
28
+ This is used to track API usage per application.
29
+
30
+ """
31
+ x_title: NotRequired[str]
32
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
33
+
34
+ """
35
+
36
+
37
+ class CreateGuardrailGlobals(BaseModel):
38
+ http_referer: Annotated[
39
+ Optional[str],
40
+ pydantic.Field(alias="HTTP-Referer"),
41
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
42
+ ] = None
43
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
44
+ This is used to track API usage per application.
45
+
46
+ """
47
+
48
+ x_title: Annotated[
49
+ Optional[str],
50
+ pydantic.Field(alias="X-Title"),
51
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
52
+ ] = None
53
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
54
+
55
+ """
56
+
57
+
58
+ CreateGuardrailResetIntervalRequest = Union[
59
+ Literal[
60
+ "daily",
61
+ "weekly",
62
+ "monthly",
63
+ ],
64
+ UnrecognizedStr,
65
+ ]
66
+ r"""Interval at which the limit resets (daily, weekly, monthly)"""
67
+
68
+
69
+ class CreateGuardrailRequestBodyTypedDict(TypedDict):
70
+ name: str
71
+ r"""Name for the new guardrail"""
72
+ description: NotRequired[Nullable[str]]
73
+ r"""Description of the guardrail"""
74
+ limit_usd: NotRequired[Nullable[float]]
75
+ r"""Spending limit in USD"""
76
+ reset_interval: NotRequired[Nullable[CreateGuardrailResetIntervalRequest]]
77
+ r"""Interval at which the limit resets (daily, weekly, monthly)"""
78
+ allowed_providers: NotRequired[Nullable[List[str]]]
79
+ r"""List of allowed provider IDs"""
80
+ allowed_models: NotRequired[Nullable[List[str]]]
81
+ r"""Array of model identifiers (slug or canonical_slug accepted)"""
82
+ enforce_zdr: NotRequired[Nullable[bool]]
83
+ r"""Whether to enforce zero data retention"""
84
+
85
+
86
+ class CreateGuardrailRequestBody(BaseModel):
87
+ name: str
88
+ r"""Name for the new guardrail"""
89
+
90
+ description: OptionalNullable[str] = UNSET
91
+ r"""Description of the guardrail"""
92
+
93
+ limit_usd: OptionalNullable[float] = UNSET
94
+ r"""Spending limit in USD"""
95
+
96
+ reset_interval: Annotated[
97
+ OptionalNullable[CreateGuardrailResetIntervalRequest],
98
+ PlainValidator(validate_open_enum(False)),
99
+ ] = UNSET
100
+ r"""Interval at which the limit resets (daily, weekly, monthly)"""
101
+
102
+ allowed_providers: OptionalNullable[List[str]] = UNSET
103
+ r"""List of allowed provider IDs"""
104
+
105
+ allowed_models: OptionalNullable[List[str]] = UNSET
106
+ r"""Array of model identifiers (slug or canonical_slug accepted)"""
107
+
108
+ enforce_zdr: OptionalNullable[bool] = UNSET
109
+ r"""Whether to enforce zero data retention"""
110
+
111
+ @model_serializer(mode="wrap")
112
+ def serialize_model(self, handler):
113
+ optional_fields = [
114
+ "description",
115
+ "limit_usd",
116
+ "reset_interval",
117
+ "allowed_providers",
118
+ "allowed_models",
119
+ "enforce_zdr",
120
+ ]
121
+ nullable_fields = [
122
+ "description",
123
+ "limit_usd",
124
+ "reset_interval",
125
+ "allowed_providers",
126
+ "allowed_models",
127
+ "enforce_zdr",
128
+ ]
129
+ null_default_fields = []
130
+
131
+ serialized = handler(self)
132
+
133
+ m = {}
134
+
135
+ for n, f in type(self).model_fields.items():
136
+ k = f.alias or n
137
+ val = serialized.get(k)
138
+ serialized.pop(k, None)
139
+
140
+ optional_nullable = k in optional_fields and k in nullable_fields
141
+ is_set = (
142
+ self.__pydantic_fields_set__.intersection({n})
143
+ or k in null_default_fields
144
+ ) # pylint: disable=no-member
145
+
146
+ if val is not None and val != UNSET_SENTINEL:
147
+ m[k] = val
148
+ elif val != UNSET_SENTINEL and (
149
+ not k in optional_fields or (optional_nullable and is_set)
150
+ ):
151
+ m[k] = val
152
+
153
+ return m
154
+
155
+
156
+ class CreateGuardrailRequestTypedDict(TypedDict):
157
+ request_body: CreateGuardrailRequestBodyTypedDict
158
+ http_referer: NotRequired[str]
159
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
160
+ This is used to track API usage per application.
161
+
162
+ """
163
+ x_title: NotRequired[str]
164
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
165
+
166
+ """
167
+
168
+
169
+ class CreateGuardrailRequest(BaseModel):
170
+ request_body: Annotated[
171
+ CreateGuardrailRequestBody,
172
+ FieldMetadata(request=RequestMetadata(media_type="application/json")),
173
+ ]
174
+
175
+ http_referer: Annotated[
176
+ Optional[str],
177
+ pydantic.Field(alias="HTTP-Referer"),
178
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
179
+ ] = None
180
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
181
+ This is used to track API usage per application.
182
+
183
+ """
184
+
185
+ x_title: Annotated[
186
+ Optional[str],
187
+ pydantic.Field(alias="X-Title"),
188
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
189
+ ] = None
190
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
191
+
192
+ """
193
+
194
+
195
+ CreateGuardrailResetIntervalResponse = Union[
196
+ Literal[
197
+ "daily",
198
+ "weekly",
199
+ "monthly",
200
+ ],
201
+ UnrecognizedStr,
202
+ ]
203
+ r"""Interval at which the limit resets (daily, weekly, monthly)"""
204
+
205
+
206
+ class CreateGuardrailDataTypedDict(TypedDict):
207
+ r"""The created guardrail"""
208
+
209
+ id: str
210
+ r"""Unique identifier for the guardrail"""
211
+ name: str
212
+ r"""Name of the guardrail"""
213
+ created_at: str
214
+ r"""ISO 8601 timestamp of when the guardrail was created"""
215
+ description: NotRequired[Nullable[str]]
216
+ r"""Description of the guardrail"""
217
+ limit_usd: NotRequired[Nullable[float]]
218
+ r"""Spending limit in USD"""
219
+ reset_interval: NotRequired[Nullable[CreateGuardrailResetIntervalResponse]]
220
+ r"""Interval at which the limit resets (daily, weekly, monthly)"""
221
+ allowed_providers: NotRequired[Nullable[List[str]]]
222
+ r"""List of allowed provider IDs"""
223
+ allowed_models: NotRequired[Nullable[List[str]]]
224
+ r"""Array of model canonical_slugs (immutable identifiers)"""
225
+ enforce_zdr: NotRequired[Nullable[bool]]
226
+ r"""Whether to enforce zero data retention"""
227
+ updated_at: NotRequired[Nullable[str]]
228
+ r"""ISO 8601 timestamp of when the guardrail was last updated"""
229
+
230
+
231
+ class CreateGuardrailData(BaseModel):
232
+ r"""The created guardrail"""
233
+
234
+ id: str
235
+ r"""Unique identifier for the guardrail"""
236
+
237
+ name: str
238
+ r"""Name of the guardrail"""
239
+
240
+ created_at: str
241
+ r"""ISO 8601 timestamp of when the guardrail was created"""
242
+
243
+ description: OptionalNullable[str] = UNSET
244
+ r"""Description of the guardrail"""
245
+
246
+ limit_usd: OptionalNullable[float] = UNSET
247
+ r"""Spending limit in USD"""
248
+
249
+ reset_interval: Annotated[
250
+ OptionalNullable[CreateGuardrailResetIntervalResponse],
251
+ PlainValidator(validate_open_enum(False)),
252
+ ] = UNSET
253
+ r"""Interval at which the limit resets (daily, weekly, monthly)"""
254
+
255
+ allowed_providers: OptionalNullable[List[str]] = UNSET
256
+ r"""List of allowed provider IDs"""
257
+
258
+ allowed_models: OptionalNullable[List[str]] = UNSET
259
+ r"""Array of model canonical_slugs (immutable identifiers)"""
260
+
261
+ enforce_zdr: OptionalNullable[bool] = UNSET
262
+ r"""Whether to enforce zero data retention"""
263
+
264
+ updated_at: OptionalNullable[str] = UNSET
265
+ r"""ISO 8601 timestamp of when the guardrail was last updated"""
266
+
267
+ @model_serializer(mode="wrap")
268
+ def serialize_model(self, handler):
269
+ optional_fields = [
270
+ "description",
271
+ "limit_usd",
272
+ "reset_interval",
273
+ "allowed_providers",
274
+ "allowed_models",
275
+ "enforce_zdr",
276
+ "updated_at",
277
+ ]
278
+ nullable_fields = [
279
+ "description",
280
+ "limit_usd",
281
+ "reset_interval",
282
+ "allowed_providers",
283
+ "allowed_models",
284
+ "enforce_zdr",
285
+ "updated_at",
286
+ ]
287
+ null_default_fields = []
288
+
289
+ serialized = handler(self)
290
+
291
+ m = {}
292
+
293
+ for n, f in type(self).model_fields.items():
294
+ k = f.alias or n
295
+ val = serialized.get(k)
296
+ serialized.pop(k, None)
297
+
298
+ optional_nullable = k in optional_fields and k in nullable_fields
299
+ is_set = (
300
+ self.__pydantic_fields_set__.intersection({n})
301
+ or k in null_default_fields
302
+ ) # pylint: disable=no-member
303
+
304
+ if val is not None and val != UNSET_SENTINEL:
305
+ m[k] = val
306
+ elif val != UNSET_SENTINEL and (
307
+ not k in optional_fields or (optional_nullable and is_set)
308
+ ):
309
+ m[k] = val
310
+
311
+ return m
312
+
313
+
314
+ class CreateGuardrailResponseTypedDict(TypedDict):
315
+ r"""Guardrail created successfully"""
316
+
317
+ data: CreateGuardrailDataTypedDict
318
+ r"""The created guardrail"""
319
+
320
+
321
+ class CreateGuardrailResponse(BaseModel):
322
+ r"""Guardrail created successfully"""
323
+
324
+ data: CreateGuardrailData
325
+ r"""The created guardrail"""
@@ -10,13 +10,52 @@ from openrouter.types import (
10
10
  UNSET_SENTINEL,
11
11
  UnrecognizedStr,
12
12
  )
13
- from openrouter.utils import validate_open_enum
13
+ from openrouter.utils import (
14
+ FieldMetadata,
15
+ HeaderMetadata,
16
+ RequestMetadata,
17
+ validate_open_enum,
18
+ )
19
+ import pydantic
14
20
  from pydantic import model_serializer
15
21
  from pydantic.functional_validators import PlainValidator
16
22
  from typing import Literal, Optional, Union
17
23
  from typing_extensions import Annotated, NotRequired, TypedDict
18
24
 
19
25
 
26
+ class CreateKeysGlobalsTypedDict(TypedDict):
27
+ http_referer: NotRequired[str]
28
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
29
+ This is used to track API usage per application.
30
+
31
+ """
32
+ x_title: NotRequired[str]
33
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
34
+
35
+ """
36
+
37
+
38
+ class CreateKeysGlobals(BaseModel):
39
+ http_referer: Annotated[
40
+ Optional[str],
41
+ pydantic.Field(alias="HTTP-Referer"),
42
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
43
+ ] = None
44
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
45
+ This is used to track API usage per application.
46
+
47
+ """
48
+
49
+ x_title: Annotated[
50
+ Optional[str],
51
+ pydantic.Field(alias="X-Title"),
52
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
53
+ ] = None
54
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
55
+
56
+ """
57
+
58
+
20
59
  CreateKeysLimitReset = Union[
21
60
  Literal[
22
61
  "daily",
@@ -28,7 +67,7 @@ CreateKeysLimitReset = Union[
28
67
  r"""Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday."""
29
68
 
30
69
 
31
- class CreateKeysRequestTypedDict(TypedDict):
70
+ class CreateKeysRequestBodyTypedDict(TypedDict):
32
71
  name: str
33
72
  r"""Name for the new API key"""
34
73
  limit: NotRequired[Nullable[float]]
@@ -41,7 +80,7 @@ class CreateKeysRequestTypedDict(TypedDict):
41
80
  r"""Optional ISO 8601 UTC timestamp when the API key should expire. Must be UTC, other timezones will be rejected"""
42
81
 
43
82
 
44
- class CreateKeysRequest(BaseModel):
83
+ class CreateKeysRequestBody(BaseModel):
45
84
  name: str
46
85
  r"""Name for the new API key"""
47
86
 
@@ -96,6 +135,45 @@ class CreateKeysRequest(BaseModel):
96
135
  return m
97
136
 
98
137
 
138
+ class CreateKeysRequestTypedDict(TypedDict):
139
+ request_body: CreateKeysRequestBodyTypedDict
140
+ http_referer: NotRequired[str]
141
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
142
+ This is used to track API usage per application.
143
+
144
+ """
145
+ x_title: NotRequired[str]
146
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
147
+
148
+ """
149
+
150
+
151
+ class CreateKeysRequest(BaseModel):
152
+ request_body: Annotated[
153
+ CreateKeysRequestBody,
154
+ FieldMetadata(request=RequestMetadata(media_type="application/json")),
155
+ ]
156
+
157
+ http_referer: Annotated[
158
+ Optional[str],
159
+ pydantic.Field(alias="HTTP-Referer"),
160
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
161
+ ] = None
162
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
163
+ This is used to track API usage per application.
164
+
165
+ """
166
+
167
+ x_title: Annotated[
168
+ Optional[str],
169
+ pydantic.Field(alias="X-Title"),
170
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
171
+ ] = None
172
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
173
+
174
+ """
175
+
176
+
99
177
  class CreateKeysDataTypedDict(TypedDict):
100
178
  r"""The created API key information"""
101
179
 
@@ -3,12 +3,93 @@
3
3
  from __future__ import annotations
4
4
  from openrouter.components import (
5
5
  openresponsesnonstreamingresponse as components_openresponsesnonstreamingresponse,
6
+ openresponsesrequest as components_openresponsesrequest,
6
7
  openresponsesstreamevent as components_openresponsesstreamevent,
7
8
  )
8
9
  from openrouter.types import BaseModel
9
- from openrouter.utils import eventstreaming
10
- from typing import Union
11
- from typing_extensions import TypeAliasType, TypedDict
10
+ from openrouter.utils import (
11
+ FieldMetadata,
12
+ HeaderMetadata,
13
+ RequestMetadata,
14
+ eventstreaming,
15
+ )
16
+ import pydantic
17
+ from typing import Optional, Union
18
+ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
19
+
20
+
21
+ class CreateResponsesGlobalsTypedDict(TypedDict):
22
+ http_referer: NotRequired[str]
23
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
24
+ This is used to track API usage per application.
25
+
26
+ """
27
+ x_title: NotRequired[str]
28
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
29
+
30
+ """
31
+
32
+
33
+ class CreateResponsesGlobals(BaseModel):
34
+ http_referer: Annotated[
35
+ Optional[str],
36
+ pydantic.Field(alias="HTTP-Referer"),
37
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
38
+ ] = None
39
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
40
+ This is used to track API usage per application.
41
+
42
+ """
43
+
44
+ x_title: Annotated[
45
+ Optional[str],
46
+ pydantic.Field(alias="X-Title"),
47
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
48
+ ] = None
49
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
50
+
51
+ """
52
+
53
+
54
+ class CreateResponsesRequestTypedDict(TypedDict):
55
+ open_responses_request: (
56
+ components_openresponsesrequest.OpenResponsesRequestTypedDict
57
+ )
58
+ http_referer: NotRequired[str]
59
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
60
+ This is used to track API usage per application.
61
+
62
+ """
63
+ x_title: NotRequired[str]
64
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
65
+
66
+ """
67
+
68
+
69
+ class CreateResponsesRequest(BaseModel):
70
+ open_responses_request: Annotated[
71
+ components_openresponsesrequest.OpenResponsesRequest,
72
+ FieldMetadata(request=RequestMetadata(media_type="application/json")),
73
+ ]
74
+
75
+ http_referer: Annotated[
76
+ Optional[str],
77
+ pydantic.Field(alias="HTTP-Referer"),
78
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
79
+ ] = None
80
+ r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
81
+ This is used to track API usage per application.
82
+
83
+ """
84
+
85
+ x_title: Annotated[
86
+ Optional[str],
87
+ pydantic.Field(alias="X-Title"),
88
+ FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
89
+ ] = None
90
+ r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
91
+
92
+ """
12
93
 
13
94
 
14
95
  class CreateResponsesResponseBodyTypedDict(TypedDict):