openrouter 0.0.16__py3-none-any.whl → 0.0.18__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 +2 -0
- openrouter/api_keys.py +24 -4
- openrouter/basesdk.py +6 -0
- openrouter/chat.py +212 -14
- openrouter/completions.py +2 -0
- openrouter/components/__init__.py +470 -106
- openrouter/components/_schema0.py +94 -0
- openrouter/components/_schema3.py +229 -0
- openrouter/components/chatgenerationparams.py +559 -16
- openrouter/components/chatgenerationtokenusage.py +3 -0
- openrouter/components/chatmessagecontentitem.py +2 -1
- openrouter/components/chatmessagecontentitemaudio.py +6 -25
- openrouter/components/chatmessagecontentitemcachecontrol.py +32 -0
- openrouter/components/chatmessagecontentitemtext.py +9 -2
- openrouter/components/chatmessagecontentitemvideo.py +50 -9
- openrouter/components/chatmessagetokenlogprob.py +4 -4
- openrouter/components/chatresponsechoice.py +6 -1
- openrouter/components/chatstreamingmessagechunk.py +12 -1
- openrouter/components/completionchoice.py +18 -5
- openrouter/components/completioncreateparams.py +10 -10
- openrouter/components/completionresponse.py +3 -0
- openrouter/components/datacollection.py +19 -0
- openrouter/components/message.py +10 -9
- openrouter/components/openairesponsesannotation.py +11 -4
- openrouter/components/openairesponsesreasoningeffort.py +2 -0
- openrouter/components/openresponseseasyinputmessage.py +93 -20
- openrouter/components/openresponsesinput.py +2 -2
- openrouter/components/openresponsesinputmessageitem.py +87 -14
- openrouter/components/openresponsesnonstreamingresponse.py +33 -19
- openrouter/components/openresponsesreasoning.py +2 -0
- openrouter/components/openresponsesrequest.py +246 -142
- openrouter/components/openresponsesstreamevent.py +110 -39
- openrouter/components/outputmessage.py +10 -4
- openrouter/components/parameter.py +1 -0
- openrouter/components/pdfparserengine.py +16 -0
- openrouter/components/pdfparseroptions.py +25 -0
- openrouter/components/percentilelatencycutoffs.py +71 -0
- openrouter/components/percentilestats.py +34 -0
- openrouter/components/percentilethroughputcutoffs.py +71 -0
- openrouter/components/preferredmaxlatency.py +21 -0
- openrouter/components/preferredminthroughput.py +22 -0
- openrouter/components/providername.py +11 -27
- openrouter/components/providerpreferences.py +355 -0
- openrouter/components/providersort.py +15 -0
- openrouter/components/providersortconfig.py +71 -0
- openrouter/components/providersortunion.py +23 -0
- openrouter/components/publicendpoint.py +61 -45
- openrouter/components/publicpricing.py +50 -45
- openrouter/components/responseformattextconfig.py +9 -7
- openrouter/components/responseinputvideo.py +26 -0
- openrouter/components/responseoutputtext.py +36 -1
- openrouter/components/responsesoutputitem.py +13 -11
- openrouter/components/responsesoutputitemreasoning.py +43 -3
- openrouter/components/responsesoutputmessage.py +10 -5
- openrouter/components/responsesoutputmodality.py +14 -0
- openrouter/components/websearchengine.py +15 -0
- openrouter/credits.py +4 -0
- openrouter/embeddings.py +34 -24
- openrouter/endpoints.py +4 -0
- openrouter/generations.py +2 -0
- openrouter/models/__init__.py +3 -0
- openrouter/models/internal/__init__.py +54 -0
- openrouter/models/internal/globals.py +41 -0
- openrouter/models_.py +6 -0
- openrouter/oauth.py +4 -0
- openrouter/operations/__init__.py +46 -49
- openrouter/operations/createembeddings.py +68 -264
- openrouter/operations/getcredits.py +19 -0
- openrouter/operations/getgeneration.py +6 -0
- openrouter/operations/getparameters.py +5 -77
- openrouter/operations/updatekeys.py +2 -2
- openrouter/parameters.py +4 -2
- openrouter/providers.py +2 -0
- openrouter/responses.py +188 -36
- openrouter/sdk.py +13 -0
- openrouter/sdkconfiguration.py +2 -0
- openrouter/utils/forms.py +21 -10
- openrouter/utils/queryparams.py +14 -2
- openrouter/utils/retries.py +69 -5
- {openrouter-0.0.16.dist-info → openrouter-0.0.18.dist-info}/METADATA +2 -1
- {openrouter-0.0.16.dist-info → openrouter-0.0.18.dist-info}/RECORD +85 -64
- {openrouter-0.0.16.dist-info → openrouter-0.0.18.dist-info}/WHEEL +0 -0
- {openrouter-0.0.16.dist-info → openrouter-0.0.18.dist-info}/licenses/LICENSE +0 -0
- {openrouter-0.0.16.dist-info → openrouter-0.0.18.dist-info}/top_level.txt +0 -0
openrouter/_version.py
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import importlib.metadata
|
|
4
4
|
|
|
5
5
|
__title__: str = "openrouter"
|
|
6
|
-
__version__: str = "0.0.
|
|
6
|
+
__version__: str = "0.0.18"
|
|
7
7
|
__openapi_doc_version__: str = "1.0.0"
|
|
8
|
-
__gen_version__: str = "2.
|
|
9
|
-
__user_agent__: str = "speakeasy-sdk/python 0.0.
|
|
8
|
+
__gen_version__: str = "2.768.0"
|
|
9
|
+
__user_agent__: str = "speakeasy-sdk/python 0.0.18 2.768.0 1.0.0 openrouter"
|
|
10
10
|
|
|
11
11
|
try:
|
|
12
12
|
if __package__ is not None:
|
openrouter/analytics.py
CHANGED
|
@@ -58,6 +58,7 @@ class Analytics(BaseSDK):
|
|
|
58
58
|
accept_header_value="application/json",
|
|
59
59
|
http_headers=http_headers,
|
|
60
60
|
security=self.sdk_configuration.security,
|
|
61
|
+
allow_empty_value=None,
|
|
61
62
|
timeout_ms=timeout_ms,
|
|
62
63
|
)
|
|
63
64
|
|
|
@@ -166,6 +167,7 @@ class Analytics(BaseSDK):
|
|
|
166
167
|
accept_header_value="application/json",
|
|
167
168
|
http_headers=http_headers,
|
|
168
169
|
security=self.sdk_configuration.security,
|
|
170
|
+
allow_empty_value=None,
|
|
169
171
|
timeout_ms=timeout_ms,
|
|
170
172
|
)
|
|
171
173
|
|
openrouter/api_keys.py
CHANGED
|
@@ -60,6 +60,7 @@ class APIKeys(BaseSDK):
|
|
|
60
60
|
accept_header_value="application/json",
|
|
61
61
|
http_headers=http_headers,
|
|
62
62
|
security=self.sdk_configuration.security,
|
|
63
|
+
allow_empty_value=None,
|
|
63
64
|
timeout_ms=timeout_ms,
|
|
64
65
|
)
|
|
65
66
|
|
|
@@ -164,6 +165,7 @@ class APIKeys(BaseSDK):
|
|
|
164
165
|
accept_header_value="application/json",
|
|
165
166
|
http_headers=http_headers,
|
|
166
167
|
security=self.sdk_configuration.security,
|
|
168
|
+
allow_empty_value=None,
|
|
167
169
|
timeout_ms=timeout_ms,
|
|
168
170
|
)
|
|
169
171
|
|
|
@@ -280,6 +282,7 @@ class APIKeys(BaseSDK):
|
|
|
280
282
|
get_serialized_body=lambda: utils.serialize_request_body(
|
|
281
283
|
request, False, False, "json", operations.CreateKeysRequest
|
|
282
284
|
),
|
|
285
|
+
allow_empty_value=None,
|
|
283
286
|
timeout_ms=timeout_ms,
|
|
284
287
|
)
|
|
285
288
|
|
|
@@ -401,6 +404,7 @@ class APIKeys(BaseSDK):
|
|
|
401
404
|
get_serialized_body=lambda: utils.serialize_request_body(
|
|
402
405
|
request, False, False, "json", operations.CreateKeysRequest
|
|
403
406
|
),
|
|
407
|
+
allow_empty_value=None,
|
|
404
408
|
timeout_ms=timeout_ms,
|
|
405
409
|
)
|
|
406
410
|
|
|
@@ -502,7 +506,7 @@ class APIKeys(BaseSDK):
|
|
|
502
506
|
|
|
503
507
|
request = operations.UpdateKeysRequest(
|
|
504
508
|
hash=hash,
|
|
505
|
-
|
|
509
|
+
request_body=operations.UpdateKeysRequestBody(
|
|
506
510
|
name=name,
|
|
507
511
|
disabled=disabled,
|
|
508
512
|
limit=limit,
|
|
@@ -525,8 +529,13 @@ class APIKeys(BaseSDK):
|
|
|
525
529
|
http_headers=http_headers,
|
|
526
530
|
security=self.sdk_configuration.security,
|
|
527
531
|
get_serialized_body=lambda: utils.serialize_request_body(
|
|
528
|
-
request.
|
|
532
|
+
request.request_body,
|
|
533
|
+
False,
|
|
534
|
+
False,
|
|
535
|
+
"json",
|
|
536
|
+
operations.UpdateKeysRequestBody,
|
|
529
537
|
),
|
|
538
|
+
allow_empty_value=None,
|
|
530
539
|
timeout_ms=timeout_ms,
|
|
531
540
|
)
|
|
532
541
|
|
|
@@ -633,7 +642,7 @@ class APIKeys(BaseSDK):
|
|
|
633
642
|
|
|
634
643
|
request = operations.UpdateKeysRequest(
|
|
635
644
|
hash=hash,
|
|
636
|
-
|
|
645
|
+
request_body=operations.UpdateKeysRequestBody(
|
|
637
646
|
name=name,
|
|
638
647
|
disabled=disabled,
|
|
639
648
|
limit=limit,
|
|
@@ -656,8 +665,13 @@ class APIKeys(BaseSDK):
|
|
|
656
665
|
http_headers=http_headers,
|
|
657
666
|
security=self.sdk_configuration.security,
|
|
658
667
|
get_serialized_body=lambda: utils.serialize_request_body(
|
|
659
|
-
request.
|
|
668
|
+
request.request_body,
|
|
669
|
+
False,
|
|
670
|
+
False,
|
|
671
|
+
"json",
|
|
672
|
+
operations.UpdateKeysRequestBody,
|
|
660
673
|
),
|
|
674
|
+
allow_empty_value=None,
|
|
661
675
|
timeout_ms=timeout_ms,
|
|
662
676
|
)
|
|
663
677
|
|
|
@@ -769,6 +783,7 @@ class APIKeys(BaseSDK):
|
|
|
769
783
|
accept_header_value="application/json",
|
|
770
784
|
http_headers=http_headers,
|
|
771
785
|
security=self.sdk_configuration.security,
|
|
786
|
+
allow_empty_value=None,
|
|
772
787
|
timeout_ms=timeout_ms,
|
|
773
788
|
)
|
|
774
789
|
|
|
@@ -875,6 +890,7 @@ class APIKeys(BaseSDK):
|
|
|
875
890
|
accept_header_value="application/json",
|
|
876
891
|
http_headers=http_headers,
|
|
877
892
|
security=self.sdk_configuration.security,
|
|
893
|
+
allow_empty_value=None,
|
|
878
894
|
timeout_ms=timeout_ms,
|
|
879
895
|
)
|
|
880
896
|
|
|
@@ -981,6 +997,7 @@ class APIKeys(BaseSDK):
|
|
|
981
997
|
accept_header_value="application/json",
|
|
982
998
|
http_headers=http_headers,
|
|
983
999
|
security=self.sdk_configuration.security,
|
|
1000
|
+
allow_empty_value=None,
|
|
984
1001
|
timeout_ms=timeout_ms,
|
|
985
1002
|
)
|
|
986
1003
|
|
|
@@ -1087,6 +1104,7 @@ class APIKeys(BaseSDK):
|
|
|
1087
1104
|
accept_header_value="application/json",
|
|
1088
1105
|
http_headers=http_headers,
|
|
1089
1106
|
security=self.sdk_configuration.security,
|
|
1107
|
+
allow_empty_value=None,
|
|
1090
1108
|
timeout_ms=timeout_ms,
|
|
1091
1109
|
)
|
|
1092
1110
|
|
|
@@ -1188,6 +1206,7 @@ class APIKeys(BaseSDK):
|
|
|
1188
1206
|
accept_header_value="application/json",
|
|
1189
1207
|
http_headers=http_headers,
|
|
1190
1208
|
security=self.sdk_configuration.security,
|
|
1209
|
+
allow_empty_value=None,
|
|
1191
1210
|
timeout_ms=timeout_ms,
|
|
1192
1211
|
)
|
|
1193
1212
|
|
|
@@ -1279,6 +1298,7 @@ class APIKeys(BaseSDK):
|
|
|
1279
1298
|
accept_header_value="application/json",
|
|
1280
1299
|
http_headers=http_headers,
|
|
1281
1300
|
security=self.sdk_configuration.security,
|
|
1301
|
+
allow_empty_value=None,
|
|
1282
1302
|
timeout_ms=timeout_ms,
|
|
1283
1303
|
)
|
|
1284
1304
|
|
openrouter/basesdk.py
CHANGED
|
@@ -60,6 +60,7 @@ class BaseSDK:
|
|
|
60
60
|
] = None,
|
|
61
61
|
url_override: Optional[str] = None,
|
|
62
62
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
63
|
+
allow_empty_value: Optional[List[str]] = None,
|
|
63
64
|
) -> httpx.Request:
|
|
64
65
|
client = self.sdk_configuration.async_client
|
|
65
66
|
return self._build_request_with_client(
|
|
@@ -80,6 +81,7 @@ class BaseSDK:
|
|
|
80
81
|
get_serialized_body,
|
|
81
82
|
url_override,
|
|
82
83
|
http_headers,
|
|
84
|
+
allow_empty_value,
|
|
83
85
|
)
|
|
84
86
|
|
|
85
87
|
def _build_request(
|
|
@@ -102,6 +104,7 @@ class BaseSDK:
|
|
|
102
104
|
] = None,
|
|
103
105
|
url_override: Optional[str] = None,
|
|
104
106
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
107
|
+
allow_empty_value: Optional[List[str]] = None,
|
|
105
108
|
) -> httpx.Request:
|
|
106
109
|
client = self.sdk_configuration.client
|
|
107
110
|
return self._build_request_with_client(
|
|
@@ -122,6 +125,7 @@ class BaseSDK:
|
|
|
122
125
|
get_serialized_body,
|
|
123
126
|
url_override,
|
|
124
127
|
http_headers,
|
|
128
|
+
allow_empty_value,
|
|
125
129
|
)
|
|
126
130
|
|
|
127
131
|
def _build_request_with_client(
|
|
@@ -145,6 +149,7 @@ class BaseSDK:
|
|
|
145
149
|
] = None,
|
|
146
150
|
url_override: Optional[str] = None,
|
|
147
151
|
http_headers: Optional[Mapping[str, str]] = None,
|
|
152
|
+
allow_empty_value: Optional[List[str]] = None,
|
|
148
153
|
) -> httpx.Request:
|
|
149
154
|
query_params = {}
|
|
150
155
|
|
|
@@ -160,6 +165,7 @@ class BaseSDK:
|
|
|
160
165
|
query_params = utils.get_query_params(
|
|
161
166
|
request if request_has_query_params else None,
|
|
162
167
|
_globals if request_has_query_params else None,
|
|
168
|
+
allow_empty_value,
|
|
163
169
|
)
|
|
164
170
|
else:
|
|
165
171
|
# Pick up the query parameter from the override so they can be
|
openrouter/chat.py
CHANGED
|
@@ -21,6 +21,21 @@ class Chat(BaseSDK):
|
|
|
21
21
|
self,
|
|
22
22
|
*,
|
|
23
23
|
messages: Union[List[components.Message], List[components.MessageTypedDict]],
|
|
24
|
+
provider: OptionalNullable[
|
|
25
|
+
Union[
|
|
26
|
+
components.ChatGenerationParamsProvider,
|
|
27
|
+
components.ChatGenerationParamsProviderTypedDict,
|
|
28
|
+
]
|
|
29
|
+
] = UNSET,
|
|
30
|
+
plugins: Optional[
|
|
31
|
+
Union[
|
|
32
|
+
List[components.ChatGenerationParamsPluginUnion],
|
|
33
|
+
List[components.ChatGenerationParamsPluginUnionTypedDict],
|
|
34
|
+
]
|
|
35
|
+
] = None,
|
|
36
|
+
route: OptionalNullable[components.Route] = UNSET,
|
|
37
|
+
user: Optional[str] = None,
|
|
38
|
+
session_id: Optional[str] = None,
|
|
24
39
|
model: Optional[str] = None,
|
|
25
40
|
models: Optional[List[str]] = None,
|
|
26
41
|
frequency_penalty: OptionalNullable[float] = UNSET,
|
|
@@ -60,7 +75,14 @@ class Chat(BaseSDK):
|
|
|
60
75
|
]
|
|
61
76
|
] = None,
|
|
62
77
|
top_p: OptionalNullable[float] = UNSET,
|
|
63
|
-
|
|
78
|
+
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
|
|
79
|
+
image_config: Optional[
|
|
80
|
+
Union[
|
|
81
|
+
Dict[str, components.ChatGenerationParamsImageConfig],
|
|
82
|
+
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
|
|
83
|
+
]
|
|
84
|
+
] = None,
|
|
85
|
+
modalities: Optional[List[components.Modality]] = None,
|
|
64
86
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
65
87
|
server_url: Optional[str] = None,
|
|
66
88
|
timeout_ms: Optional[int] = None,
|
|
@@ -71,6 +93,11 @@ class Chat(BaseSDK):
|
|
|
71
93
|
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
|
|
72
94
|
|
|
73
95
|
:param messages:
|
|
96
|
+
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
|
97
|
+
:param plugins: Plugins you want to enable for this request, including their settings.
|
|
98
|
+
:param route:
|
|
99
|
+
:param user:
|
|
100
|
+
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
|
74
101
|
:param model:
|
|
75
102
|
:param models:
|
|
76
103
|
:param frequency_penalty:
|
|
@@ -91,7 +118,9 @@ class Chat(BaseSDK):
|
|
|
91
118
|
:param tool_choice:
|
|
92
119
|
:param tools:
|
|
93
120
|
:param top_p:
|
|
94
|
-
:param
|
|
121
|
+
:param debug:
|
|
122
|
+
:param image_config:
|
|
123
|
+
:param modalities:
|
|
95
124
|
:param retries: Override the default retry configuration for this method
|
|
96
125
|
:param server_url: Override the default server URL for this method
|
|
97
126
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -104,6 +133,21 @@ class Chat(BaseSDK):
|
|
|
104
133
|
self,
|
|
105
134
|
*,
|
|
106
135
|
messages: Union[List[components.Message], List[components.MessageTypedDict]],
|
|
136
|
+
provider: OptionalNullable[
|
|
137
|
+
Union[
|
|
138
|
+
components.ChatGenerationParamsProvider,
|
|
139
|
+
components.ChatGenerationParamsProviderTypedDict,
|
|
140
|
+
]
|
|
141
|
+
] = UNSET,
|
|
142
|
+
plugins: Optional[
|
|
143
|
+
Union[
|
|
144
|
+
List[components.ChatGenerationParamsPluginUnion],
|
|
145
|
+
List[components.ChatGenerationParamsPluginUnionTypedDict],
|
|
146
|
+
]
|
|
147
|
+
] = None,
|
|
148
|
+
route: OptionalNullable[components.Route] = UNSET,
|
|
149
|
+
user: Optional[str] = None,
|
|
150
|
+
session_id: Optional[str] = None,
|
|
107
151
|
model: Optional[str] = None,
|
|
108
152
|
models: Optional[List[str]] = None,
|
|
109
153
|
frequency_penalty: OptionalNullable[float] = UNSET,
|
|
@@ -143,7 +187,14 @@ class Chat(BaseSDK):
|
|
|
143
187
|
]
|
|
144
188
|
] = None,
|
|
145
189
|
top_p: OptionalNullable[float] = UNSET,
|
|
146
|
-
|
|
190
|
+
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
|
|
191
|
+
image_config: Optional[
|
|
192
|
+
Union[
|
|
193
|
+
Dict[str, components.ChatGenerationParamsImageConfig],
|
|
194
|
+
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
|
|
195
|
+
]
|
|
196
|
+
] = None,
|
|
197
|
+
modalities: Optional[List[components.Modality]] = None,
|
|
147
198
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
148
199
|
server_url: Optional[str] = None,
|
|
149
200
|
timeout_ms: Optional[int] = None,
|
|
@@ -154,6 +205,11 @@ class Chat(BaseSDK):
|
|
|
154
205
|
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
|
|
155
206
|
|
|
156
207
|
:param messages:
|
|
208
|
+
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
|
209
|
+
:param plugins: Plugins you want to enable for this request, including their settings.
|
|
210
|
+
:param route:
|
|
211
|
+
:param user:
|
|
212
|
+
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
|
157
213
|
:param model:
|
|
158
214
|
:param models:
|
|
159
215
|
:param frequency_penalty:
|
|
@@ -174,7 +230,9 @@ class Chat(BaseSDK):
|
|
|
174
230
|
:param tool_choice:
|
|
175
231
|
:param tools:
|
|
176
232
|
:param top_p:
|
|
177
|
-
:param
|
|
233
|
+
:param debug:
|
|
234
|
+
:param image_config:
|
|
235
|
+
:param modalities:
|
|
178
236
|
:param retries: Override the default retry configuration for this method
|
|
179
237
|
:param server_url: Override the default server URL for this method
|
|
180
238
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -186,6 +244,21 @@ class Chat(BaseSDK):
|
|
|
186
244
|
self,
|
|
187
245
|
*,
|
|
188
246
|
messages: Union[List[components.Message], List[components.MessageTypedDict]],
|
|
247
|
+
provider: OptionalNullable[
|
|
248
|
+
Union[
|
|
249
|
+
components.ChatGenerationParamsProvider,
|
|
250
|
+
components.ChatGenerationParamsProviderTypedDict,
|
|
251
|
+
]
|
|
252
|
+
] = UNSET,
|
|
253
|
+
plugins: Optional[
|
|
254
|
+
Union[
|
|
255
|
+
List[components.ChatGenerationParamsPluginUnion],
|
|
256
|
+
List[components.ChatGenerationParamsPluginUnionTypedDict],
|
|
257
|
+
]
|
|
258
|
+
] = None,
|
|
259
|
+
route: OptionalNullable[components.Route] = UNSET,
|
|
260
|
+
user: Optional[str] = None,
|
|
261
|
+
session_id: Optional[str] = None,
|
|
189
262
|
model: Optional[str] = None,
|
|
190
263
|
models: Optional[List[str]] = None,
|
|
191
264
|
frequency_penalty: OptionalNullable[float] = UNSET,
|
|
@@ -225,7 +298,14 @@ class Chat(BaseSDK):
|
|
|
225
298
|
]
|
|
226
299
|
] = None,
|
|
227
300
|
top_p: OptionalNullable[float] = UNSET,
|
|
228
|
-
|
|
301
|
+
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
|
|
302
|
+
image_config: Optional[
|
|
303
|
+
Union[
|
|
304
|
+
Dict[str, components.ChatGenerationParamsImageConfig],
|
|
305
|
+
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
|
|
306
|
+
]
|
|
307
|
+
] = None,
|
|
308
|
+
modalities: Optional[List[components.Modality]] = None,
|
|
229
309
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
230
310
|
server_url: Optional[str] = None,
|
|
231
311
|
timeout_ms: Optional[int] = None,
|
|
@@ -236,6 +316,11 @@ class Chat(BaseSDK):
|
|
|
236
316
|
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
|
|
237
317
|
|
|
238
318
|
:param messages:
|
|
319
|
+
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
|
320
|
+
:param plugins: Plugins you want to enable for this request, including their settings.
|
|
321
|
+
:param route:
|
|
322
|
+
:param user:
|
|
323
|
+
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
|
239
324
|
:param model:
|
|
240
325
|
:param models:
|
|
241
326
|
:param frequency_penalty:
|
|
@@ -256,7 +341,9 @@ class Chat(BaseSDK):
|
|
|
256
341
|
:param tool_choice:
|
|
257
342
|
:param tools:
|
|
258
343
|
:param top_p:
|
|
259
|
-
:param
|
|
344
|
+
:param debug:
|
|
345
|
+
:param image_config:
|
|
346
|
+
:param modalities:
|
|
260
347
|
:param retries: Override the default retry configuration for this method
|
|
261
348
|
:param server_url: Override the default server URL for this method
|
|
262
349
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -274,6 +361,15 @@ class Chat(BaseSDK):
|
|
|
274
361
|
base_url = self._get_url(base_url, url_variables)
|
|
275
362
|
|
|
276
363
|
request = components.ChatGenerationParams(
|
|
364
|
+
provider=utils.get_pydantic_model(
|
|
365
|
+
provider, OptionalNullable[components.ChatGenerationParamsProvider]
|
|
366
|
+
),
|
|
367
|
+
plugins=utils.get_pydantic_model(
|
|
368
|
+
plugins, Optional[List[components.ChatGenerationParamsPluginUnion]]
|
|
369
|
+
),
|
|
370
|
+
route=route,
|
|
371
|
+
user=user,
|
|
372
|
+
session_id=session_id,
|
|
277
373
|
messages=utils.get_pydantic_model(messages, List[components.Message]),
|
|
278
374
|
model=model,
|
|
279
375
|
models=models,
|
|
@@ -304,7 +400,9 @@ class Chat(BaseSDK):
|
|
|
304
400
|
tools, Optional[List[components.ToolDefinitionJSON]]
|
|
305
401
|
),
|
|
306
402
|
top_p=top_p,
|
|
307
|
-
|
|
403
|
+
debug=utils.get_pydantic_model(debug, Optional[components.Debug]),
|
|
404
|
+
image_config=image_config,
|
|
405
|
+
modalities=modalities,
|
|
308
406
|
)
|
|
309
407
|
|
|
310
408
|
req = self._build_request(
|
|
@@ -323,6 +421,7 @@ class Chat(BaseSDK):
|
|
|
323
421
|
get_serialized_body=lambda: utils.serialize_request_body(
|
|
324
422
|
request, False, False, "json", components.ChatGenerationParams
|
|
325
423
|
),
|
|
424
|
+
allow_empty_value=None,
|
|
326
425
|
timeout_ms=timeout_ms,
|
|
327
426
|
)
|
|
328
427
|
|
|
@@ -398,6 +497,21 @@ class Chat(BaseSDK):
|
|
|
398
497
|
self,
|
|
399
498
|
*,
|
|
400
499
|
messages: Union[List[components.Message], List[components.MessageTypedDict]],
|
|
500
|
+
provider: OptionalNullable[
|
|
501
|
+
Union[
|
|
502
|
+
components.ChatGenerationParamsProvider,
|
|
503
|
+
components.ChatGenerationParamsProviderTypedDict,
|
|
504
|
+
]
|
|
505
|
+
] = UNSET,
|
|
506
|
+
plugins: Optional[
|
|
507
|
+
Union[
|
|
508
|
+
List[components.ChatGenerationParamsPluginUnion],
|
|
509
|
+
List[components.ChatGenerationParamsPluginUnionTypedDict],
|
|
510
|
+
]
|
|
511
|
+
] = None,
|
|
512
|
+
route: OptionalNullable[components.Route] = UNSET,
|
|
513
|
+
user: Optional[str] = None,
|
|
514
|
+
session_id: Optional[str] = None,
|
|
401
515
|
model: Optional[str] = None,
|
|
402
516
|
models: Optional[List[str]] = None,
|
|
403
517
|
frequency_penalty: OptionalNullable[float] = UNSET,
|
|
@@ -437,7 +551,14 @@ class Chat(BaseSDK):
|
|
|
437
551
|
]
|
|
438
552
|
] = None,
|
|
439
553
|
top_p: OptionalNullable[float] = UNSET,
|
|
440
|
-
|
|
554
|
+
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
|
|
555
|
+
image_config: Optional[
|
|
556
|
+
Union[
|
|
557
|
+
Dict[str, components.ChatGenerationParamsImageConfig],
|
|
558
|
+
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
|
|
559
|
+
]
|
|
560
|
+
] = None,
|
|
561
|
+
modalities: Optional[List[components.Modality]] = None,
|
|
441
562
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
442
563
|
server_url: Optional[str] = None,
|
|
443
564
|
timeout_ms: Optional[int] = None,
|
|
@@ -448,6 +569,11 @@ class Chat(BaseSDK):
|
|
|
448
569
|
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
|
|
449
570
|
|
|
450
571
|
:param messages:
|
|
572
|
+
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
|
573
|
+
:param plugins: Plugins you want to enable for this request, including their settings.
|
|
574
|
+
:param route:
|
|
575
|
+
:param user:
|
|
576
|
+
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
|
451
577
|
:param model:
|
|
452
578
|
:param models:
|
|
453
579
|
:param frequency_penalty:
|
|
@@ -468,7 +594,9 @@ class Chat(BaseSDK):
|
|
|
468
594
|
:param tool_choice:
|
|
469
595
|
:param tools:
|
|
470
596
|
:param top_p:
|
|
471
|
-
:param
|
|
597
|
+
:param debug:
|
|
598
|
+
:param image_config:
|
|
599
|
+
:param modalities:
|
|
472
600
|
:param retries: Override the default retry configuration for this method
|
|
473
601
|
:param server_url: Override the default server URL for this method
|
|
474
602
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -481,6 +609,21 @@ class Chat(BaseSDK):
|
|
|
481
609
|
self,
|
|
482
610
|
*,
|
|
483
611
|
messages: Union[List[components.Message], List[components.MessageTypedDict]],
|
|
612
|
+
provider: OptionalNullable[
|
|
613
|
+
Union[
|
|
614
|
+
components.ChatGenerationParamsProvider,
|
|
615
|
+
components.ChatGenerationParamsProviderTypedDict,
|
|
616
|
+
]
|
|
617
|
+
] = UNSET,
|
|
618
|
+
plugins: Optional[
|
|
619
|
+
Union[
|
|
620
|
+
List[components.ChatGenerationParamsPluginUnion],
|
|
621
|
+
List[components.ChatGenerationParamsPluginUnionTypedDict],
|
|
622
|
+
]
|
|
623
|
+
] = None,
|
|
624
|
+
route: OptionalNullable[components.Route] = UNSET,
|
|
625
|
+
user: Optional[str] = None,
|
|
626
|
+
session_id: Optional[str] = None,
|
|
484
627
|
model: Optional[str] = None,
|
|
485
628
|
models: Optional[List[str]] = None,
|
|
486
629
|
frequency_penalty: OptionalNullable[float] = UNSET,
|
|
@@ -520,7 +663,14 @@ class Chat(BaseSDK):
|
|
|
520
663
|
]
|
|
521
664
|
] = None,
|
|
522
665
|
top_p: OptionalNullable[float] = UNSET,
|
|
523
|
-
|
|
666
|
+
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
|
|
667
|
+
image_config: Optional[
|
|
668
|
+
Union[
|
|
669
|
+
Dict[str, components.ChatGenerationParamsImageConfig],
|
|
670
|
+
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
|
|
671
|
+
]
|
|
672
|
+
] = None,
|
|
673
|
+
modalities: Optional[List[components.Modality]] = None,
|
|
524
674
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
525
675
|
server_url: Optional[str] = None,
|
|
526
676
|
timeout_ms: Optional[int] = None,
|
|
@@ -531,6 +681,11 @@ class Chat(BaseSDK):
|
|
|
531
681
|
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
|
|
532
682
|
|
|
533
683
|
:param messages:
|
|
684
|
+
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
|
685
|
+
:param plugins: Plugins you want to enable for this request, including their settings.
|
|
686
|
+
:param route:
|
|
687
|
+
:param user:
|
|
688
|
+
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
|
534
689
|
:param model:
|
|
535
690
|
:param models:
|
|
536
691
|
:param frequency_penalty:
|
|
@@ -551,7 +706,9 @@ class Chat(BaseSDK):
|
|
|
551
706
|
:param tool_choice:
|
|
552
707
|
:param tools:
|
|
553
708
|
:param top_p:
|
|
554
|
-
:param
|
|
709
|
+
:param debug:
|
|
710
|
+
:param image_config:
|
|
711
|
+
:param modalities:
|
|
555
712
|
:param retries: Override the default retry configuration for this method
|
|
556
713
|
:param server_url: Override the default server URL for this method
|
|
557
714
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -563,6 +720,21 @@ class Chat(BaseSDK):
|
|
|
563
720
|
self,
|
|
564
721
|
*,
|
|
565
722
|
messages: Union[List[components.Message], List[components.MessageTypedDict]],
|
|
723
|
+
provider: OptionalNullable[
|
|
724
|
+
Union[
|
|
725
|
+
components.ChatGenerationParamsProvider,
|
|
726
|
+
components.ChatGenerationParamsProviderTypedDict,
|
|
727
|
+
]
|
|
728
|
+
] = UNSET,
|
|
729
|
+
plugins: Optional[
|
|
730
|
+
Union[
|
|
731
|
+
List[components.ChatGenerationParamsPluginUnion],
|
|
732
|
+
List[components.ChatGenerationParamsPluginUnionTypedDict],
|
|
733
|
+
]
|
|
734
|
+
] = None,
|
|
735
|
+
route: OptionalNullable[components.Route] = UNSET,
|
|
736
|
+
user: Optional[str] = None,
|
|
737
|
+
session_id: Optional[str] = None,
|
|
566
738
|
model: Optional[str] = None,
|
|
567
739
|
models: Optional[List[str]] = None,
|
|
568
740
|
frequency_penalty: OptionalNullable[float] = UNSET,
|
|
@@ -602,7 +774,14 @@ class Chat(BaseSDK):
|
|
|
602
774
|
]
|
|
603
775
|
] = None,
|
|
604
776
|
top_p: OptionalNullable[float] = UNSET,
|
|
605
|
-
|
|
777
|
+
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
|
|
778
|
+
image_config: Optional[
|
|
779
|
+
Union[
|
|
780
|
+
Dict[str, components.ChatGenerationParamsImageConfig],
|
|
781
|
+
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
|
|
782
|
+
]
|
|
783
|
+
] = None,
|
|
784
|
+
modalities: Optional[List[components.Modality]] = None,
|
|
606
785
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
607
786
|
server_url: Optional[str] = None,
|
|
608
787
|
timeout_ms: Optional[int] = None,
|
|
@@ -613,6 +792,11 @@ class Chat(BaseSDK):
|
|
|
613
792
|
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
|
|
614
793
|
|
|
615
794
|
:param messages:
|
|
795
|
+
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
|
796
|
+
:param plugins: Plugins you want to enable for this request, including their settings.
|
|
797
|
+
:param route:
|
|
798
|
+
:param user:
|
|
799
|
+
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
|
|
616
800
|
:param model:
|
|
617
801
|
:param models:
|
|
618
802
|
:param frequency_penalty:
|
|
@@ -633,7 +817,9 @@ class Chat(BaseSDK):
|
|
|
633
817
|
:param tool_choice:
|
|
634
818
|
:param tools:
|
|
635
819
|
:param top_p:
|
|
636
|
-
:param
|
|
820
|
+
:param debug:
|
|
821
|
+
:param image_config:
|
|
822
|
+
:param modalities:
|
|
637
823
|
:param retries: Override the default retry configuration for this method
|
|
638
824
|
:param server_url: Override the default server URL for this method
|
|
639
825
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -651,6 +837,15 @@ class Chat(BaseSDK):
|
|
|
651
837
|
base_url = self._get_url(base_url, url_variables)
|
|
652
838
|
|
|
653
839
|
request = components.ChatGenerationParams(
|
|
840
|
+
provider=utils.get_pydantic_model(
|
|
841
|
+
provider, OptionalNullable[components.ChatGenerationParamsProvider]
|
|
842
|
+
),
|
|
843
|
+
plugins=utils.get_pydantic_model(
|
|
844
|
+
plugins, Optional[List[components.ChatGenerationParamsPluginUnion]]
|
|
845
|
+
),
|
|
846
|
+
route=route,
|
|
847
|
+
user=user,
|
|
848
|
+
session_id=session_id,
|
|
654
849
|
messages=utils.get_pydantic_model(messages, List[components.Message]),
|
|
655
850
|
model=model,
|
|
656
851
|
models=models,
|
|
@@ -681,7 +876,9 @@ class Chat(BaseSDK):
|
|
|
681
876
|
tools, Optional[List[components.ToolDefinitionJSON]]
|
|
682
877
|
),
|
|
683
878
|
top_p=top_p,
|
|
684
|
-
|
|
879
|
+
debug=utils.get_pydantic_model(debug, Optional[components.Debug]),
|
|
880
|
+
image_config=image_config,
|
|
881
|
+
modalities=modalities,
|
|
685
882
|
)
|
|
686
883
|
|
|
687
884
|
req = self._build_request_async(
|
|
@@ -700,6 +897,7 @@ class Chat(BaseSDK):
|
|
|
700
897
|
get_serialized_body=lambda: utils.serialize_request_body(
|
|
701
898
|
request, False, False, "json", components.ChatGenerationParams
|
|
702
899
|
),
|
|
900
|
+
allow_empty_value=None,
|
|
703
901
|
timeout_ms=timeout_ms,
|
|
704
902
|
)
|
|
705
903
|
|
openrouter/completions.py
CHANGED
|
@@ -136,6 +136,7 @@ class Completions(BaseSDK):
|
|
|
136
136
|
get_serialized_body=lambda: utils.serialize_request_body(
|
|
137
137
|
request, False, False, "json", components.CompletionCreateParams
|
|
138
138
|
),
|
|
139
|
+
allow_empty_value=None,
|
|
139
140
|
timeout_ms=timeout_ms,
|
|
140
141
|
)
|
|
141
142
|
|
|
@@ -310,6 +311,7 @@ class Completions(BaseSDK):
|
|
|
310
311
|
get_serialized_body=lambda: utils.serialize_request_body(
|
|
311
312
|
request, False, False, "json", components.CompletionCreateParams
|
|
312
313
|
),
|
|
314
|
+
allow_empty_value=None,
|
|
313
315
|
timeout_ms=timeout_ms,
|
|
314
316
|
)
|
|
315
317
|
|