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.
- openrouter/_version.py +2 -2
- openrouter/analytics.py +28 -2
- openrouter/api_keys.py +210 -14
- openrouter/chat.py +192 -200
- openrouter/components/__init__.py +229 -285
- openrouter/components/_schema10.py +39 -0
- openrouter/components/_schema14.py +11 -0
- openrouter/components/_schema17.py +154 -0
- openrouter/components/{_schema3.py → _schema19.py} +28 -22
- openrouter/components/{_schema0.py → _schema5.py} +7 -5
- openrouter/components/assistantmessage.py +32 -1
- openrouter/components/chatgenerationparams.py +57 -343
- openrouter/components/chatmessagecontentitemimage.py +4 -4
- openrouter/components/chatresponsechoice.py +1 -6
- openrouter/components/chatstreamingmessagechunk.py +3 -3
- openrouter/components/developermessage.py +41 -0
- openrouter/components/message.py +6 -39
- openrouter/components/model.py +7 -1
- openrouter/components/openresponsesrequest.py +31 -39
- openrouter/components/outputmodality.py +1 -0
- openrouter/components/providername.py +2 -0
- openrouter/components/providerpreferences.py +2 -10
- openrouter/components/publicendpoint.py +8 -24
- openrouter/components/publicpricing.py +3 -24
- openrouter/credits.py +86 -14
- openrouter/embeddings.py +92 -20
- openrouter/endpoints.py +62 -2
- openrouter/generations.py +26 -0
- openrouter/guardrails.py +3367 -0
- openrouter/models_.py +120 -12
- openrouter/oauth.py +90 -22
- openrouter/operations/__init__.py +601 -30
- openrouter/operations/bulkassignkeystoguardrail.py +116 -0
- openrouter/operations/bulkassignmemberstoguardrail.py +116 -0
- openrouter/operations/bulkunassignkeysfromguardrail.py +116 -0
- openrouter/operations/bulkunassignmembersfromguardrail.py +116 -0
- openrouter/operations/createauthkeyscode.py +81 -3
- openrouter/operations/createcoinbasecharge.py +82 -2
- openrouter/operations/createembeddings.py +82 -3
- openrouter/operations/createguardrail.py +325 -0
- openrouter/operations/createkeys.py +81 -3
- openrouter/operations/createresponses.py +84 -3
- openrouter/operations/deleteguardrail.py +104 -0
- openrouter/operations/deletekeys.py +69 -3
- openrouter/operations/exchangeauthcodeforapikey.py +81 -3
- openrouter/operations/getcredits.py +70 -1
- openrouter/operations/getcurrentkey.py +81 -3
- openrouter/operations/getgeneration.py +248 -3
- openrouter/operations/getguardrail.py +228 -0
- openrouter/operations/getkey.py +64 -1
- openrouter/operations/getmodels.py +95 -5
- openrouter/operations/getuseractivity.py +62 -1
- openrouter/operations/list.py +63 -1
- openrouter/operations/listembeddingsmodels.py +74 -0
- openrouter/operations/listendpoints.py +65 -2
- openrouter/operations/listendpointszdr.py +70 -2
- openrouter/operations/listguardrailkeyassignments.py +192 -0
- openrouter/operations/listguardrailmemberassignments.py +187 -0
- openrouter/operations/listguardrails.py +238 -0
- openrouter/operations/listkeyassignments.py +180 -0
- openrouter/operations/listmemberassignments.py +175 -0
- openrouter/operations/listmodelscount.py +74 -0
- openrouter/operations/listmodelsuser.py +70 -2
- openrouter/operations/listproviders.py +70 -2
- openrouter/operations/sendchatcompletionrequest.py +87 -3
- openrouter/operations/updateguardrail.py +334 -0
- openrouter/operations/updatekeys.py +63 -0
- openrouter/providers.py +36 -2
- openrouter/responses.py +178 -148
- openrouter/sdk.py +5 -8
- openrouter/types/models.py +378 -0
- {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/METADATA +5 -1
- {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/RECORD +76 -63
- {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/WHEEL +1 -1
- openrouter/completions.py +0 -361
- openrouter/components/completionchoice.py +0 -82
- openrouter/components/completioncreateparams.py +0 -277
- openrouter/components/completionlogprobs.py +0 -54
- openrouter/components/completionresponse.py +0 -46
- openrouter/components/completionusage.py +0 -19
- openrouter/operations/getparameters.py +0 -123
- openrouter/parameters.py +0 -237
- {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/licenses/LICENSE +0 -0
- {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,334 @@
|
|
|
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
|
+
PathParamMetadata,
|
|
16
|
+
RequestMetadata,
|
|
17
|
+
validate_open_enum,
|
|
18
|
+
)
|
|
19
|
+
import pydantic
|
|
20
|
+
from pydantic import model_serializer
|
|
21
|
+
from pydantic.functional_validators import PlainValidator
|
|
22
|
+
from typing import List, Literal, Optional, Union
|
|
23
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class UpdateGuardrailGlobalsTypedDict(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 UpdateGuardrailGlobals(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
|
+
|
|
59
|
+
UpdateGuardrailResetIntervalRequest = Union[
|
|
60
|
+
Literal[
|
|
61
|
+
"daily",
|
|
62
|
+
"weekly",
|
|
63
|
+
"monthly",
|
|
64
|
+
],
|
|
65
|
+
UnrecognizedStr,
|
|
66
|
+
]
|
|
67
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class UpdateGuardrailRequestBodyTypedDict(TypedDict):
|
|
71
|
+
name: NotRequired[str]
|
|
72
|
+
r"""New name for the guardrail"""
|
|
73
|
+
description: NotRequired[Nullable[str]]
|
|
74
|
+
r"""New description for the guardrail"""
|
|
75
|
+
limit_usd: NotRequired[Nullable[float]]
|
|
76
|
+
r"""New spending limit in USD"""
|
|
77
|
+
reset_interval: NotRequired[Nullable[UpdateGuardrailResetIntervalRequest]]
|
|
78
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
79
|
+
allowed_providers: NotRequired[Nullable[List[str]]]
|
|
80
|
+
r"""New list of allowed provider IDs"""
|
|
81
|
+
allowed_models: NotRequired[Nullable[List[str]]]
|
|
82
|
+
r"""Array of model identifiers (slug or canonical_slug accepted)"""
|
|
83
|
+
enforce_zdr: NotRequired[Nullable[bool]]
|
|
84
|
+
r"""Whether to enforce zero data retention"""
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class UpdateGuardrailRequestBody(BaseModel):
|
|
88
|
+
name: Optional[str] = None
|
|
89
|
+
r"""New name for the guardrail"""
|
|
90
|
+
|
|
91
|
+
description: OptionalNullable[str] = UNSET
|
|
92
|
+
r"""New description for the guardrail"""
|
|
93
|
+
|
|
94
|
+
limit_usd: OptionalNullable[float] = UNSET
|
|
95
|
+
r"""New spending limit in USD"""
|
|
96
|
+
|
|
97
|
+
reset_interval: Annotated[
|
|
98
|
+
OptionalNullable[UpdateGuardrailResetIntervalRequest],
|
|
99
|
+
PlainValidator(validate_open_enum(False)),
|
|
100
|
+
] = UNSET
|
|
101
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
102
|
+
|
|
103
|
+
allowed_providers: OptionalNullable[List[str]] = UNSET
|
|
104
|
+
r"""New list of allowed provider IDs"""
|
|
105
|
+
|
|
106
|
+
allowed_models: OptionalNullable[List[str]] = UNSET
|
|
107
|
+
r"""Array of model identifiers (slug or canonical_slug accepted)"""
|
|
108
|
+
|
|
109
|
+
enforce_zdr: OptionalNullable[bool] = UNSET
|
|
110
|
+
r"""Whether to enforce zero data retention"""
|
|
111
|
+
|
|
112
|
+
@model_serializer(mode="wrap")
|
|
113
|
+
def serialize_model(self, handler):
|
|
114
|
+
optional_fields = [
|
|
115
|
+
"name",
|
|
116
|
+
"description",
|
|
117
|
+
"limit_usd",
|
|
118
|
+
"reset_interval",
|
|
119
|
+
"allowed_providers",
|
|
120
|
+
"allowed_models",
|
|
121
|
+
"enforce_zdr",
|
|
122
|
+
]
|
|
123
|
+
nullable_fields = [
|
|
124
|
+
"description",
|
|
125
|
+
"limit_usd",
|
|
126
|
+
"reset_interval",
|
|
127
|
+
"allowed_providers",
|
|
128
|
+
"allowed_models",
|
|
129
|
+
"enforce_zdr",
|
|
130
|
+
]
|
|
131
|
+
null_default_fields = []
|
|
132
|
+
|
|
133
|
+
serialized = handler(self)
|
|
134
|
+
|
|
135
|
+
m = {}
|
|
136
|
+
|
|
137
|
+
for n, f in type(self).model_fields.items():
|
|
138
|
+
k = f.alias or n
|
|
139
|
+
val = serialized.get(k)
|
|
140
|
+
serialized.pop(k, None)
|
|
141
|
+
|
|
142
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
143
|
+
is_set = (
|
|
144
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
145
|
+
or k in null_default_fields
|
|
146
|
+
) # pylint: disable=no-member
|
|
147
|
+
|
|
148
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
149
|
+
m[k] = val
|
|
150
|
+
elif val != UNSET_SENTINEL and (
|
|
151
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
152
|
+
):
|
|
153
|
+
m[k] = val
|
|
154
|
+
|
|
155
|
+
return m
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class UpdateGuardrailRequestTypedDict(TypedDict):
|
|
159
|
+
id: str
|
|
160
|
+
r"""The unique identifier of the guardrail to update"""
|
|
161
|
+
request_body: UpdateGuardrailRequestBodyTypedDict
|
|
162
|
+
http_referer: NotRequired[str]
|
|
163
|
+
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
164
|
+
This is used to track API usage per application.
|
|
165
|
+
|
|
166
|
+
"""
|
|
167
|
+
x_title: NotRequired[str]
|
|
168
|
+
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
169
|
+
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class UpdateGuardrailRequest(BaseModel):
|
|
174
|
+
id: Annotated[
|
|
175
|
+
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
|
176
|
+
]
|
|
177
|
+
r"""The unique identifier of the guardrail to update"""
|
|
178
|
+
|
|
179
|
+
request_body: Annotated[
|
|
180
|
+
UpdateGuardrailRequestBody,
|
|
181
|
+
FieldMetadata(request=RequestMetadata(media_type="application/json")),
|
|
182
|
+
]
|
|
183
|
+
|
|
184
|
+
http_referer: Annotated[
|
|
185
|
+
Optional[str],
|
|
186
|
+
pydantic.Field(alias="HTTP-Referer"),
|
|
187
|
+
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
|
188
|
+
] = None
|
|
189
|
+
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
190
|
+
This is used to track API usage per application.
|
|
191
|
+
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
x_title: Annotated[
|
|
195
|
+
Optional[str],
|
|
196
|
+
pydantic.Field(alias="X-Title"),
|
|
197
|
+
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
|
198
|
+
] = None
|
|
199
|
+
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
200
|
+
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
UpdateGuardrailResetIntervalResponse = Union[
|
|
205
|
+
Literal[
|
|
206
|
+
"daily",
|
|
207
|
+
"weekly",
|
|
208
|
+
"monthly",
|
|
209
|
+
],
|
|
210
|
+
UnrecognizedStr,
|
|
211
|
+
]
|
|
212
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
class UpdateGuardrailDataTypedDict(TypedDict):
|
|
216
|
+
r"""The updated guardrail"""
|
|
217
|
+
|
|
218
|
+
id: str
|
|
219
|
+
r"""Unique identifier for the guardrail"""
|
|
220
|
+
name: str
|
|
221
|
+
r"""Name of the guardrail"""
|
|
222
|
+
created_at: str
|
|
223
|
+
r"""ISO 8601 timestamp of when the guardrail was created"""
|
|
224
|
+
description: NotRequired[Nullable[str]]
|
|
225
|
+
r"""Description of the guardrail"""
|
|
226
|
+
limit_usd: NotRequired[Nullable[float]]
|
|
227
|
+
r"""Spending limit in USD"""
|
|
228
|
+
reset_interval: NotRequired[Nullable[UpdateGuardrailResetIntervalResponse]]
|
|
229
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
230
|
+
allowed_providers: NotRequired[Nullable[List[str]]]
|
|
231
|
+
r"""List of allowed provider IDs"""
|
|
232
|
+
allowed_models: NotRequired[Nullable[List[str]]]
|
|
233
|
+
r"""Array of model canonical_slugs (immutable identifiers)"""
|
|
234
|
+
enforce_zdr: NotRequired[Nullable[bool]]
|
|
235
|
+
r"""Whether to enforce zero data retention"""
|
|
236
|
+
updated_at: NotRequired[Nullable[str]]
|
|
237
|
+
r"""ISO 8601 timestamp of when the guardrail was last updated"""
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
class UpdateGuardrailData(BaseModel):
|
|
241
|
+
r"""The updated guardrail"""
|
|
242
|
+
|
|
243
|
+
id: str
|
|
244
|
+
r"""Unique identifier for the guardrail"""
|
|
245
|
+
|
|
246
|
+
name: str
|
|
247
|
+
r"""Name of the guardrail"""
|
|
248
|
+
|
|
249
|
+
created_at: str
|
|
250
|
+
r"""ISO 8601 timestamp of when the guardrail was created"""
|
|
251
|
+
|
|
252
|
+
description: OptionalNullable[str] = UNSET
|
|
253
|
+
r"""Description of the guardrail"""
|
|
254
|
+
|
|
255
|
+
limit_usd: OptionalNullable[float] = UNSET
|
|
256
|
+
r"""Spending limit in USD"""
|
|
257
|
+
|
|
258
|
+
reset_interval: Annotated[
|
|
259
|
+
OptionalNullable[UpdateGuardrailResetIntervalResponse],
|
|
260
|
+
PlainValidator(validate_open_enum(False)),
|
|
261
|
+
] = UNSET
|
|
262
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
263
|
+
|
|
264
|
+
allowed_providers: OptionalNullable[List[str]] = UNSET
|
|
265
|
+
r"""List of allowed provider IDs"""
|
|
266
|
+
|
|
267
|
+
allowed_models: OptionalNullable[List[str]] = UNSET
|
|
268
|
+
r"""Array of model canonical_slugs (immutable identifiers)"""
|
|
269
|
+
|
|
270
|
+
enforce_zdr: OptionalNullable[bool] = UNSET
|
|
271
|
+
r"""Whether to enforce zero data retention"""
|
|
272
|
+
|
|
273
|
+
updated_at: OptionalNullable[str] = UNSET
|
|
274
|
+
r"""ISO 8601 timestamp of when the guardrail was last updated"""
|
|
275
|
+
|
|
276
|
+
@model_serializer(mode="wrap")
|
|
277
|
+
def serialize_model(self, handler):
|
|
278
|
+
optional_fields = [
|
|
279
|
+
"description",
|
|
280
|
+
"limit_usd",
|
|
281
|
+
"reset_interval",
|
|
282
|
+
"allowed_providers",
|
|
283
|
+
"allowed_models",
|
|
284
|
+
"enforce_zdr",
|
|
285
|
+
"updated_at",
|
|
286
|
+
]
|
|
287
|
+
nullable_fields = [
|
|
288
|
+
"description",
|
|
289
|
+
"limit_usd",
|
|
290
|
+
"reset_interval",
|
|
291
|
+
"allowed_providers",
|
|
292
|
+
"allowed_models",
|
|
293
|
+
"enforce_zdr",
|
|
294
|
+
"updated_at",
|
|
295
|
+
]
|
|
296
|
+
null_default_fields = []
|
|
297
|
+
|
|
298
|
+
serialized = handler(self)
|
|
299
|
+
|
|
300
|
+
m = {}
|
|
301
|
+
|
|
302
|
+
for n, f in type(self).model_fields.items():
|
|
303
|
+
k = f.alias or n
|
|
304
|
+
val = serialized.get(k)
|
|
305
|
+
serialized.pop(k, None)
|
|
306
|
+
|
|
307
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
308
|
+
is_set = (
|
|
309
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
310
|
+
or k in null_default_fields
|
|
311
|
+
) # pylint: disable=no-member
|
|
312
|
+
|
|
313
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
314
|
+
m[k] = val
|
|
315
|
+
elif val != UNSET_SENTINEL and (
|
|
316
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
317
|
+
):
|
|
318
|
+
m[k] = val
|
|
319
|
+
|
|
320
|
+
return m
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
class UpdateGuardrailResponseTypedDict(TypedDict):
|
|
324
|
+
r"""Guardrail updated successfully"""
|
|
325
|
+
|
|
326
|
+
data: UpdateGuardrailDataTypedDict
|
|
327
|
+
r"""The updated guardrail"""
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
class UpdateGuardrailResponse(BaseModel):
|
|
331
|
+
r"""Guardrail updated successfully"""
|
|
332
|
+
|
|
333
|
+
data: UpdateGuardrailData
|
|
334
|
+
r"""The updated guardrail"""
|
|
@@ -12,16 +12,51 @@ from openrouter.types import (
|
|
|
12
12
|
)
|
|
13
13
|
from openrouter.utils import (
|
|
14
14
|
FieldMetadata,
|
|
15
|
+
HeaderMetadata,
|
|
15
16
|
PathParamMetadata,
|
|
16
17
|
RequestMetadata,
|
|
17
18
|
validate_open_enum,
|
|
18
19
|
)
|
|
20
|
+
import pydantic
|
|
19
21
|
from pydantic import model_serializer
|
|
20
22
|
from pydantic.functional_validators import PlainValidator
|
|
21
23
|
from typing import Literal, Optional, Union
|
|
22
24
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
23
25
|
|
|
24
26
|
|
|
27
|
+
class UpdateKeysGlobalsTypedDict(TypedDict):
|
|
28
|
+
http_referer: NotRequired[str]
|
|
29
|
+
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
30
|
+
This is used to track API usage per application.
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
x_title: NotRequired[str]
|
|
34
|
+
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
35
|
+
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class UpdateKeysGlobals(BaseModel):
|
|
40
|
+
http_referer: Annotated[
|
|
41
|
+
Optional[str],
|
|
42
|
+
pydantic.Field(alias="HTTP-Referer"),
|
|
43
|
+
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
|
44
|
+
] = None
|
|
45
|
+
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
46
|
+
This is used to track API usage per application.
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
x_title: Annotated[
|
|
51
|
+
Optional[str],
|
|
52
|
+
pydantic.Field(alias="X-Title"),
|
|
53
|
+
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
|
54
|
+
] = None
|
|
55
|
+
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
56
|
+
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
|
|
25
60
|
UpdateKeysLimitReset = Union[
|
|
26
61
|
Literal[
|
|
27
62
|
"daily",
|
|
@@ -106,6 +141,15 @@ class UpdateKeysRequestTypedDict(TypedDict):
|
|
|
106
141
|
hash: str
|
|
107
142
|
r"""The hash identifier of the API key to update"""
|
|
108
143
|
request_body: UpdateKeysRequestBodyTypedDict
|
|
144
|
+
http_referer: NotRequired[str]
|
|
145
|
+
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
146
|
+
This is used to track API usage per application.
|
|
147
|
+
|
|
148
|
+
"""
|
|
149
|
+
x_title: NotRequired[str]
|
|
150
|
+
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
151
|
+
|
|
152
|
+
"""
|
|
109
153
|
|
|
110
154
|
|
|
111
155
|
class UpdateKeysRequest(BaseModel):
|
|
@@ -119,6 +163,25 @@ class UpdateKeysRequest(BaseModel):
|
|
|
119
163
|
FieldMetadata(request=RequestMetadata(media_type="application/json")),
|
|
120
164
|
]
|
|
121
165
|
|
|
166
|
+
http_referer: Annotated[
|
|
167
|
+
Optional[str],
|
|
168
|
+
pydantic.Field(alias="HTTP-Referer"),
|
|
169
|
+
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
|
170
|
+
] = None
|
|
171
|
+
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
172
|
+
This is used to track API usage per application.
|
|
173
|
+
|
|
174
|
+
"""
|
|
175
|
+
|
|
176
|
+
x_title: Annotated[
|
|
177
|
+
Optional[str],
|
|
178
|
+
pydantic.Field(alias="X-Title"),
|
|
179
|
+
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
|
180
|
+
] = None
|
|
181
|
+
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
182
|
+
|
|
183
|
+
"""
|
|
184
|
+
|
|
122
185
|
|
|
123
186
|
class UpdateKeysDataTypedDict(TypedDict):
|
|
124
187
|
r"""The updated API key information"""
|
openrouter/providers.py
CHANGED
|
@@ -15,6 +15,8 @@ class Providers(BaseSDK):
|
|
|
15
15
|
def list(
|
|
16
16
|
self,
|
|
17
17
|
*,
|
|
18
|
+
http_referer: Optional[str] = None,
|
|
19
|
+
x_title: Optional[str] = None,
|
|
18
20
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
19
21
|
server_url: Optional[str] = None,
|
|
20
22
|
timeout_ms: Optional[int] = None,
|
|
@@ -22,6 +24,11 @@ class Providers(BaseSDK):
|
|
|
22
24
|
) -> operations.ListProvidersResponse:
|
|
23
25
|
r"""List all providers
|
|
24
26
|
|
|
27
|
+
:param http_referer: 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
|
+
:param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
31
|
+
|
|
25
32
|
:param retries: Override the default retry configuration for this method
|
|
26
33
|
:param server_url: Override the default server URL for this method
|
|
27
34
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -36,18 +43,28 @@ class Providers(BaseSDK):
|
|
|
36
43
|
base_url = server_url
|
|
37
44
|
else:
|
|
38
45
|
base_url = self._get_url(base_url, url_variables)
|
|
46
|
+
|
|
47
|
+
request = operations.ListProvidersRequest(
|
|
48
|
+
http_referer=http_referer,
|
|
49
|
+
x_title=x_title,
|
|
50
|
+
)
|
|
51
|
+
|
|
39
52
|
req = self._build_request(
|
|
40
53
|
method="GET",
|
|
41
54
|
path="/providers",
|
|
42
55
|
base_url=base_url,
|
|
43
56
|
url_variables=url_variables,
|
|
44
|
-
request=
|
|
57
|
+
request=request,
|
|
45
58
|
request_body_required=False,
|
|
46
59
|
request_has_path_params=False,
|
|
47
60
|
request_has_query_params=True,
|
|
48
61
|
user_agent_header="user-agent",
|
|
49
62
|
accept_header_value="application/json",
|
|
50
63
|
http_headers=http_headers,
|
|
64
|
+
_globals=operations.ListProvidersGlobals(
|
|
65
|
+
http_referer=self.sdk_configuration.globals.http_referer,
|
|
66
|
+
x_title=self.sdk_configuration.globals.x_title,
|
|
67
|
+
),
|
|
51
68
|
security=self.sdk_configuration.security,
|
|
52
69
|
allow_empty_value=None,
|
|
53
70
|
timeout_ms=timeout_ms,
|
|
@@ -100,6 +117,8 @@ class Providers(BaseSDK):
|
|
|
100
117
|
async def list_async(
|
|
101
118
|
self,
|
|
102
119
|
*,
|
|
120
|
+
http_referer: Optional[str] = None,
|
|
121
|
+
x_title: Optional[str] = None,
|
|
103
122
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
104
123
|
server_url: Optional[str] = None,
|
|
105
124
|
timeout_ms: Optional[int] = None,
|
|
@@ -107,6 +126,11 @@ class Providers(BaseSDK):
|
|
|
107
126
|
) -> operations.ListProvidersResponse:
|
|
108
127
|
r"""List all providers
|
|
109
128
|
|
|
129
|
+
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
130
|
+
This is used to track API usage per application.
|
|
131
|
+
|
|
132
|
+
:param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
133
|
+
|
|
110
134
|
:param retries: Override the default retry configuration for this method
|
|
111
135
|
:param server_url: Override the default server URL for this method
|
|
112
136
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -121,18 +145,28 @@ class Providers(BaseSDK):
|
|
|
121
145
|
base_url = server_url
|
|
122
146
|
else:
|
|
123
147
|
base_url = self._get_url(base_url, url_variables)
|
|
148
|
+
|
|
149
|
+
request = operations.ListProvidersRequest(
|
|
150
|
+
http_referer=http_referer,
|
|
151
|
+
x_title=x_title,
|
|
152
|
+
)
|
|
153
|
+
|
|
124
154
|
req = self._build_request_async(
|
|
125
155
|
method="GET",
|
|
126
156
|
path="/providers",
|
|
127
157
|
base_url=base_url,
|
|
128
158
|
url_variables=url_variables,
|
|
129
|
-
request=
|
|
159
|
+
request=request,
|
|
130
160
|
request_body_required=False,
|
|
131
161
|
request_has_path_params=False,
|
|
132
162
|
request_has_query_params=True,
|
|
133
163
|
user_agent_header="user-agent",
|
|
134
164
|
accept_header_value="application/json",
|
|
135
165
|
http_headers=http_headers,
|
|
166
|
+
_globals=operations.ListProvidersGlobals(
|
|
167
|
+
http_referer=self.sdk_configuration.globals.http_referer,
|
|
168
|
+
x_title=self.sdk_configuration.globals.x_title,
|
|
169
|
+
),
|
|
136
170
|
security=self.sdk_configuration.security,
|
|
137
171
|
allow_empty_value=None,
|
|
138
172
|
timeout_ms=timeout_ms,
|