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.
Files changed (40) hide show
  1. openrouter/_version.py +2 -2
  2. openrouter/analytics.py +2 -2
  3. openrouter/api_keys.py +20 -0
  4. openrouter/components/__init__.py +46 -34
  5. openrouter/components/{_schema3.py → _schema2.py} +22 -22
  6. openrouter/components/assistantmessage.py +32 -1
  7. openrouter/components/chatmessagecontentitemimage.py +4 -4
  8. openrouter/components/chatresponsechoice.py +1 -6
  9. openrouter/components/chatstreamingmessagechunk.py +3 -3
  10. openrouter/components/model.py +7 -1
  11. openrouter/components/outputmodality.py +1 -0
  12. openrouter/components/publicendpoint.py +10 -0
  13. openrouter/components/publicpricing.py +5 -0
  14. openrouter/credits.py +2 -2
  15. openrouter/guardrails.py +3017 -0
  16. openrouter/models_.py +4 -4
  17. openrouter/operations/__init__.py +281 -30
  18. openrouter/operations/bulkassignkeystoguardrail.py +49 -0
  19. openrouter/operations/bulkassignmemberstoguardrail.py +49 -0
  20. openrouter/operations/bulkunassignkeysfromguardrail.py +49 -0
  21. openrouter/operations/bulkunassignmembersfromguardrail.py +49 -0
  22. openrouter/operations/createguardrail.py +247 -0
  23. openrouter/operations/deleteguardrail.py +38 -0
  24. openrouter/operations/getguardrail.py +161 -0
  25. openrouter/operations/getmodels.py +28 -5
  26. openrouter/operations/listguardrailkeyassignments.py +125 -0
  27. openrouter/operations/listguardrailmemberassignments.py +120 -0
  28. openrouter/operations/listguardrails.py +171 -0
  29. openrouter/operations/listkeyassignments.py +118 -0
  30. openrouter/operations/listmemberassignments.py +113 -0
  31. openrouter/operations/updateguardrail.py +271 -0
  32. openrouter/sdk.py +4 -4
  33. openrouter/types/models.py +378 -0
  34. {openrouter-0.1.2.dist-info → openrouter-0.1.3.dist-info}/METADATA +1 -1
  35. {openrouter-0.1.2.dist-info → openrouter-0.1.3.dist-info}/RECORD +38 -25
  36. openrouter/operations/getparameters.py +0 -123
  37. openrouter/parameters.py +0 -237
  38. {openrouter-0.1.2.dist-info → openrouter-0.1.3.dist-info}/WHEEL +0 -0
  39. {openrouter-0.1.2.dist-info → openrouter-0.1.3.dist-info}/licenses/LICENSE +0 -0
  40. {openrouter-0.1.2.dist-info → openrouter-0.1.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,120 @@
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 ListGuardrailMemberAssignmentsRequestTypedDict(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 ListGuardrailMemberAssignmentsRequest(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 ListGuardrailMemberAssignmentsDataTypedDict(TypedDict):
40
+ id: str
41
+ r"""Unique identifier for the assignment"""
42
+ user_id: str
43
+ r"""Clerk user ID of the assigned member"""
44
+ organization_id: str
45
+ r"""Organization ID"""
46
+ guardrail_id: str
47
+ r"""ID of the guardrail"""
48
+ assigned_by: Nullable[str]
49
+ r"""User ID of who made the assignment"""
50
+ created_at: str
51
+ r"""ISO 8601 timestamp of when the assignment was created"""
52
+
53
+
54
+ class ListGuardrailMemberAssignmentsData(BaseModel):
55
+ id: str
56
+ r"""Unique identifier for the assignment"""
57
+
58
+ user_id: str
59
+ r"""Clerk user ID of the assigned member"""
60
+
61
+ organization_id: str
62
+ r"""Organization ID"""
63
+
64
+ guardrail_id: str
65
+ r"""ID of the guardrail"""
66
+
67
+ assigned_by: Nullable[str]
68
+ r"""User ID of who made the assignment"""
69
+
70
+ created_at: str
71
+ r"""ISO 8601 timestamp of when the assignment was created"""
72
+
73
+ @model_serializer(mode="wrap")
74
+ def serialize_model(self, handler):
75
+ optional_fields = []
76
+ nullable_fields = ["assigned_by"]
77
+ null_default_fields = []
78
+
79
+ serialized = handler(self)
80
+
81
+ m = {}
82
+
83
+ for n, f in type(self).model_fields.items():
84
+ k = f.alias or n
85
+ val = serialized.get(k)
86
+ serialized.pop(k, None)
87
+
88
+ optional_nullable = k in optional_fields and k in nullable_fields
89
+ is_set = (
90
+ self.__pydantic_fields_set__.intersection({n})
91
+ or k in null_default_fields
92
+ ) # pylint: disable=no-member
93
+
94
+ if val is not None and val != UNSET_SENTINEL:
95
+ m[k] = val
96
+ elif val != UNSET_SENTINEL and (
97
+ not k in optional_fields or (optional_nullable and is_set)
98
+ ):
99
+ m[k] = val
100
+
101
+ return m
102
+
103
+
104
+ class ListGuardrailMemberAssignmentsResponseTypedDict(TypedDict):
105
+ r"""List of member assignments"""
106
+
107
+ data: List[ListGuardrailMemberAssignmentsDataTypedDict]
108
+ r"""List of member assignments"""
109
+ total_count: float
110
+ r"""Total number of member assignments"""
111
+
112
+
113
+ class ListGuardrailMemberAssignmentsResponse(BaseModel):
114
+ r"""List of member assignments"""
115
+
116
+ data: List[ListGuardrailMemberAssignmentsData]
117
+ r"""List of member assignments"""
118
+
119
+ total_count: float
120
+ r"""Total number of member assignments"""
@@ -0,0 +1,171 @@
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, QueryParamMetadata, validate_open_enum
13
+ from pydantic import model_serializer
14
+ from pydantic.functional_validators import PlainValidator
15
+ from typing import List, Literal, Optional, Union
16
+ from typing_extensions import Annotated, NotRequired, TypedDict
17
+
18
+
19
+ class ListGuardrailsRequestTypedDict(TypedDict):
20
+ offset: NotRequired[str]
21
+ r"""Number of records to skip for pagination"""
22
+ limit: NotRequired[str]
23
+ r"""Maximum number of records to return (max 100)"""
24
+
25
+
26
+ class ListGuardrailsRequest(BaseModel):
27
+ offset: Annotated[
28
+ Optional[str],
29
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
30
+ ] = None
31
+ r"""Number of records to skip for pagination"""
32
+
33
+ limit: Annotated[
34
+ Optional[str],
35
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
36
+ ] = None
37
+ r"""Maximum number of records to return (max 100)"""
38
+
39
+
40
+ ListGuardrailsResetInterval = Union[
41
+ Literal[
42
+ "daily",
43
+ "weekly",
44
+ "monthly",
45
+ ],
46
+ UnrecognizedStr,
47
+ ]
48
+ r"""Interval at which the limit resets (daily, weekly, monthly)"""
49
+
50
+
51
+ class ListGuardrailsDataTypedDict(TypedDict):
52
+ id: str
53
+ r"""Unique identifier for the guardrail"""
54
+ name: str
55
+ r"""Name of the guardrail"""
56
+ created_at: str
57
+ r"""ISO 8601 timestamp of when the guardrail was created"""
58
+ description: NotRequired[Nullable[str]]
59
+ r"""Description of the guardrail"""
60
+ limit_usd: NotRequired[Nullable[float]]
61
+ r"""Spending limit in USD"""
62
+ reset_interval: NotRequired[Nullable[ListGuardrailsResetInterval]]
63
+ r"""Interval at which the limit resets (daily, weekly, monthly)"""
64
+ allowed_providers: NotRequired[Nullable[List[str]]]
65
+ r"""List of allowed provider IDs"""
66
+ allowed_models: NotRequired[Nullable[List[str]]]
67
+ r"""Array of model canonical_slugs (immutable identifiers)"""
68
+ enforce_zdr: NotRequired[Nullable[bool]]
69
+ r"""Whether to enforce zero data retention"""
70
+ updated_at: NotRequired[Nullable[str]]
71
+ r"""ISO 8601 timestamp of when the guardrail was last updated"""
72
+
73
+
74
+ class ListGuardrailsData(BaseModel):
75
+ id: str
76
+ r"""Unique identifier for the guardrail"""
77
+
78
+ name: str
79
+ r"""Name of the guardrail"""
80
+
81
+ created_at: str
82
+ r"""ISO 8601 timestamp of when the guardrail was created"""
83
+
84
+ description: OptionalNullable[str] = UNSET
85
+ r"""Description of the guardrail"""
86
+
87
+ limit_usd: OptionalNullable[float] = UNSET
88
+ r"""Spending limit in USD"""
89
+
90
+ reset_interval: Annotated[
91
+ OptionalNullable[ListGuardrailsResetInterval],
92
+ PlainValidator(validate_open_enum(False)),
93
+ ] = UNSET
94
+ r"""Interval at which the limit resets (daily, weekly, monthly)"""
95
+
96
+ allowed_providers: OptionalNullable[List[str]] = UNSET
97
+ r"""List of allowed provider IDs"""
98
+
99
+ allowed_models: OptionalNullable[List[str]] = UNSET
100
+ r"""Array of model canonical_slugs (immutable identifiers)"""
101
+
102
+ enforce_zdr: OptionalNullable[bool] = UNSET
103
+ r"""Whether to enforce zero data retention"""
104
+
105
+ updated_at: OptionalNullable[str] = UNSET
106
+ r"""ISO 8601 timestamp of when the guardrail was last updated"""
107
+
108
+ @model_serializer(mode="wrap")
109
+ def serialize_model(self, handler):
110
+ optional_fields = [
111
+ "description",
112
+ "limit_usd",
113
+ "reset_interval",
114
+ "allowed_providers",
115
+ "allowed_models",
116
+ "enforce_zdr",
117
+ "updated_at",
118
+ ]
119
+ nullable_fields = [
120
+ "description",
121
+ "limit_usd",
122
+ "reset_interval",
123
+ "allowed_providers",
124
+ "allowed_models",
125
+ "enforce_zdr",
126
+ "updated_at",
127
+ ]
128
+ null_default_fields = []
129
+
130
+ serialized = handler(self)
131
+
132
+ m = {}
133
+
134
+ for n, f in type(self).model_fields.items():
135
+ k = f.alias or n
136
+ val = serialized.get(k)
137
+ serialized.pop(k, None)
138
+
139
+ optional_nullable = k in optional_fields and k in nullable_fields
140
+ is_set = (
141
+ self.__pydantic_fields_set__.intersection({n})
142
+ or k in null_default_fields
143
+ ) # pylint: disable=no-member
144
+
145
+ if val is not None and val != UNSET_SENTINEL:
146
+ m[k] = val
147
+ elif val != UNSET_SENTINEL and (
148
+ not k in optional_fields or (optional_nullable and is_set)
149
+ ):
150
+ m[k] = val
151
+
152
+ return m
153
+
154
+
155
+ class ListGuardrailsResponseTypedDict(TypedDict):
156
+ r"""List of guardrails"""
157
+
158
+ data: List[ListGuardrailsDataTypedDict]
159
+ r"""List of guardrails"""
160
+ total_count: float
161
+ r"""Total number of guardrails"""
162
+
163
+
164
+ class ListGuardrailsResponse(BaseModel):
165
+ r"""List of guardrails"""
166
+
167
+ data: List[ListGuardrailsData]
168
+ r"""List of guardrails"""
169
+
170
+ total_count: float
171
+ r"""Total number of guardrails"""
@@ -0,0 +1,118 @@
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, 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 ListKeyAssignmentsRequestTypedDict(TypedDict):
12
+ offset: NotRequired[str]
13
+ r"""Number of records to skip for pagination"""
14
+ limit: NotRequired[str]
15
+ r"""Maximum number of records to return (max 100)"""
16
+
17
+
18
+ class ListKeyAssignmentsRequest(BaseModel):
19
+ offset: Annotated[
20
+ Optional[str],
21
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
22
+ ] = None
23
+ r"""Number of records to skip for pagination"""
24
+
25
+ limit: Annotated[
26
+ Optional[str],
27
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
28
+ ] = None
29
+ r"""Maximum number of records to return (max 100)"""
30
+
31
+
32
+ class ListKeyAssignmentsDataTypedDict(TypedDict):
33
+ id: str
34
+ r"""Unique identifier for the assignment"""
35
+ key_hash: str
36
+ r"""Hash of the assigned API key"""
37
+ guardrail_id: str
38
+ r"""ID of the guardrail"""
39
+ key_name: str
40
+ r"""Name of the API key"""
41
+ key_label: str
42
+ r"""Label of the API key"""
43
+ assigned_by: Nullable[str]
44
+ r"""User ID of who made the assignment"""
45
+ created_at: str
46
+ r"""ISO 8601 timestamp of when the assignment was created"""
47
+
48
+
49
+ class ListKeyAssignmentsData(BaseModel):
50
+ id: str
51
+ r"""Unique identifier for the assignment"""
52
+
53
+ key_hash: str
54
+ r"""Hash of the assigned API key"""
55
+
56
+ guardrail_id: str
57
+ r"""ID of the guardrail"""
58
+
59
+ key_name: str
60
+ r"""Name of the API key"""
61
+
62
+ key_label: str
63
+ r"""Label of the API key"""
64
+
65
+ assigned_by: Nullable[str]
66
+ r"""User ID of who made the assignment"""
67
+
68
+ created_at: str
69
+ r"""ISO 8601 timestamp of when the assignment was created"""
70
+
71
+ @model_serializer(mode="wrap")
72
+ def serialize_model(self, handler):
73
+ optional_fields = []
74
+ nullable_fields = ["assigned_by"]
75
+ null_default_fields = []
76
+
77
+ serialized = handler(self)
78
+
79
+ m = {}
80
+
81
+ for n, f in type(self).model_fields.items():
82
+ k = f.alias or n
83
+ val = serialized.get(k)
84
+ serialized.pop(k, None)
85
+
86
+ optional_nullable = k in optional_fields and k in nullable_fields
87
+ is_set = (
88
+ self.__pydantic_fields_set__.intersection({n})
89
+ or k in null_default_fields
90
+ ) # pylint: disable=no-member
91
+
92
+ if val is not None and val != UNSET_SENTINEL:
93
+ m[k] = val
94
+ elif val != UNSET_SENTINEL and (
95
+ not k in optional_fields or (optional_nullable and is_set)
96
+ ):
97
+ m[k] = val
98
+
99
+ return m
100
+
101
+
102
+ class ListKeyAssignmentsResponseTypedDict(TypedDict):
103
+ r"""List of key assignments"""
104
+
105
+ data: List[ListKeyAssignmentsDataTypedDict]
106
+ r"""List of key assignments"""
107
+ total_count: float
108
+ r"""Total number of key assignments for this guardrail"""
109
+
110
+
111
+ class ListKeyAssignmentsResponse(BaseModel):
112
+ r"""List of key assignments"""
113
+
114
+ data: List[ListKeyAssignmentsData]
115
+ r"""List of key assignments"""
116
+
117
+ total_count: float
118
+ r"""Total number of key assignments for this guardrail"""
@@ -0,0 +1,113 @@
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, 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 ListMemberAssignmentsRequestTypedDict(TypedDict):
12
+ offset: NotRequired[str]
13
+ r"""Number of records to skip for pagination"""
14
+ limit: NotRequired[str]
15
+ r"""Maximum number of records to return (max 100)"""
16
+
17
+
18
+ class ListMemberAssignmentsRequest(BaseModel):
19
+ offset: Annotated[
20
+ Optional[str],
21
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
22
+ ] = None
23
+ r"""Number of records to skip for pagination"""
24
+
25
+ limit: Annotated[
26
+ Optional[str],
27
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
28
+ ] = None
29
+ r"""Maximum number of records to return (max 100)"""
30
+
31
+
32
+ class ListMemberAssignmentsDataTypedDict(TypedDict):
33
+ id: str
34
+ r"""Unique identifier for the assignment"""
35
+ user_id: str
36
+ r"""Clerk user ID of the assigned member"""
37
+ organization_id: str
38
+ r"""Organization ID"""
39
+ guardrail_id: str
40
+ r"""ID of the guardrail"""
41
+ assigned_by: Nullable[str]
42
+ r"""User ID of who made the assignment"""
43
+ created_at: str
44
+ r"""ISO 8601 timestamp of when the assignment was created"""
45
+
46
+
47
+ class ListMemberAssignmentsData(BaseModel):
48
+ id: str
49
+ r"""Unique identifier for the assignment"""
50
+
51
+ user_id: str
52
+ r"""Clerk user ID of the assigned member"""
53
+
54
+ organization_id: str
55
+ r"""Organization ID"""
56
+
57
+ guardrail_id: str
58
+ r"""ID of the guardrail"""
59
+
60
+ assigned_by: Nullable[str]
61
+ r"""User ID of who made the assignment"""
62
+
63
+ created_at: str
64
+ r"""ISO 8601 timestamp of when the assignment was created"""
65
+
66
+ @model_serializer(mode="wrap")
67
+ def serialize_model(self, handler):
68
+ optional_fields = []
69
+ nullable_fields = ["assigned_by"]
70
+ null_default_fields = []
71
+
72
+ serialized = handler(self)
73
+
74
+ m = {}
75
+
76
+ for n, f in type(self).model_fields.items():
77
+ k = f.alias or n
78
+ val = serialized.get(k)
79
+ serialized.pop(k, None)
80
+
81
+ optional_nullable = k in optional_fields and k in nullable_fields
82
+ is_set = (
83
+ self.__pydantic_fields_set__.intersection({n})
84
+ or k in null_default_fields
85
+ ) # pylint: disable=no-member
86
+
87
+ if val is not None and val != UNSET_SENTINEL:
88
+ m[k] = val
89
+ elif val != UNSET_SENTINEL and (
90
+ not k in optional_fields or (optional_nullable and is_set)
91
+ ):
92
+ m[k] = val
93
+
94
+ return m
95
+
96
+
97
+ class ListMemberAssignmentsResponseTypedDict(TypedDict):
98
+ r"""List of member assignments"""
99
+
100
+ data: List[ListMemberAssignmentsDataTypedDict]
101
+ r"""List of member assignments"""
102
+ total_count: float
103
+ r"""Total number of member assignments"""
104
+
105
+
106
+ class ListMemberAssignmentsResponse(BaseModel):
107
+ r"""List of member assignments"""
108
+
109
+ data: List[ListMemberAssignmentsData]
110
+ r"""List of member assignments"""
111
+
112
+ total_count: float
113
+ r"""Total number of member assignments"""