openrouter 0.0.18__py3-none-any.whl → 0.0.19__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 +3 -3
- openrouter/analytics.py +0 -2
- openrouter/api_keys.py +4 -24
- openrouter/basesdk.py +0 -6
- openrouter/chat.py +14 -212
- openrouter/completions.py +0 -2
- openrouter/components/__init__.py +105 -447
- openrouter/components/chatgenerationparams.py +17 -559
- openrouter/components/chatgenerationtokenusage.py +0 -3
- openrouter/components/chatmessagecontentitem.py +1 -1
- openrouter/components/chatmessagecontentitemaudio.py +25 -6
- openrouter/components/chatmessagecontentitemtext.py +2 -9
- openrouter/components/chatmessagecontentitemvideo.py +5 -9
- openrouter/components/chatmessagetokenlogprob.py +4 -4
- openrouter/components/chatresponsechoice.py +67 -6
- openrouter/components/chatstreamingmessagechunk.py +1 -12
- openrouter/components/chatstreamingresponsechunk.py +1 -1
- openrouter/components/completionchoice.py +5 -18
- openrouter/components/completioncreateparams.py +10 -10
- openrouter/components/completionresponse.py +0 -3
- openrouter/components/message.py +9 -10
- openrouter/components/openairesponsesannotation.py +4 -11
- openrouter/components/openairesponsesreasoningeffort.py +0 -1
- openrouter/components/openresponseseasyinputmessage.py +20 -93
- openrouter/components/openresponsesinput.py +2 -2
- openrouter/components/openresponsesinputmessageitem.py +14 -87
- openrouter/components/openresponsesnonstreamingresponse.py +19 -33
- openrouter/components/openresponsesreasoning.py +0 -1
- openrouter/components/openresponsesrequest.py +119 -246
- openrouter/components/openresponsesstreamevent.py +39 -110
- openrouter/components/outputmessage.py +4 -10
- openrouter/components/parameter.py +0 -1
- openrouter/components/providername.py +2 -10
- openrouter/components/providersort.py +1 -0
- openrouter/components/publicendpoint.py +49 -60
- openrouter/components/publicpricing.py +49 -49
- openrouter/components/responseformattextconfig.py +7 -9
- openrouter/components/responseoutputtext.py +1 -36
- openrouter/components/responsesoutputitem.py +11 -13
- openrouter/components/responsesoutputitemreasoning.py +3 -43
- openrouter/components/responsesoutputmessage.py +5 -10
- openrouter/credits.py +0 -4
- openrouter/embeddings.py +8 -10
- openrouter/endpoints.py +0 -4
- openrouter/generations.py +0 -2
- openrouter/models_.py +0 -6
- openrouter/oauth.py +0 -4
- openrouter/operations/__init__.py +34 -10
- openrouter/operations/createembeddings.py +247 -16
- openrouter/operations/getcredits.py +0 -19
- openrouter/operations/getgeneration.py +0 -6
- openrouter/operations/getparameters.py +71 -5
- openrouter/operations/updatekeys.py +2 -2
- openrouter/parameters.py +2 -4
- openrouter/providers.py +0 -2
- openrouter/responses.py +36 -188
- openrouter/sdk.py +0 -13
- openrouter/sdkconfiguration.py +0 -2
- openrouter/utils/forms.py +10 -21
- openrouter/utils/queryparams.py +2 -14
- openrouter/utils/retries.py +5 -69
- {openrouter-0.0.18.dist-info → openrouter-0.0.19.dist-info}/METADATA +1 -1
- {openrouter-0.0.18.dist-info → openrouter-0.0.19.dist-info}/RECORD +66 -87
- openrouter/components/_schema0.py +0 -94
- openrouter/components/_schema3.py +0 -229
- openrouter/components/chatcompletionfinishreason.py +0 -17
- openrouter/components/chatmessagecontentitemcachecontrol.py +0 -32
- openrouter/components/chatstreamingchoice.py +0 -72
- openrouter/components/pdfparserengine.py +0 -16
- openrouter/components/pdfparseroptions.py +0 -25
- openrouter/components/percentilelatencycutoffs.py +0 -71
- openrouter/components/percentilestats.py +0 -34
- openrouter/components/percentilethroughputcutoffs.py +0 -71
- openrouter/components/preferredmaxlatency.py +0 -21
- openrouter/components/preferredminthroughput.py +0 -22
- openrouter/components/providerpreferences.py +0 -355
- openrouter/components/providersortconfig.py +0 -71
- openrouter/components/providersortunion.py +0 -23
- openrouter/components/responseinputvideo.py +0 -26
- openrouter/components/responsesoutputmodality.py +0 -14
- openrouter/components/websearchengine.py +0 -15
- openrouter/models/__init__.py +0 -3
- openrouter/models/internal/__init__.py +0 -54
- openrouter/models/internal/globals.py +0 -41
- {openrouter-0.0.18.dist-info → openrouter-0.0.19.dist-info}/WHEEL +0 -0
- {openrouter-0.0.18.dist-info → openrouter-0.0.19.dist-info}/licenses/LICENSE +0 -0
- {openrouter-0.0.18.dist-info → openrouter-0.0.19.dist-info}/top_level.txt +0 -0
|
@@ -3,24 +3,16 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .responseinputaudio import ResponseInputAudio, ResponseInputAudioTypedDict
|
|
5
5
|
from .responseinputfile import ResponseInputFile, ResponseInputFileTypedDict
|
|
6
|
+
from .responseinputimage import ResponseInputImage, ResponseInputImageTypedDict
|
|
6
7
|
from .responseinputtext import ResponseInputText, ResponseInputTextTypedDict
|
|
7
|
-
from .
|
|
8
|
-
from openrouter.
|
|
9
|
-
|
|
10
|
-
Nullable,
|
|
11
|
-
OptionalNullable,
|
|
12
|
-
UNSET,
|
|
13
|
-
UNSET_SENTINEL,
|
|
14
|
-
UnrecognizedStr,
|
|
15
|
-
)
|
|
16
|
-
from openrouter.utils import get_discriminator, validate_open_enum
|
|
17
|
-
from pydantic import Discriminator, Tag, model_serializer
|
|
18
|
-
from pydantic.functional_validators import PlainValidator
|
|
8
|
+
from openrouter.types import BaseModel
|
|
9
|
+
from openrouter.utils import get_discriminator
|
|
10
|
+
from pydantic import Discriminator, Tag
|
|
19
11
|
from typing import List, Literal, Optional, Union
|
|
20
12
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
21
13
|
|
|
22
14
|
|
|
23
|
-
|
|
15
|
+
OpenResponsesInputMessageItemType = Literal["message",]
|
|
24
16
|
|
|
25
17
|
|
|
26
18
|
OpenResponsesInputMessageItemRoleDeveloper = Literal["developer",]
|
|
@@ -52,88 +44,23 @@ OpenResponsesInputMessageItemRoleUnion = TypeAliasType(
|
|
|
52
44
|
)
|
|
53
45
|
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
OpenResponsesInputMessageItemDetail = Union[
|
|
59
|
-
Literal[
|
|
60
|
-
"auto",
|
|
61
|
-
"high",
|
|
62
|
-
"low",
|
|
63
|
-
],
|
|
64
|
-
UnrecognizedStr,
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
class OpenResponsesInputMessageItemContentInputImageTypedDict(TypedDict):
|
|
69
|
-
r"""Image input content item"""
|
|
70
|
-
|
|
71
|
-
type: OpenResponsesInputMessageItemContentType
|
|
72
|
-
detail: OpenResponsesInputMessageItemDetail
|
|
73
|
-
image_url: NotRequired[Nullable[str]]
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
class OpenResponsesInputMessageItemContentInputImage(BaseModel):
|
|
77
|
-
r"""Image input content item"""
|
|
78
|
-
|
|
79
|
-
type: OpenResponsesInputMessageItemContentType
|
|
80
|
-
|
|
81
|
-
detail: Annotated[
|
|
82
|
-
OpenResponsesInputMessageItemDetail, PlainValidator(validate_open_enum(False))
|
|
83
|
-
]
|
|
84
|
-
|
|
85
|
-
image_url: OptionalNullable[str] = UNSET
|
|
86
|
-
|
|
87
|
-
@model_serializer(mode="wrap")
|
|
88
|
-
def serialize_model(self, handler):
|
|
89
|
-
optional_fields = ["image_url"]
|
|
90
|
-
nullable_fields = ["image_url"]
|
|
91
|
-
null_default_fields = []
|
|
92
|
-
|
|
93
|
-
serialized = handler(self)
|
|
94
|
-
|
|
95
|
-
m = {}
|
|
96
|
-
|
|
97
|
-
for n, f in type(self).model_fields.items():
|
|
98
|
-
k = f.alias or n
|
|
99
|
-
val = serialized.get(k)
|
|
100
|
-
serialized.pop(k, None)
|
|
101
|
-
|
|
102
|
-
optional_nullable = k in optional_fields and k in nullable_fields
|
|
103
|
-
is_set = (
|
|
104
|
-
self.__pydantic_fields_set__.intersection({n})
|
|
105
|
-
or k in null_default_fields
|
|
106
|
-
) # pylint: disable=no-member
|
|
107
|
-
|
|
108
|
-
if val is not None and val != UNSET_SENTINEL:
|
|
109
|
-
m[k] = val
|
|
110
|
-
elif val != UNSET_SENTINEL and (
|
|
111
|
-
not k in optional_fields or (optional_nullable and is_set)
|
|
112
|
-
):
|
|
113
|
-
m[k] = val
|
|
114
|
-
|
|
115
|
-
return m
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
OpenResponsesInputMessageItemContentUnionTypedDict = TypeAliasType(
|
|
119
|
-
"OpenResponsesInputMessageItemContentUnionTypedDict",
|
|
47
|
+
OpenResponsesInputMessageItemContentTypedDict = TypeAliasType(
|
|
48
|
+
"OpenResponsesInputMessageItemContentTypedDict",
|
|
120
49
|
Union[
|
|
121
50
|
ResponseInputTextTypedDict,
|
|
122
51
|
ResponseInputAudioTypedDict,
|
|
123
|
-
|
|
124
|
-
OpenResponsesInputMessageItemContentInputImageTypedDict,
|
|
52
|
+
ResponseInputImageTypedDict,
|
|
125
53
|
ResponseInputFileTypedDict,
|
|
126
54
|
],
|
|
127
55
|
)
|
|
128
56
|
|
|
129
57
|
|
|
130
|
-
|
|
58
|
+
OpenResponsesInputMessageItemContent = Annotated[
|
|
131
59
|
Union[
|
|
132
60
|
Annotated[ResponseInputText, Tag("input_text")],
|
|
133
|
-
Annotated[
|
|
61
|
+
Annotated[ResponseInputImage, Tag("input_image")],
|
|
134
62
|
Annotated[ResponseInputFile, Tag("input_file")],
|
|
135
63
|
Annotated[ResponseInputAudio, Tag("input_audio")],
|
|
136
|
-
Annotated[ResponseInputVideo, Tag("input_video")],
|
|
137
64
|
],
|
|
138
65
|
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
|
139
66
|
]
|
|
@@ -141,16 +68,16 @@ OpenResponsesInputMessageItemContentUnion = Annotated[
|
|
|
141
68
|
|
|
142
69
|
class OpenResponsesInputMessageItemTypedDict(TypedDict):
|
|
143
70
|
role: OpenResponsesInputMessageItemRoleUnionTypedDict
|
|
144
|
-
content: List[
|
|
71
|
+
content: List[OpenResponsesInputMessageItemContentTypedDict]
|
|
145
72
|
id: NotRequired[str]
|
|
146
|
-
type: NotRequired[
|
|
73
|
+
type: NotRequired[OpenResponsesInputMessageItemType]
|
|
147
74
|
|
|
148
75
|
|
|
149
76
|
class OpenResponsesInputMessageItem(BaseModel):
|
|
150
77
|
role: OpenResponsesInputMessageItemRoleUnion
|
|
151
78
|
|
|
152
|
-
content: List[
|
|
79
|
+
content: List[OpenResponsesInputMessageItemContent]
|
|
153
80
|
|
|
154
81
|
id: Optional[str] = None
|
|
155
82
|
|
|
156
|
-
type: Optional[
|
|
83
|
+
type: Optional[OpenResponsesInputMessageItemType] = None
|
|
@@ -48,8 +48,8 @@ from openrouter.types import (
|
|
|
48
48
|
UNSET,
|
|
49
49
|
UNSET_SENTINEL,
|
|
50
50
|
)
|
|
51
|
-
from openrouter.utils import
|
|
52
|
-
from pydantic import
|
|
51
|
+
from openrouter.utils import validate_open_enum
|
|
52
|
+
from pydantic import model_serializer
|
|
53
53
|
from pydantic.functional_validators import PlainValidator
|
|
54
54
|
from typing import Any, Dict, List, Literal, Optional, Union
|
|
55
55
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
@@ -127,19 +127,16 @@ OpenResponsesNonStreamingResponseToolUnionTypedDict = TypeAliasType(
|
|
|
127
127
|
)
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
OpenResponsesNonStreamingResponseToolUnion =
|
|
130
|
+
OpenResponsesNonStreamingResponseToolUnion = TypeAliasType(
|
|
131
|
+
"OpenResponsesNonStreamingResponseToolUnion",
|
|
131
132
|
Union[
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
],
|
|
138
|
-
Annotated[OpenResponsesWebSearchTool, Tag("web_search")],
|
|
139
|
-
Annotated[OpenResponsesWebSearch20250826Tool, Tag("web_search_2025_08_26")],
|
|
133
|
+
OpenResponsesWebSearchPreviewTool,
|
|
134
|
+
OpenResponsesWebSearchPreview20250311Tool,
|
|
135
|
+
OpenResponsesWebSearchTool,
|
|
136
|
+
OpenResponsesWebSearch20250826Tool,
|
|
137
|
+
OpenResponsesNonStreamingResponseToolFunction,
|
|
140
138
|
],
|
|
141
|
-
|
|
142
|
-
]
|
|
139
|
+
)
|
|
143
140
|
|
|
144
141
|
|
|
145
142
|
class OpenResponsesNonStreamingResponseTypedDict(TypedDict):
|
|
@@ -149,27 +146,24 @@ class OpenResponsesNonStreamingResponseTypedDict(TypedDict):
|
|
|
149
146
|
object: Object
|
|
150
147
|
created_at: float
|
|
151
148
|
model: str
|
|
152
|
-
status: OpenAIResponsesResponseStatus
|
|
153
|
-
completed_at: Nullable[float]
|
|
154
149
|
output: List[ResponsesOutputItemTypedDict]
|
|
155
150
|
error: Nullable[ResponsesErrorFieldTypedDict]
|
|
156
151
|
r"""Error information returned from the API"""
|
|
157
152
|
incomplete_details: Nullable[OpenAIResponsesIncompleteDetailsTypedDict]
|
|
158
153
|
temperature: Nullable[float]
|
|
159
154
|
top_p: Nullable[float]
|
|
160
|
-
presence_penalty: Nullable[float]
|
|
161
|
-
frequency_penalty: Nullable[float]
|
|
162
155
|
instructions: Nullable[OpenAIResponsesInputUnionTypedDict]
|
|
163
156
|
metadata: Nullable[Dict[str, str]]
|
|
164
157
|
r"""Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed."""
|
|
165
158
|
tools: List[OpenResponsesNonStreamingResponseToolUnionTypedDict]
|
|
166
159
|
tool_choice: OpenAIResponsesToolChoiceUnionTypedDict
|
|
167
160
|
parallel_tool_calls: bool
|
|
161
|
+
status: NotRequired[OpenAIResponsesResponseStatus]
|
|
168
162
|
user: NotRequired[Nullable[str]]
|
|
169
163
|
output_text: NotRequired[str]
|
|
170
164
|
prompt_cache_key: NotRequired[Nullable[str]]
|
|
171
165
|
safety_identifier: NotRequired[Nullable[str]]
|
|
172
|
-
usage: NotRequired[
|
|
166
|
+
usage: NotRequired[OpenResponsesUsageTypedDict]
|
|
173
167
|
r"""Token usage information for the response"""
|
|
174
168
|
max_tool_calls: NotRequired[Nullable[float]]
|
|
175
169
|
top_logprobs: NotRequired[float]
|
|
@@ -196,12 +190,6 @@ class OpenResponsesNonStreamingResponse(BaseModel):
|
|
|
196
190
|
|
|
197
191
|
model: str
|
|
198
192
|
|
|
199
|
-
status: Annotated[
|
|
200
|
-
OpenAIResponsesResponseStatus, PlainValidator(validate_open_enum(False))
|
|
201
|
-
]
|
|
202
|
-
|
|
203
|
-
completed_at: Nullable[float]
|
|
204
|
-
|
|
205
193
|
output: List[ResponsesOutputItem]
|
|
206
194
|
|
|
207
195
|
error: Nullable[ResponsesErrorField]
|
|
@@ -213,10 +201,6 @@ class OpenResponsesNonStreamingResponse(BaseModel):
|
|
|
213
201
|
|
|
214
202
|
top_p: Nullable[float]
|
|
215
203
|
|
|
216
|
-
presence_penalty: Nullable[float]
|
|
217
|
-
|
|
218
|
-
frequency_penalty: Nullable[float]
|
|
219
|
-
|
|
220
204
|
instructions: Nullable[OpenAIResponsesInputUnion]
|
|
221
205
|
|
|
222
206
|
metadata: Nullable[Dict[str, str]]
|
|
@@ -228,6 +212,11 @@ class OpenResponsesNonStreamingResponse(BaseModel):
|
|
|
228
212
|
|
|
229
213
|
parallel_tool_calls: bool
|
|
230
214
|
|
|
215
|
+
status: Annotated[
|
|
216
|
+
Optional[OpenAIResponsesResponseStatus],
|
|
217
|
+
PlainValidator(validate_open_enum(False)),
|
|
218
|
+
] = None
|
|
219
|
+
|
|
231
220
|
user: OptionalNullable[str] = UNSET
|
|
232
221
|
|
|
233
222
|
output_text: Optional[str] = None
|
|
@@ -236,7 +225,7 @@ class OpenResponsesNonStreamingResponse(BaseModel):
|
|
|
236
225
|
|
|
237
226
|
safety_identifier: OptionalNullable[str] = UNSET
|
|
238
227
|
|
|
239
|
-
usage:
|
|
228
|
+
usage: Optional[OpenResponsesUsage] = None
|
|
240
229
|
r"""Token usage information for the response"""
|
|
241
230
|
|
|
242
231
|
max_tool_calls: OptionalNullable[float] = UNSET
|
|
@@ -271,6 +260,7 @@ class OpenResponsesNonStreamingResponse(BaseModel):
|
|
|
271
260
|
@model_serializer(mode="wrap")
|
|
272
261
|
def serialize_model(self, handler):
|
|
273
262
|
optional_fields = [
|
|
263
|
+
"status",
|
|
274
264
|
"user",
|
|
275
265
|
"output_text",
|
|
276
266
|
"prompt_cache_key",
|
|
@@ -289,19 +279,15 @@ class OpenResponsesNonStreamingResponse(BaseModel):
|
|
|
289
279
|
"text",
|
|
290
280
|
]
|
|
291
281
|
nullable_fields = [
|
|
292
|
-
"completed_at",
|
|
293
282
|
"user",
|
|
294
283
|
"prompt_cache_key",
|
|
295
284
|
"safety_identifier",
|
|
296
285
|
"error",
|
|
297
286
|
"incomplete_details",
|
|
298
|
-
"usage",
|
|
299
287
|
"max_tool_calls",
|
|
300
288
|
"max_output_tokens",
|
|
301
289
|
"temperature",
|
|
302
290
|
"top_p",
|
|
303
|
-
"presence_penalty",
|
|
304
|
-
"frequency_penalty",
|
|
305
291
|
"instructions",
|
|
306
292
|
"metadata",
|
|
307
293
|
"prompt",
|