openrouter 0.1.2__py3-none-any.whl → 0.1.3__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 +2 -2
- openrouter/api_keys.py +20 -0
- openrouter/components/__init__.py +46 -34
- openrouter/components/{_schema3.py → _schema2.py} +22 -22
- openrouter/components/assistantmessage.py +32 -1
- openrouter/components/chatmessagecontentitemimage.py +4 -4
- openrouter/components/chatresponsechoice.py +1 -6
- openrouter/components/chatstreamingmessagechunk.py +3 -3
- openrouter/components/model.py +7 -1
- openrouter/components/outputmodality.py +1 -0
- openrouter/components/publicendpoint.py +10 -0
- openrouter/components/publicpricing.py +5 -0
- openrouter/credits.py +2 -2
- openrouter/guardrails.py +3017 -0
- openrouter/models_.py +4 -4
- openrouter/operations/__init__.py +281 -30
- openrouter/operations/bulkassignkeystoguardrail.py +49 -0
- openrouter/operations/bulkassignmemberstoguardrail.py +49 -0
- openrouter/operations/bulkunassignkeysfromguardrail.py +49 -0
- openrouter/operations/bulkunassignmembersfromguardrail.py +49 -0
- openrouter/operations/createguardrail.py +247 -0
- openrouter/operations/deleteguardrail.py +38 -0
- openrouter/operations/getguardrail.py +161 -0
- openrouter/operations/getmodels.py +28 -5
- openrouter/operations/listguardrailkeyassignments.py +125 -0
- openrouter/operations/listguardrailmemberassignments.py +120 -0
- openrouter/operations/listguardrails.py +171 -0
- openrouter/operations/listkeyassignments.py +118 -0
- openrouter/operations/listmemberassignments.py +113 -0
- openrouter/operations/updateguardrail.py +271 -0
- openrouter/sdk.py +4 -4
- openrouter/types/models.py +378 -0
- {openrouter-0.1.2.dist-info → openrouter-0.1.3.dist-info}/METADATA +1 -1
- {openrouter-0.1.2.dist-info → openrouter-0.1.3.dist-info}/RECORD +38 -25
- openrouter/operations/getparameters.py +0 -123
- openrouter/parameters.py +0 -237
- {openrouter-0.1.2.dist-info → openrouter-0.1.3.dist-info}/WHEEL +0 -0
- {openrouter-0.1.2.dist-info → openrouter-0.1.3.dist-info}/licenses/LICENSE +0 -0
- {openrouter-0.1.2.dist-info → openrouter-0.1.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
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 openrouter.utils import FieldMetadata, PathParamMetadata, RequestMetadata
|
|
6
|
+
from typing import List
|
|
7
|
+
from typing_extensions import Annotated, TypedDict
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BulkUnassignMembersFromGuardrailRequestBodyTypedDict(TypedDict):
|
|
11
|
+
member_user_ids: List[str]
|
|
12
|
+
r"""Array of member user IDs to unassign from the guardrail"""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class BulkUnassignMembersFromGuardrailRequestBody(BaseModel):
|
|
16
|
+
member_user_ids: List[str]
|
|
17
|
+
r"""Array of member user IDs to unassign from the guardrail"""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class BulkUnassignMembersFromGuardrailRequestTypedDict(TypedDict):
|
|
21
|
+
id: str
|
|
22
|
+
r"""The unique identifier of the guardrail"""
|
|
23
|
+
request_body: BulkUnassignMembersFromGuardrailRequestBodyTypedDict
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class BulkUnassignMembersFromGuardrailRequest(BaseModel):
|
|
27
|
+
id: Annotated[
|
|
28
|
+
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
|
29
|
+
]
|
|
30
|
+
r"""The unique identifier of the guardrail"""
|
|
31
|
+
|
|
32
|
+
request_body: Annotated[
|
|
33
|
+
BulkUnassignMembersFromGuardrailRequestBody,
|
|
34
|
+
FieldMetadata(request=RequestMetadata(media_type="application/json")),
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class BulkUnassignMembersFromGuardrailResponseTypedDict(TypedDict):
|
|
39
|
+
r"""Unassignment result"""
|
|
40
|
+
|
|
41
|
+
unassigned_count: float
|
|
42
|
+
r"""Number of members successfully unassigned"""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class BulkUnassignMembersFromGuardrailResponse(BaseModel):
|
|
46
|
+
r"""Unassignment result"""
|
|
47
|
+
|
|
48
|
+
unassigned_count: float
|
|
49
|
+
r"""Number of members successfully unassigned"""
|
|
@@ -0,0 +1,247 @@
|
|
|
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 validate_open_enum
|
|
13
|
+
from pydantic import model_serializer
|
|
14
|
+
from pydantic.functional_validators import PlainValidator
|
|
15
|
+
from typing import List, Literal, Union
|
|
16
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
CreateGuardrailResetIntervalRequest = Union[
|
|
20
|
+
Literal[
|
|
21
|
+
"daily",
|
|
22
|
+
"weekly",
|
|
23
|
+
"monthly",
|
|
24
|
+
],
|
|
25
|
+
UnrecognizedStr,
|
|
26
|
+
]
|
|
27
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class CreateGuardrailRequestTypedDict(TypedDict):
|
|
31
|
+
name: str
|
|
32
|
+
r"""Name for the new guardrail"""
|
|
33
|
+
description: NotRequired[Nullable[str]]
|
|
34
|
+
r"""Description of the guardrail"""
|
|
35
|
+
limit_usd: NotRequired[Nullable[float]]
|
|
36
|
+
r"""Spending limit in USD"""
|
|
37
|
+
reset_interval: NotRequired[Nullable[CreateGuardrailResetIntervalRequest]]
|
|
38
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
39
|
+
allowed_providers: NotRequired[Nullable[List[str]]]
|
|
40
|
+
r"""List of allowed provider IDs"""
|
|
41
|
+
allowed_models: NotRequired[Nullable[List[str]]]
|
|
42
|
+
r"""Array of model identifiers (slug or canonical_slug accepted)"""
|
|
43
|
+
enforce_zdr: NotRequired[Nullable[bool]]
|
|
44
|
+
r"""Whether to enforce zero data retention"""
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class CreateGuardrailRequest(BaseModel):
|
|
48
|
+
name: str
|
|
49
|
+
r"""Name for the new guardrail"""
|
|
50
|
+
|
|
51
|
+
description: OptionalNullable[str] = UNSET
|
|
52
|
+
r"""Description of the guardrail"""
|
|
53
|
+
|
|
54
|
+
limit_usd: OptionalNullable[float] = UNSET
|
|
55
|
+
r"""Spending limit in USD"""
|
|
56
|
+
|
|
57
|
+
reset_interval: Annotated[
|
|
58
|
+
OptionalNullable[CreateGuardrailResetIntervalRequest],
|
|
59
|
+
PlainValidator(validate_open_enum(False)),
|
|
60
|
+
] = UNSET
|
|
61
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
62
|
+
|
|
63
|
+
allowed_providers: OptionalNullable[List[str]] = UNSET
|
|
64
|
+
r"""List of allowed provider IDs"""
|
|
65
|
+
|
|
66
|
+
allowed_models: OptionalNullable[List[str]] = UNSET
|
|
67
|
+
r"""Array of model identifiers (slug or canonical_slug accepted)"""
|
|
68
|
+
|
|
69
|
+
enforce_zdr: OptionalNullable[bool] = UNSET
|
|
70
|
+
r"""Whether to enforce zero data retention"""
|
|
71
|
+
|
|
72
|
+
@model_serializer(mode="wrap")
|
|
73
|
+
def serialize_model(self, handler):
|
|
74
|
+
optional_fields = [
|
|
75
|
+
"description",
|
|
76
|
+
"limit_usd",
|
|
77
|
+
"reset_interval",
|
|
78
|
+
"allowed_providers",
|
|
79
|
+
"allowed_models",
|
|
80
|
+
"enforce_zdr",
|
|
81
|
+
]
|
|
82
|
+
nullable_fields = [
|
|
83
|
+
"description",
|
|
84
|
+
"limit_usd",
|
|
85
|
+
"reset_interval",
|
|
86
|
+
"allowed_providers",
|
|
87
|
+
"allowed_models",
|
|
88
|
+
"enforce_zdr",
|
|
89
|
+
]
|
|
90
|
+
null_default_fields = []
|
|
91
|
+
|
|
92
|
+
serialized = handler(self)
|
|
93
|
+
|
|
94
|
+
m = {}
|
|
95
|
+
|
|
96
|
+
for n, f in type(self).model_fields.items():
|
|
97
|
+
k = f.alias or n
|
|
98
|
+
val = serialized.get(k)
|
|
99
|
+
serialized.pop(k, None)
|
|
100
|
+
|
|
101
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
102
|
+
is_set = (
|
|
103
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
104
|
+
or k in null_default_fields
|
|
105
|
+
) # pylint: disable=no-member
|
|
106
|
+
|
|
107
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
108
|
+
m[k] = val
|
|
109
|
+
elif val != UNSET_SENTINEL and (
|
|
110
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
111
|
+
):
|
|
112
|
+
m[k] = val
|
|
113
|
+
|
|
114
|
+
return m
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
CreateGuardrailResetIntervalResponse = Union[
|
|
118
|
+
Literal[
|
|
119
|
+
"daily",
|
|
120
|
+
"weekly",
|
|
121
|
+
"monthly",
|
|
122
|
+
],
|
|
123
|
+
UnrecognizedStr,
|
|
124
|
+
]
|
|
125
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class CreateGuardrailDataTypedDict(TypedDict):
|
|
129
|
+
r"""The created guardrail"""
|
|
130
|
+
|
|
131
|
+
id: str
|
|
132
|
+
r"""Unique identifier for the guardrail"""
|
|
133
|
+
name: str
|
|
134
|
+
r"""Name of the guardrail"""
|
|
135
|
+
created_at: str
|
|
136
|
+
r"""ISO 8601 timestamp of when the guardrail was created"""
|
|
137
|
+
description: NotRequired[Nullable[str]]
|
|
138
|
+
r"""Description of the guardrail"""
|
|
139
|
+
limit_usd: NotRequired[Nullable[float]]
|
|
140
|
+
r"""Spending limit in USD"""
|
|
141
|
+
reset_interval: NotRequired[Nullable[CreateGuardrailResetIntervalResponse]]
|
|
142
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
143
|
+
allowed_providers: NotRequired[Nullable[List[str]]]
|
|
144
|
+
r"""List of allowed provider IDs"""
|
|
145
|
+
allowed_models: NotRequired[Nullable[List[str]]]
|
|
146
|
+
r"""Array of model canonical_slugs (immutable identifiers)"""
|
|
147
|
+
enforce_zdr: NotRequired[Nullable[bool]]
|
|
148
|
+
r"""Whether to enforce zero data retention"""
|
|
149
|
+
updated_at: NotRequired[Nullable[str]]
|
|
150
|
+
r"""ISO 8601 timestamp of when the guardrail was last updated"""
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class CreateGuardrailData(BaseModel):
|
|
154
|
+
r"""The created guardrail"""
|
|
155
|
+
|
|
156
|
+
id: str
|
|
157
|
+
r"""Unique identifier for the guardrail"""
|
|
158
|
+
|
|
159
|
+
name: str
|
|
160
|
+
r"""Name of the guardrail"""
|
|
161
|
+
|
|
162
|
+
created_at: str
|
|
163
|
+
r"""ISO 8601 timestamp of when the guardrail was created"""
|
|
164
|
+
|
|
165
|
+
description: OptionalNullable[str] = UNSET
|
|
166
|
+
r"""Description of the guardrail"""
|
|
167
|
+
|
|
168
|
+
limit_usd: OptionalNullable[float] = UNSET
|
|
169
|
+
r"""Spending limit in USD"""
|
|
170
|
+
|
|
171
|
+
reset_interval: Annotated[
|
|
172
|
+
OptionalNullable[CreateGuardrailResetIntervalResponse],
|
|
173
|
+
PlainValidator(validate_open_enum(False)),
|
|
174
|
+
] = UNSET
|
|
175
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
176
|
+
|
|
177
|
+
allowed_providers: OptionalNullable[List[str]] = UNSET
|
|
178
|
+
r"""List of allowed provider IDs"""
|
|
179
|
+
|
|
180
|
+
allowed_models: OptionalNullable[List[str]] = UNSET
|
|
181
|
+
r"""Array of model canonical_slugs (immutable identifiers)"""
|
|
182
|
+
|
|
183
|
+
enforce_zdr: OptionalNullable[bool] = UNSET
|
|
184
|
+
r"""Whether to enforce zero data retention"""
|
|
185
|
+
|
|
186
|
+
updated_at: OptionalNullable[str] = UNSET
|
|
187
|
+
r"""ISO 8601 timestamp of when the guardrail was last updated"""
|
|
188
|
+
|
|
189
|
+
@model_serializer(mode="wrap")
|
|
190
|
+
def serialize_model(self, handler):
|
|
191
|
+
optional_fields = [
|
|
192
|
+
"description",
|
|
193
|
+
"limit_usd",
|
|
194
|
+
"reset_interval",
|
|
195
|
+
"allowed_providers",
|
|
196
|
+
"allowed_models",
|
|
197
|
+
"enforce_zdr",
|
|
198
|
+
"updated_at",
|
|
199
|
+
]
|
|
200
|
+
nullable_fields = [
|
|
201
|
+
"description",
|
|
202
|
+
"limit_usd",
|
|
203
|
+
"reset_interval",
|
|
204
|
+
"allowed_providers",
|
|
205
|
+
"allowed_models",
|
|
206
|
+
"enforce_zdr",
|
|
207
|
+
"updated_at",
|
|
208
|
+
]
|
|
209
|
+
null_default_fields = []
|
|
210
|
+
|
|
211
|
+
serialized = handler(self)
|
|
212
|
+
|
|
213
|
+
m = {}
|
|
214
|
+
|
|
215
|
+
for n, f in type(self).model_fields.items():
|
|
216
|
+
k = f.alias or n
|
|
217
|
+
val = serialized.get(k)
|
|
218
|
+
serialized.pop(k, None)
|
|
219
|
+
|
|
220
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
221
|
+
is_set = (
|
|
222
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
223
|
+
or k in null_default_fields
|
|
224
|
+
) # pylint: disable=no-member
|
|
225
|
+
|
|
226
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
227
|
+
m[k] = val
|
|
228
|
+
elif val != UNSET_SENTINEL and (
|
|
229
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
230
|
+
):
|
|
231
|
+
m[k] = val
|
|
232
|
+
|
|
233
|
+
return m
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
class CreateGuardrailResponseTypedDict(TypedDict):
|
|
237
|
+
r"""Guardrail created successfully"""
|
|
238
|
+
|
|
239
|
+
data: CreateGuardrailDataTypedDict
|
|
240
|
+
r"""The created guardrail"""
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
class CreateGuardrailResponse(BaseModel):
|
|
244
|
+
r"""Guardrail created successfully"""
|
|
245
|
+
|
|
246
|
+
data: CreateGuardrailData
|
|
247
|
+
r"""The created guardrail"""
|
|
@@ -0,0 +1,38 @@
|
|
|
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 openrouter.utils import FieldMetadata, PathParamMetadata, validate_const
|
|
6
|
+
import pydantic
|
|
7
|
+
from pydantic.functional_validators import AfterValidator
|
|
8
|
+
from typing import Literal
|
|
9
|
+
from typing_extensions import Annotated, TypedDict
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DeleteGuardrailRequestTypedDict(TypedDict):
|
|
13
|
+
id: str
|
|
14
|
+
r"""The unique identifier of the guardrail to delete"""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class DeleteGuardrailRequest(BaseModel):
|
|
18
|
+
id: Annotated[
|
|
19
|
+
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
|
20
|
+
]
|
|
21
|
+
r"""The unique identifier of the guardrail to delete"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class DeleteGuardrailResponseTypedDict(TypedDict):
|
|
25
|
+
r"""Guardrail deleted successfully"""
|
|
26
|
+
|
|
27
|
+
deleted: Literal[True]
|
|
28
|
+
r"""Confirmation that the guardrail was deleted"""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class DeleteGuardrailResponse(BaseModel):
|
|
32
|
+
r"""Guardrail deleted successfully"""
|
|
33
|
+
|
|
34
|
+
DELETED: Annotated[
|
|
35
|
+
Annotated[Literal[True], AfterValidator(validate_const(True))],
|
|
36
|
+
pydantic.Field(alias="deleted"),
|
|
37
|
+
] = True
|
|
38
|
+
r"""Confirmation that the guardrail was deleted"""
|
|
@@ -0,0 +1,161 @@
|
|
|
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 FieldMetadata, PathParamMetadata, validate_open_enum
|
|
13
|
+
from pydantic import model_serializer
|
|
14
|
+
from pydantic.functional_validators import PlainValidator
|
|
15
|
+
from typing import List, Literal, Union
|
|
16
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class GetGuardrailRequestTypedDict(TypedDict):
|
|
20
|
+
id: str
|
|
21
|
+
r"""The unique identifier of the guardrail to retrieve"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class GetGuardrailRequest(BaseModel):
|
|
25
|
+
id: Annotated[
|
|
26
|
+
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
|
27
|
+
]
|
|
28
|
+
r"""The unique identifier of the guardrail to retrieve"""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
GetGuardrailResetInterval = Union[
|
|
32
|
+
Literal[
|
|
33
|
+
"daily",
|
|
34
|
+
"weekly",
|
|
35
|
+
"monthly",
|
|
36
|
+
],
|
|
37
|
+
UnrecognizedStr,
|
|
38
|
+
]
|
|
39
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class GetGuardrailDataTypedDict(TypedDict):
|
|
43
|
+
r"""The guardrail"""
|
|
44
|
+
|
|
45
|
+
id: str
|
|
46
|
+
r"""Unique identifier for the guardrail"""
|
|
47
|
+
name: str
|
|
48
|
+
r"""Name of the guardrail"""
|
|
49
|
+
created_at: str
|
|
50
|
+
r"""ISO 8601 timestamp of when the guardrail was created"""
|
|
51
|
+
description: NotRequired[Nullable[str]]
|
|
52
|
+
r"""Description of the guardrail"""
|
|
53
|
+
limit_usd: NotRequired[Nullable[float]]
|
|
54
|
+
r"""Spending limit in USD"""
|
|
55
|
+
reset_interval: NotRequired[Nullable[GetGuardrailResetInterval]]
|
|
56
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
57
|
+
allowed_providers: NotRequired[Nullable[List[str]]]
|
|
58
|
+
r"""List of allowed provider IDs"""
|
|
59
|
+
allowed_models: NotRequired[Nullable[List[str]]]
|
|
60
|
+
r"""Array of model canonical_slugs (immutable identifiers)"""
|
|
61
|
+
enforce_zdr: NotRequired[Nullable[bool]]
|
|
62
|
+
r"""Whether to enforce zero data retention"""
|
|
63
|
+
updated_at: NotRequired[Nullable[str]]
|
|
64
|
+
r"""ISO 8601 timestamp of when the guardrail was last updated"""
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class GetGuardrailData(BaseModel):
|
|
68
|
+
r"""The guardrail"""
|
|
69
|
+
|
|
70
|
+
id: str
|
|
71
|
+
r"""Unique identifier for the guardrail"""
|
|
72
|
+
|
|
73
|
+
name: str
|
|
74
|
+
r"""Name of the guardrail"""
|
|
75
|
+
|
|
76
|
+
created_at: str
|
|
77
|
+
r"""ISO 8601 timestamp of when the guardrail was created"""
|
|
78
|
+
|
|
79
|
+
description: OptionalNullable[str] = UNSET
|
|
80
|
+
r"""Description of the guardrail"""
|
|
81
|
+
|
|
82
|
+
limit_usd: OptionalNullable[float] = UNSET
|
|
83
|
+
r"""Spending limit in USD"""
|
|
84
|
+
|
|
85
|
+
reset_interval: Annotated[
|
|
86
|
+
OptionalNullable[GetGuardrailResetInterval],
|
|
87
|
+
PlainValidator(validate_open_enum(False)),
|
|
88
|
+
] = UNSET
|
|
89
|
+
r"""Interval at which the limit resets (daily, weekly, monthly)"""
|
|
90
|
+
|
|
91
|
+
allowed_providers: OptionalNullable[List[str]] = UNSET
|
|
92
|
+
r"""List of allowed provider IDs"""
|
|
93
|
+
|
|
94
|
+
allowed_models: OptionalNullable[List[str]] = UNSET
|
|
95
|
+
r"""Array of model canonical_slugs (immutable identifiers)"""
|
|
96
|
+
|
|
97
|
+
enforce_zdr: OptionalNullable[bool] = UNSET
|
|
98
|
+
r"""Whether to enforce zero data retention"""
|
|
99
|
+
|
|
100
|
+
updated_at: OptionalNullable[str] = UNSET
|
|
101
|
+
r"""ISO 8601 timestamp of when the guardrail was last updated"""
|
|
102
|
+
|
|
103
|
+
@model_serializer(mode="wrap")
|
|
104
|
+
def serialize_model(self, handler):
|
|
105
|
+
optional_fields = [
|
|
106
|
+
"description",
|
|
107
|
+
"limit_usd",
|
|
108
|
+
"reset_interval",
|
|
109
|
+
"allowed_providers",
|
|
110
|
+
"allowed_models",
|
|
111
|
+
"enforce_zdr",
|
|
112
|
+
"updated_at",
|
|
113
|
+
]
|
|
114
|
+
nullable_fields = [
|
|
115
|
+
"description",
|
|
116
|
+
"limit_usd",
|
|
117
|
+
"reset_interval",
|
|
118
|
+
"allowed_providers",
|
|
119
|
+
"allowed_models",
|
|
120
|
+
"enforce_zdr",
|
|
121
|
+
"updated_at",
|
|
122
|
+
]
|
|
123
|
+
null_default_fields = []
|
|
124
|
+
|
|
125
|
+
serialized = handler(self)
|
|
126
|
+
|
|
127
|
+
m = {}
|
|
128
|
+
|
|
129
|
+
for n, f in type(self).model_fields.items():
|
|
130
|
+
k = f.alias or n
|
|
131
|
+
val = serialized.get(k)
|
|
132
|
+
serialized.pop(k, None)
|
|
133
|
+
|
|
134
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
135
|
+
is_set = (
|
|
136
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
137
|
+
or k in null_default_fields
|
|
138
|
+
) # pylint: disable=no-member
|
|
139
|
+
|
|
140
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
141
|
+
m[k] = val
|
|
142
|
+
elif val != UNSET_SENTINEL and (
|
|
143
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
144
|
+
):
|
|
145
|
+
m[k] = val
|
|
146
|
+
|
|
147
|
+
return m
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class GetGuardrailResponseTypedDict(TypedDict):
|
|
151
|
+
r"""Guardrail details"""
|
|
152
|
+
|
|
153
|
+
data: GetGuardrailDataTypedDict
|
|
154
|
+
r"""The guardrail"""
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class GetGuardrailResponse(BaseModel):
|
|
158
|
+
r"""Guardrail details"""
|
|
159
|
+
|
|
160
|
+
data: GetGuardrailData
|
|
161
|
+
r"""The guardrail"""
|
|
@@ -1,22 +1,45 @@
|
|
|
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 FieldMetadata, QueryParamMetadata
|
|
6
|
-
from
|
|
4
|
+
from openrouter.types import BaseModel, UnrecognizedStr
|
|
5
|
+
from openrouter.utils import FieldMetadata, QueryParamMetadata, validate_open_enum
|
|
6
|
+
from pydantic.functional_validators import PlainValidator
|
|
7
|
+
from typing import Literal, Optional, Union
|
|
7
8
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
Category = Union[
|
|
12
|
+
Literal[
|
|
13
|
+
"programming",
|
|
14
|
+
"roleplay",
|
|
15
|
+
"marketing",
|
|
16
|
+
"marketing/seo",
|
|
17
|
+
"technology",
|
|
18
|
+
"science",
|
|
19
|
+
"translation",
|
|
20
|
+
"legal",
|
|
21
|
+
"finance",
|
|
22
|
+
"health",
|
|
23
|
+
"trivia",
|
|
24
|
+
"academia",
|
|
25
|
+
],
|
|
26
|
+
UnrecognizedStr,
|
|
27
|
+
]
|
|
28
|
+
r"""Filter models by use case category"""
|
|
29
|
+
|
|
30
|
+
|
|
10
31
|
class GetModelsRequestTypedDict(TypedDict):
|
|
11
|
-
category: NotRequired[
|
|
32
|
+
category: NotRequired[Category]
|
|
33
|
+
r"""Filter models by use case category"""
|
|
12
34
|
supported_parameters: NotRequired[str]
|
|
13
35
|
|
|
14
36
|
|
|
15
37
|
class GetModelsRequest(BaseModel):
|
|
16
38
|
category: Annotated[
|
|
17
|
-
Optional[
|
|
39
|
+
Annotated[Optional[Category], PlainValidator(validate_open_enum(False))],
|
|
18
40
|
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
|
19
41
|
] = None
|
|
42
|
+
r"""Filter models by use case category"""
|
|
20
43
|
|
|
21
44
|
supported_parameters: Annotated[
|
|
22
45
|
Optional[str],
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
|
5
|
+
from openrouter.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
|
|
6
|
+
from pydantic import model_serializer
|
|
7
|
+
from typing import List, Optional
|
|
8
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ListGuardrailKeyAssignmentsRequestTypedDict(TypedDict):
|
|
12
|
+
id: str
|
|
13
|
+
r"""The unique identifier of the guardrail"""
|
|
14
|
+
offset: NotRequired[str]
|
|
15
|
+
r"""Number of records to skip for pagination"""
|
|
16
|
+
limit: NotRequired[str]
|
|
17
|
+
r"""Maximum number of records to return (max 100)"""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ListGuardrailKeyAssignmentsRequest(BaseModel):
|
|
21
|
+
id: Annotated[
|
|
22
|
+
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
|
23
|
+
]
|
|
24
|
+
r"""The unique identifier of the guardrail"""
|
|
25
|
+
|
|
26
|
+
offset: Annotated[
|
|
27
|
+
Optional[str],
|
|
28
|
+
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
|
29
|
+
] = None
|
|
30
|
+
r"""Number of records to skip for pagination"""
|
|
31
|
+
|
|
32
|
+
limit: Annotated[
|
|
33
|
+
Optional[str],
|
|
34
|
+
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
|
35
|
+
] = None
|
|
36
|
+
r"""Maximum number of records to return (max 100)"""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ListGuardrailKeyAssignmentsDataTypedDict(TypedDict):
|
|
40
|
+
id: str
|
|
41
|
+
r"""Unique identifier for the assignment"""
|
|
42
|
+
key_hash: str
|
|
43
|
+
r"""Hash of the assigned API key"""
|
|
44
|
+
guardrail_id: str
|
|
45
|
+
r"""ID of the guardrail"""
|
|
46
|
+
key_name: str
|
|
47
|
+
r"""Name of the API key"""
|
|
48
|
+
key_label: str
|
|
49
|
+
r"""Label of the API key"""
|
|
50
|
+
assigned_by: Nullable[str]
|
|
51
|
+
r"""User ID of who made the assignment"""
|
|
52
|
+
created_at: str
|
|
53
|
+
r"""ISO 8601 timestamp of when the assignment was created"""
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class ListGuardrailKeyAssignmentsData(BaseModel):
|
|
57
|
+
id: str
|
|
58
|
+
r"""Unique identifier for the assignment"""
|
|
59
|
+
|
|
60
|
+
key_hash: str
|
|
61
|
+
r"""Hash of the assigned API key"""
|
|
62
|
+
|
|
63
|
+
guardrail_id: str
|
|
64
|
+
r"""ID of the guardrail"""
|
|
65
|
+
|
|
66
|
+
key_name: str
|
|
67
|
+
r"""Name of the API key"""
|
|
68
|
+
|
|
69
|
+
key_label: str
|
|
70
|
+
r"""Label of the API key"""
|
|
71
|
+
|
|
72
|
+
assigned_by: Nullable[str]
|
|
73
|
+
r"""User ID of who made the assignment"""
|
|
74
|
+
|
|
75
|
+
created_at: str
|
|
76
|
+
r"""ISO 8601 timestamp of when the assignment was created"""
|
|
77
|
+
|
|
78
|
+
@model_serializer(mode="wrap")
|
|
79
|
+
def serialize_model(self, handler):
|
|
80
|
+
optional_fields = []
|
|
81
|
+
nullable_fields = ["assigned_by"]
|
|
82
|
+
null_default_fields = []
|
|
83
|
+
|
|
84
|
+
serialized = handler(self)
|
|
85
|
+
|
|
86
|
+
m = {}
|
|
87
|
+
|
|
88
|
+
for n, f in type(self).model_fields.items():
|
|
89
|
+
k = f.alias or n
|
|
90
|
+
val = serialized.get(k)
|
|
91
|
+
serialized.pop(k, None)
|
|
92
|
+
|
|
93
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
94
|
+
is_set = (
|
|
95
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
96
|
+
or k in null_default_fields
|
|
97
|
+
) # pylint: disable=no-member
|
|
98
|
+
|
|
99
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
100
|
+
m[k] = val
|
|
101
|
+
elif val != UNSET_SENTINEL and (
|
|
102
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
103
|
+
):
|
|
104
|
+
m[k] = val
|
|
105
|
+
|
|
106
|
+
return m
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class ListGuardrailKeyAssignmentsResponseTypedDict(TypedDict):
|
|
110
|
+
r"""List of key assignments"""
|
|
111
|
+
|
|
112
|
+
data: List[ListGuardrailKeyAssignmentsDataTypedDict]
|
|
113
|
+
r"""List of key assignments"""
|
|
114
|
+
total_count: float
|
|
115
|
+
r"""Total number of key assignments for this guardrail"""
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class ListGuardrailKeyAssignmentsResponse(BaseModel):
|
|
119
|
+
r"""List of key assignments"""
|
|
120
|
+
|
|
121
|
+
data: List[ListGuardrailKeyAssignmentsData]
|
|
122
|
+
r"""List of key assignments"""
|
|
123
|
+
|
|
124
|
+
total_count: float
|
|
125
|
+
r"""Total number of key assignments for this guardrail"""
|