mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-31 12:30:30 +08:00
chore: 🐝 Update SDK - Generate (spec change merged) 0.11.24 (#436)
Co-authored-by: speakeasybot <bot@speakeasyapi.dev> Co-authored-by: speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
speakeasybot
speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
parent
cb1b9c5ac6
commit
7010ca5c2e
+216
-9
@@ -1,12 +1,13 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from .basesdk import BaseSDK
|
||||
from jsonpath import JSONPath
|
||||
from openrouter import components, errors, operations, utils
|
||||
from openrouter._hooks import HookContext
|
||||
from openrouter.types import OptionalNullable, UNSET
|
||||
from openrouter.utils import get_security_from_env
|
||||
from openrouter.utils.unmarshal_json_response import unmarshal_json_response
|
||||
from typing import Any, Mapping, Optional, Union
|
||||
from typing import Any, Awaitable, Dict, List, Mapping, Optional, Union
|
||||
|
||||
|
||||
class Models(BaseSDK):
|
||||
@@ -270,6 +271,8 @@ class Models(BaseSDK):
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
offset: Optional[int] = 0,
|
||||
limit: Optional[int] = 500,
|
||||
category: Optional[operations.GetModelsCategory] = None,
|
||||
supported_parameters: Optional[str] = None,
|
||||
output_modalities: Optional[str] = None,
|
||||
@@ -301,7 +304,7 @@ class Models(BaseSDK):
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> components.ModelsListResponse:
|
||||
) -> Optional[operations.GetModelsResponse]:
|
||||
r"""List all models and their properties
|
||||
|
||||
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
@@ -311,6 +314,8 @@ class Models(BaseSDK):
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param offset: Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned
|
||||
:param limit: Maximum number of records to return (max 1000). When both offset and limit are omitted, the full list is returned
|
||||
:param category: Filter models by use case category
|
||||
:param supported_parameters: Filter models by supported parameter (comma-separated)
|
||||
:param output_modalities: Filter models by output modality. Accepts a comma-separated list of modalities (text, image, audio, embeddings) or \"all\" to include all models. Defaults to \"text\".
|
||||
@@ -357,6 +362,8 @@ class Models(BaseSDK):
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
offset=offset,
|
||||
limit=limit,
|
||||
category=category,
|
||||
supported_parameters=supported_parameters,
|
||||
output_modalities=output_modalities,
|
||||
@@ -437,9 +444,66 @@ class Models(BaseSDK):
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
def next_func() -> Optional[operations.GetModelsResponse]:
|
||||
body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]])
|
||||
|
||||
offset = request.offset if isinstance(request.offset, int) else 0
|
||||
|
||||
if not http_res.text:
|
||||
return None
|
||||
results = JSONPath("$.data").parse(body)
|
||||
if len(results) == 0 or len(results[0]) == 0:
|
||||
return None
|
||||
limit_ = request.limit if isinstance(request.limit, int) else 500
|
||||
if len(results[0]) < limit_:
|
||||
return None
|
||||
next_offset = offset + len(results[0])
|
||||
|
||||
return self.list(
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
offset=next_offset,
|
||||
limit=limit,
|
||||
category=category,
|
||||
supported_parameters=supported_parameters,
|
||||
output_modalities=output_modalities,
|
||||
sort=sort,
|
||||
q=q,
|
||||
input_modalities=input_modalities,
|
||||
context=context,
|
||||
min_price=min_price,
|
||||
max_price=max_price,
|
||||
arch=arch,
|
||||
model_authors=model_authors,
|
||||
providers=providers,
|
||||
distillable=distillable,
|
||||
zdr=zdr,
|
||||
region=region,
|
||||
min_output_price=min_output_price,
|
||||
max_output_price=max_output_price,
|
||||
min_age_days=min_age_days,
|
||||
max_age_days=max_age_days,
|
||||
min_intelligence_index=min_intelligence_index,
|
||||
max_intelligence_index=max_intelligence_index,
|
||||
min_coding_index=min_coding_index,
|
||||
max_coding_index=max_coding_index,
|
||||
min_agentic_index=min_agentic_index,
|
||||
max_agentic_index=max_agentic_index,
|
||||
min_tool_success_rate=min_tool_success_rate,
|
||||
max_tool_success_rate=max_tool_success_rate,
|
||||
retries=retries,
|
||||
server_url=server_url,
|
||||
timeout_ms=timeout_ms,
|
||||
http_headers=http_headers,
|
||||
)
|
||||
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(components.ModelsListResponse, http_res)
|
||||
return operations.GetModelsResponse(
|
||||
result=unmarshal_json_response(components.ModelsListResponse, http_res),
|
||||
next=next_func,
|
||||
)
|
||||
if utils.match_response(http_res, "400", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.BadRequestResponseErrorData, http_res
|
||||
@@ -469,6 +533,8 @@ class Models(BaseSDK):
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
offset: Optional[int] = 0,
|
||||
limit: Optional[int] = 500,
|
||||
category: Optional[operations.GetModelsCategory] = None,
|
||||
supported_parameters: Optional[str] = None,
|
||||
output_modalities: Optional[str] = None,
|
||||
@@ -500,7 +566,7 @@ class Models(BaseSDK):
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> components.ModelsListResponse:
|
||||
) -> Optional[operations.GetModelsResponse]:
|
||||
r"""List all models and their properties
|
||||
|
||||
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
||||
@@ -510,6 +576,8 @@ class Models(BaseSDK):
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param offset: Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned
|
||||
:param limit: Maximum number of records to return (max 1000). When both offset and limit are omitted, the full list is returned
|
||||
:param category: Filter models by use case category
|
||||
:param supported_parameters: Filter models by supported parameter (comma-separated)
|
||||
:param output_modalities: Filter models by output modality. Accepts a comma-separated list of modalities (text, image, audio, embeddings) or \"all\" to include all models. Defaults to \"text\".
|
||||
@@ -556,6 +624,8 @@ class Models(BaseSDK):
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
offset=offset,
|
||||
limit=limit,
|
||||
category=category,
|
||||
supported_parameters=supported_parameters,
|
||||
output_modalities=output_modalities,
|
||||
@@ -636,9 +706,69 @@ class Models(BaseSDK):
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
def next_func() -> Awaitable[Optional[operations.GetModelsResponse]]:
|
||||
body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]])
|
||||
|
||||
async def empty_result():
|
||||
return None
|
||||
|
||||
offset = request.offset if isinstance(request.offset, int) else 0
|
||||
|
||||
if not http_res.text:
|
||||
return empty_result()
|
||||
results = JSONPath("$.data").parse(body)
|
||||
if len(results) == 0 or len(results[0]) == 0:
|
||||
return empty_result()
|
||||
limit_ = request.limit if isinstance(request.limit, int) else 500
|
||||
if len(results[0]) < limit_:
|
||||
return empty_result()
|
||||
next_offset = offset + len(results[0])
|
||||
|
||||
return self.list_async(
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
offset=next_offset,
|
||||
limit=limit,
|
||||
category=category,
|
||||
supported_parameters=supported_parameters,
|
||||
output_modalities=output_modalities,
|
||||
sort=sort,
|
||||
q=q,
|
||||
input_modalities=input_modalities,
|
||||
context=context,
|
||||
min_price=min_price,
|
||||
max_price=max_price,
|
||||
arch=arch,
|
||||
model_authors=model_authors,
|
||||
providers=providers,
|
||||
distillable=distillable,
|
||||
zdr=zdr,
|
||||
region=region,
|
||||
min_output_price=min_output_price,
|
||||
max_output_price=max_output_price,
|
||||
min_age_days=min_age_days,
|
||||
max_age_days=max_age_days,
|
||||
min_intelligence_index=min_intelligence_index,
|
||||
max_intelligence_index=max_intelligence_index,
|
||||
min_coding_index=min_coding_index,
|
||||
max_coding_index=max_coding_index,
|
||||
min_agentic_index=min_agentic_index,
|
||||
max_agentic_index=max_agentic_index,
|
||||
min_tool_success_rate=min_tool_success_rate,
|
||||
max_tool_success_rate=max_tool_success_rate,
|
||||
retries=retries,
|
||||
server_url=server_url,
|
||||
timeout_ms=timeout_ms,
|
||||
http_headers=http_headers,
|
||||
)
|
||||
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(components.ModelsListResponse, http_res)
|
||||
return operations.GetModelsResponse(
|
||||
result=unmarshal_json_response(components.ModelsListResponse, http_res),
|
||||
next=next_func,
|
||||
)
|
||||
if utils.match_response(http_res, "400", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.BadRequestResponseErrorData, http_res
|
||||
@@ -914,11 +1044,13 @@ class Models(BaseSDK):
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
offset: Optional[int] = 0,
|
||||
limit: Optional[int] = 500,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> components.ModelsListResponse:
|
||||
) -> Optional[operations.ListModelsUserResponse]:
|
||||
r"""List models filtered by user provider preferences, privacy settings, and guardrails
|
||||
|
||||
List models filtered by user provider preferences, [privacy settings](https://openrouter.ai/docs/guides/privacy/provider-logging), and [guardrails](https://openrouter.ai/docs/guides/features/guardrails). If requesting through `eu.openrouter.ai/api/v1/...` the results will be filtered to models that satisfy [EU in-region routing](https://openrouter.ai/docs/guides/privacy/provider-logging#enterprise-eu-in-region-routing).
|
||||
@@ -931,6 +1063,8 @@ class Models(BaseSDK):
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param offset: Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned
|
||||
:param limit: Maximum number of records to return (max 1000). When both offset and limit are omitted, the full list is returned
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -950,6 +1084,8 @@ class Models(BaseSDK):
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
offset=offset,
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
req = self._build_request(
|
||||
@@ -1003,9 +1139,40 @@ class Models(BaseSDK):
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
def next_func() -> Optional[operations.ListModelsUserResponse]:
|
||||
body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]])
|
||||
|
||||
offset = request.offset if isinstance(request.offset, int) else 0
|
||||
|
||||
if not http_res.text:
|
||||
return None
|
||||
results = JSONPath("$.data").parse(body)
|
||||
if len(results) == 0 or len(results[0]) == 0:
|
||||
return None
|
||||
limit_ = request.limit if isinstance(request.limit, int) else 500
|
||||
if len(results[0]) < limit_:
|
||||
return None
|
||||
next_offset = offset + len(results[0])
|
||||
|
||||
return self.list_for_user(
|
||||
security=security,
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
offset=next_offset,
|
||||
limit=limit,
|
||||
retries=retries,
|
||||
server_url=server_url,
|
||||
timeout_ms=timeout_ms,
|
||||
http_headers=http_headers,
|
||||
)
|
||||
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(components.ModelsListResponse, http_res)
|
||||
return operations.ListModelsUserResponse(
|
||||
result=unmarshal_json_response(components.ModelsListResponse, http_res),
|
||||
next=next_func,
|
||||
)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.UnauthorizedResponseErrorData, http_res
|
||||
@@ -1044,11 +1211,13 @@ class Models(BaseSDK):
|
||||
http_referer: Optional[str] = None,
|
||||
x_open_router_title: Optional[str] = None,
|
||||
x_open_router_categories: Optional[str] = None,
|
||||
offset: Optional[int] = 0,
|
||||
limit: Optional[int] = 500,
|
||||
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
||||
server_url: Optional[str] = None,
|
||||
timeout_ms: Optional[int] = None,
|
||||
http_headers: Optional[Mapping[str, str]] = None,
|
||||
) -> components.ModelsListResponse:
|
||||
) -> Optional[operations.ListModelsUserResponse]:
|
||||
r"""List models filtered by user provider preferences, privacy settings, and guardrails
|
||||
|
||||
List models filtered by user provider preferences, [privacy settings](https://openrouter.ai/docs/guides/privacy/provider-logging), and [guardrails](https://openrouter.ai/docs/guides/features/guardrails). If requesting through `eu.openrouter.ai/api/v1/...` the results will be filtered to models that satisfy [EU in-region routing](https://openrouter.ai/docs/guides/privacy/provider-logging#enterprise-eu-in-region-routing).
|
||||
@@ -1061,6 +1230,8 @@ class Models(BaseSDK):
|
||||
|
||||
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
|
||||
|
||||
:param offset: Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned
|
||||
:param limit: Maximum number of records to return (max 1000). When both offset and limit are omitted, the full list is returned
|
||||
:param retries: Override the default retry configuration for this method
|
||||
:param server_url: Override the default server URL for this method
|
||||
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
||||
@@ -1080,6 +1251,8 @@ class Models(BaseSDK):
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
offset=offset,
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
req = self._build_request_async(
|
||||
@@ -1133,9 +1306,43 @@ class Models(BaseSDK):
|
||||
retry_config=retry_config,
|
||||
)
|
||||
|
||||
def next_func() -> Awaitable[Optional[operations.ListModelsUserResponse]]:
|
||||
body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]])
|
||||
|
||||
async def empty_result():
|
||||
return None
|
||||
|
||||
offset = request.offset if isinstance(request.offset, int) else 0
|
||||
|
||||
if not http_res.text:
|
||||
return empty_result()
|
||||
results = JSONPath("$.data").parse(body)
|
||||
if len(results) == 0 or len(results[0]) == 0:
|
||||
return empty_result()
|
||||
limit_ = request.limit if isinstance(request.limit, int) else 500
|
||||
if len(results[0]) < limit_:
|
||||
return empty_result()
|
||||
next_offset = offset + len(results[0])
|
||||
|
||||
return self.list_for_user_async(
|
||||
security=security,
|
||||
http_referer=http_referer,
|
||||
x_open_router_title=x_open_router_title,
|
||||
x_open_router_categories=x_open_router_categories,
|
||||
offset=next_offset,
|
||||
limit=limit,
|
||||
retries=retries,
|
||||
server_url=server_url,
|
||||
timeout_ms=timeout_ms,
|
||||
http_headers=http_headers,
|
||||
)
|
||||
|
||||
response_data: Any = None
|
||||
if utils.match_response(http_res, "200", "application/json"):
|
||||
return unmarshal_json_response(components.ModelsListResponse, http_res)
|
||||
return operations.ListModelsUserResponse(
|
||||
result=unmarshal_json_response(components.ModelsListResponse, http_res),
|
||||
next=next_func,
|
||||
)
|
||||
if utils.match_response(http_res, "401", "application/json"):
|
||||
response_data = unmarshal_json_response(
|
||||
errors.UnauthorizedResponseErrorData, http_res
|
||||
|
||||
Reference in New Issue
Block a user