mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-08-01 12:40:23 +08:00
- 68922847c2969b773887310eb7aa9a814e199c5a - 729ee2338c39df22461526153e7f4ba868fd498e - e1074ff86fccf5e48406b7595298873106d3cc5a - 123bbdaf841d299162a82ee2573adfbb70a45b8f - ac457b8a8dad98fdf5ddcae8dd4711361cea3084 - ea825199f4c59dd68fec01cf8d18a582963c9f25 - 4d48e4f6bb936e785787314a965298da6b78fea0 - 718729a573ee98893a4408d5a52ab4686661fe54 - b867adcde6b64f3f2a11c4626254b39098e4b0b4 - 21912c097b4066d109766c6b4492826595cd57c5 - bc1ed85adc976a4634ca8a41b82e4fc2c39a864f - d145c89c941937a312ed1357590d2bfda9a3603d - 12f05b5dee397ead47cfcd545a7a2e3c7ff57524 - dd28f75a19a015809797c7abf3f8758f7c37262e - c96e569781e07ab44172d9c69940ec17bafd81f4 - c9d5a90e3c2b5077a2bdd49773f1a46d1a5a79c7 - 58b08f87116ceab9076de2fdc0a4c74c919b44c4 GitOrigin-RevId: 68922847c2969b773887310eb7aa9a814e199c5a
138 lines
7.7 KiB
Markdown
138 lines
7.7 KiB
Markdown
# Models
|
|
(*models*)
|
|
|
|
## Overview
|
|
|
|
Model information endpoints
|
|
|
|
### Available Operations
|
|
|
|
* [count](#count) - Get total count of available models
|
|
* [list](#list) - List all models and their properties
|
|
* [list_for_user](#list_for_user) - List models filtered by user provider preferences, privacy settings, and guardrails
|
|
|
|
## count
|
|
|
|
Get total count of available models
|
|
|
|
### Example Usage
|
|
|
|
<!-- UsageSnippet language="python" operationID="listModelsCount" method="get" path="/models/count" -->
|
|
```python
|
|
from openrouter import OpenRouter
|
|
import os
|
|
|
|
|
|
with OpenRouter(
|
|
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
|
) as open_router:
|
|
|
|
res = open_router.models.count()
|
|
|
|
# Handle response
|
|
print(res)
|
|
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
|
|
|
|
### Response
|
|
|
|
**[components.ModelsCountResponse](../../components/modelscountresponse.md)**
|
|
|
|
### Errors
|
|
|
|
| Error Type | Status Code | Content Type |
|
|
| ---------------------------------- | ---------------------------------- | ---------------------------------- |
|
|
| errors.InternalServerResponseError | 500 | application/json |
|
|
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |
|
|
|
|
## list
|
|
|
|
List all models and their properties
|
|
|
|
### Example Usage
|
|
|
|
<!-- UsageSnippet language="python" operationID="getModels" method="get" path="/models" -->
|
|
```python
|
|
from openrouter import OpenRouter
|
|
import os
|
|
|
|
|
|
with OpenRouter(
|
|
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
|
) as open_router:
|
|
|
|
res = open_router.models.list()
|
|
|
|
# Handle response
|
|
print(res)
|
|
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description | Example |
|
|
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
| `category` | [Optional[operations.Category]](../../operations/category.md) | :heavy_minus_sign: | Filter models by use case category | programming |
|
|
| `supported_parameters` | *Optional[str]* | :heavy_minus_sign: | N/A | |
|
|
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
|
|
|
### Response
|
|
|
|
**[components.ModelsListResponse](../../components/modelslistresponse.md)**
|
|
|
|
### Errors
|
|
|
|
| Error Type | Status Code | Content Type |
|
|
| ---------------------------------- | ---------------------------------- | ---------------------------------- |
|
|
| errors.BadRequestResponseError | 400 | application/json |
|
|
| errors.InternalServerResponseError | 500 | application/json |
|
|
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |
|
|
|
|
## list_for_user
|
|
|
|
List models filtered by user provider preferences, [privacy settings](https://openrouter.ai/docs/guides/privacy/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/logging#enterprise-eu-in-region-routing).
|
|
|
|
### Example Usage
|
|
|
|
<!-- UsageSnippet language="python" operationID="listModelsUser" method="get" path="/models/user" -->
|
|
```python
|
|
from openrouter import OpenRouter, operations
|
|
import os
|
|
|
|
|
|
with OpenRouter() as open_router:
|
|
|
|
res = open_router.models.list_for_user(security=operations.ListModelsUserSecurity(
|
|
bearer=os.getenv("OPENROUTER_BEARER", ""),
|
|
))
|
|
|
|
# Handle response
|
|
print(res)
|
|
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
|
|
| `security` | [operations.ListModelsUserSecurity](../../operations/listmodelsusersecurity.md) | :heavy_check_mark: | The security requirements to use for the request. |
|
|
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
|
|
|
|
### Response
|
|
|
|
**[components.ModelsListResponse](../../components/modelslistresponse.md)**
|
|
|
|
### Errors
|
|
|
|
| Error Type | Status Code | Content Type |
|
|
| ---------------------------------- | ---------------------------------- | ---------------------------------- |
|
|
| errors.UnauthorizedResponseError | 401 | application/json |
|
|
| errors.NotFoundResponseError | 404 | application/json |
|
|
| errors.InternalServerResponseError | 500 | application/json |
|
|
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | |