Commits included in this export:

- 6ddaaa6989d725bbe966e45f7aed0c1bd72f9153
  - 4779741b6ba710b1299612b82e8544516bd9dd6a
  - 22083fcc8f58884d8212d6f3314b231c4ddd21cd
  - a925a620f97196d509e073a163caac053bd82316
  - 5c05d8829784601ffd151acef1a6978c266f913d
  - 6f4fff535fbf4274255c255ae23620b8e00e614f
  - ef358e96cb01e469b77d44683603a602b0813116
  - e6299b4ebfe5c2eed6c598771f0fd99f84555401
  - 24d3f0ee1c2aa19a62f7902836034080b9246813
  - 68922847c2969b773887310eb7aa9a814e199c5a
  - 729ee2338c39df22461526153e7f4ba868fd498e
  - e1074ff86fccf5e48406b7595298873106d3cc5a
  - 123bbdaf841d299162a82ee2573adfbb70a45b8f
  - ac457b8a8dad98fdf5ddcae8dd4711361cea3084
  - ea825199f4c59dd68fec01cf8d18a582963c9f25
  - 4d48e4f6bb936e785787314a965298da6b78fea0
  - 718729a573ee98893a4408d5a52ab4686661fe54
  - b867adcde6b64f3f2a11c4626254b39098e4b0b4
  - 21912c097b4066d109766c6b4492826595cd57c5
  - bc1ed85adc976a4634ca8a41b82e4fc2c39a864f
  - d145c89c941937a312ed1357590d2bfda9a3603d
  - 12f05b5dee397ead47cfcd545a7a2e3c7ff57524
  - dd28f75a19a015809797c7abf3f8758f7c37262e
  - c96e569781e07ab44172d9c69940ec17bafd81f4
  - c9d5a90e3c2b5077a2bdd49773f1a46d1a5a79c7
  - 58b08f87116ceab9076de2fdc0a4c74c919b44c4

GitOrigin-RevId: 6ddaaa6989d725bbe966e45f7aed0c1bd72f9153
This commit is contained in:
OpenRouter Team
2026-02-05 23:15:21 +00:00
parent 0c791b04d1
commit 1cad51abb6
247 changed files with 8079 additions and 4566 deletions
+9 -5
View File
@@ -11,7 +11,7 @@ Analytics and usage endpoints
## get_user_activity
Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Returns user activity data grouped by endpoint for the last 30 (completed) UTC days. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -22,6 +22,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -34,10 +36,12 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- |
| `date_` | *Optional[str]* | :heavy_minus_sign: | Filter by a single UTC date in the last 30 days (YYYY-MM-DD format). | 2025-08-24 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `date_` | *Optional[str]* | :heavy_minus_sign: | Filter by a single UTC date in the last 30 days (YYYY-MM-DD format). | 2025-08-24 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
+45 -21
View File
@@ -16,7 +16,7 @@ API key management endpoints
## list
List all API keys for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
List all API keys for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -27,6 +27,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -39,11 +41,13 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `include_disabled` | *Optional[str]* | :heavy_minus_sign: | Whether to include disabled API keys in the response | false |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of API keys to skip for pagination | 0 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `include_disabled` | *Optional[str]* | :heavy_minus_sign: | Whether to include disabled API keys in the response | false |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of API keys to skip for pagination | 0 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -60,7 +64,7 @@ with OpenRouter(
## create
Create a new API key for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Create a new API key for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -71,6 +75,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -86,6 +92,8 @@ with OpenRouter(
| Parameter | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | *str* | :heavy_check_mark: | Name for the new API key | My New API Key |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `limit` | *OptionalNullable[float]* | :heavy_minus_sign: | Optional spending limit for the API key in USD | 50 |
| `limit_reset` | [OptionalNullable[operations.CreateKeysLimitReset]](../../operations/createkeyslimitreset.md) | :heavy_minus_sign: | Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday. | monthly |
| `include_byok_in_limit` | *Optional[bool]* | :heavy_minus_sign: | Whether to include BYOK usage in the limit | true |
@@ -108,7 +116,7 @@ with OpenRouter(
## update
Update an existing API key. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Update an existing API key. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -119,6 +127,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -134,6 +144,8 @@ with OpenRouter(
| Parameter | Type | Required | Description | Example |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `hash` | *str* | :heavy_check_mark: | The hash identifier of the API key to update | f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943 |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `name` | *Optional[str]* | :heavy_minus_sign: | New name for the API key | Updated API Key Name |
| `disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether to disable the API key | false |
| `limit` | *OptionalNullable[float]* | :heavy_minus_sign: | New spending limit for the API key in USD | 75 |
@@ -158,7 +170,7 @@ with OpenRouter(
## delete
Delete an existing API key. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Delete an existing API key. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -169,6 +181,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -181,10 +195,12 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `hash` | *str* | :heavy_check_mark: | The hash identifier of the API key to delete | f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `hash` | *str* | :heavy_check_mark: | The hash identifier of the API key to delete | f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943 |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -202,7 +218,7 @@ with OpenRouter(
## get
Get a single API key by hash. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Get a single API key by hash. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -213,6 +229,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -225,10 +243,12 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `hash` | *str* | :heavy_check_mark: | The hash identifier of the API key to retrieve | f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `hash` | *str* | :heavy_check_mark: | The hash identifier of the API key to retrieve | f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943 |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -257,6 +277,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -269,9 +291,11 @@ with OpenRouter(
### 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. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response
+36 -32
View File
@@ -20,6 +20,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -34,38 +36,40 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `messages` | List[[components.Message](../../components/message.md)] | :heavy_check_mark: | N/A |
| `provider` | [OptionalNullable[components.ChatGenerationParamsProvider]](../../components/chatgenerationparamsprovider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. |
| `plugins` | List[[components.ChatGenerationParamsPluginUnion](../../components/chatgenerationparamspluginunion.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. |
| `route` | [OptionalNullable[components.Route]](../../components/route.md) | :heavy_minus_sign: | N/A |
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `session_id` | *Optional[str]* | :heavy_minus_sign: | 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. |
| `model` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `models` | List[*str*] | :heavy_minus_sign: | N/A |
| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | N/A |
| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A |
| `top_logprobs` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `max_completion_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | N/A |
| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `reasoning` | [Optional[components.Reasoning]](../../components/reasoning.md) | :heavy_minus_sign: | N/A |
| `response_format` | [Optional[components.ChatGenerationParamsResponseFormatUnion]](../../components/chatgenerationparamsresponseformatunion.md) | :heavy_minus_sign: | N/A |
| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A |
| `stop` | [OptionalNullable[components.ChatGenerationParamsStop]](../../components/chatgenerationparamsstop.md) | :heavy_minus_sign: | N/A |
| `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A |
| `stream_options` | [OptionalNullable[components.ChatStreamOptions]](../../components/chatstreamoptions.md) | :heavy_minus_sign: | N/A |
| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `tool_choice` | *Optional[Any]* | :heavy_minus_sign: | N/A |
| `tools` | List[[components.ToolDefinitionJSON](../../components/tooldefinitionjson.md)] | :heavy_minus_sign: | N/A |
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `debug` | [Optional[components.Debug]](../../components/debug.md) | :heavy_minus_sign: | N/A |
| `image_config` | Dict[str, [components.ChatGenerationParamsImageConfig](../../components/chatgenerationparamsimageconfig.md)] | :heavy_minus_sign: | N/A |
| `modalities` | List[[components.Modality](../../components/modality.md)] | :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. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `messages` | List[[components.Message](../../components/message.md)] | :heavy_check_mark: | N/A |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `provider` | [OptionalNullable[components.Schema0]](../../components/schema0.md) | :heavy_minus_sign: | N/A |
| `plugins` | List[[components.Schema17](../../components/schema17.md)] | :heavy_minus_sign: | N/A |
| `route` | [OptionalNullable[components.Route]](../../components/route.md) | :heavy_minus_sign: | N/A |
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `session_id` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `model` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `models` | List[*str*] | :heavy_minus_sign: | N/A |
| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | N/A |
| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A |
| `top_logprobs` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `max_completion_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | N/A |
| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `reasoning` | [Optional[components.Reasoning]](../../components/reasoning.md) | :heavy_minus_sign: | N/A |
| `response_format` | [Optional[components.ResponseFormat]](../../components/responseformat.md) | :heavy_minus_sign: | N/A |
| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A |
| `stop` | [OptionalNullable[components.Stop]](../../components/stop.md) | :heavy_minus_sign: | N/A |
| `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A |
| `stream_options` | [OptionalNullable[components.ChatStreamOptions]](../../components/chatstreamoptions.md) | :heavy_minus_sign: | N/A |
| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `tool_choice` | *Optional[Any]* | :heavy_minus_sign: | N/A |
| `tools` | List[[components.ToolDefinitionJSON](../../components/tooldefinitionjson.md)] | :heavy_minus_sign: | N/A |
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `debug` | [Optional[components.Debug]](../../components/debug.md) | :heavy_minus_sign: | N/A |
| `image_config` | Dict[str, [components.ChatGenerationParamsImageConfig](../../components/chatgenerationparamsimageconfig.md)] | :heavy_minus_sign: | N/A |
| `modalities` | List[[components.Modality](../../components/modality.md)] | :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
-70
View File
@@ -1,70 +0,0 @@
# Completions
(*completions*)
## Overview
### Available Operations
* [generate](#generate) - Create a completion
## generate
Creates a completion for the provided prompt and parameters. Supports both streaming and non-streaming modes.
### Example Usage
<!-- UsageSnippet language="python" operationID="createCompletions" method="post" path="/completions" -->
```python
from openrouter import OpenRouter
import os
with OpenRouter(
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
res = open_router.completions.generate(prompt=[], stream=False)
# Handle response
print(res)
```
### Parameters
| Parameter | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `prompt` | [components.Prompt](../../components/prompt.md) | :heavy_check_mark: | N/A |
| `model` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `models` | List[*str*] | :heavy_minus_sign: | N/A |
| `best_of` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A |
| `echo` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A |
| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | N/A |
| `logprobs` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A |
| `max_tokens` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A |
| `n` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A |
| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A |
| `stop` | [OptionalNullable[components.CompletionCreateParamsStop]](../../components/completioncreateparamsstop.md) | :heavy_minus_sign: | N/A |
| `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A |
| `stream_options` | [OptionalNullable[components.StreamOptions]](../../components/streamoptions.md) | :heavy_minus_sign: | N/A |
| `suffix` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | N/A |
| `response_format` | [OptionalNullable[components.CompletionCreateParamsResponseFormatUnion]](../../components/completioncreateparamsresponseformatunion.md) | :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.CompletionResponse](../../components/completionresponse.md)**
### Errors
| Error Type | Status Code | Content Type |
| ----------------------------- | ----------------------------- | ----------------------------- |
| errors.ChatError | 400, 401, 429 | application/json |
| errors.ChatError | 500 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |
+21 -12
View File
@@ -12,7 +12,7 @@ Credit management endpoints
## get_credits
Get total credits purchased and used for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Get total credits purchased and used for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -23,6 +23,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -35,9 +37,11 @@ with OpenRouter(
### 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. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response
@@ -64,7 +68,10 @@ from openrouter import OpenRouter, operations
import os
with OpenRouter() as open_router:
with OpenRouter(
http_referer="<value>",
x_title="<value>",
) as open_router:
res = open_router.credits.create_coinbase_charge(security=operations.CreateCoinbaseChargeSecurity(
bearer=os.getenv("OPENROUTER_BEARER", ""),
@@ -77,13 +84,15 @@ with OpenRouter() as open_router:
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `security` | [operations.CreateCoinbaseChargeSecurity](../../operations/createcoinbasechargesecurity.md) | :heavy_check_mark: | N/A |
| `amount` | *float* | :heavy_check_mark: | N/A |
| `sender` | *str* | :heavy_check_mark: | N/A |
| `chain_id` | [components.ChainID](../../components/chainid.md) | :heavy_check_mark: | N/A |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `security` | [operations.CreateCoinbaseChargeSecurity](../../operations/createcoinbasechargesecurity.md) | :heavy_check_mark: | N/A |
| `amount` | *float* | :heavy_check_mark: | N/A |
| `sender` | *str* | :heavy_check_mark: | N/A |
| `chain_id` | [components.ChainID](../../components/chainid.md) | :heavy_check_mark: | N/A |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response
+21 -13
View File
@@ -23,6 +23,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -35,16 +37,18 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `input` | [operations.InputUnion](../../operations/inputunion.md) | :heavy_check_mark: | N/A |
| `model` | *str* | :heavy_check_mark: | N/A |
| `encoding_format` | [Optional[operations.EncodingFormat]](../../operations/encodingformat.md) | :heavy_minus_sign: | N/A |
| `dimensions` | *Optional[int]* | :heavy_minus_sign: | N/A |
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `provider` | [Optional[components.ProviderPreferences]](../../components/providerpreferences.md) | :heavy_minus_sign: | Provider routing preferences for the request. |
| `input_type` | *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. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `input` | [operations.InputUnion](../../operations/inputunion.md) | :heavy_check_mark: | N/A |
| `model` | *str* | :heavy_check_mark: | N/A |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `encoding_format` | [Optional[operations.EncodingFormat]](../../operations/encodingformat.md) | :heavy_minus_sign: | N/A |
| `dimensions` | *Optional[int]* | :heavy_minus_sign: | N/A |
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `provider` | [Optional[components.ProviderPreferences]](../../components/providerpreferences.md) | :heavy_minus_sign: | Provider routing preferences for the request. |
| `input_type` | *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
@@ -79,6 +83,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -91,9 +97,11 @@ with OpenRouter(
### 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. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response
+16 -8
View File
@@ -23,6 +23,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -35,11 +37,13 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `author` | *str* | :heavy_check_mark: | N/A |
| `slug` | *str* | :heavy_check_mark: | N/A |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `author` | *str* | :heavy_check_mark: | N/A |
| `slug` | *str* | :heavy_check_mark: | N/A |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response
@@ -66,6 +70,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -78,9 +84,11 @@ with OpenRouter(
### 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. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response
+8 -4
View File
@@ -22,6 +22,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -34,10 +36,12 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | N/A |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | N/A |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response
+141 -89
View File
@@ -23,7 +23,7 @@ Guardrails endpoints
## list
List all guardrails for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
List all guardrails for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -34,6 +34,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -46,11 +48,13 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
| `limit` | *Optional[str]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
| `limit` | *Optional[str]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -66,7 +70,7 @@ with OpenRouter(
## create
Create a new guardrail for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Create a new guardrail for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -77,6 +81,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -89,16 +95,18 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `name` | *str* | :heavy_check_mark: | Name for the new guardrail | My New Guardrail |
| `description` | *OptionalNullable[str]* | :heavy_minus_sign: | Description of the guardrail | A guardrail for limiting API usage |
| `limit_usd` | *OptionalNullable[float]* | :heavy_minus_sign: | Spending limit in USD | 50 |
| `reset_interval` | [OptionalNullable[operations.CreateGuardrailResetIntervalRequest]](../../operations/createguardrailresetintervalrequest.md) | :heavy_minus_sign: | Interval at which the limit resets (daily, weekly, monthly) | monthly |
| `allowed_providers` | List[*str*] | :heavy_minus_sign: | List of allowed provider IDs | [<br/>"openai",<br/>"anthropic",<br/>"deepseek"<br/>] |
| `allowed_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers (slug or canonical_slug accepted) | [<br/>"openai/gpt-5.2",<br/>"anthropic/claude-4.5-opus-20251124",<br/>"deepseek/deepseek-r1-0528:free"<br/>] |
| `enforce_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention | false |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | *str* | :heavy_check_mark: | Name for the new guardrail | My New Guardrail |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `description` | *OptionalNullable[str]* | :heavy_minus_sign: | Description of the guardrail | A guardrail for limiting API usage |
| `limit_usd` | *OptionalNullable[float]* | :heavy_minus_sign: | Spending limit in USD | 50 |
| `reset_interval` | [OptionalNullable[operations.CreateGuardrailResetIntervalRequest]](../../operations/createguardrailresetintervalrequest.md) | :heavy_minus_sign: | Interval at which the limit resets (daily, weekly, monthly) | monthly |
| `allowed_providers` | List[*str*] | :heavy_minus_sign: | List of allowed provider IDs | [<br/>"openai",<br/>"anthropic",<br/>"deepseek"<br/>] |
| `allowed_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers (slug or canonical_slug accepted) | [<br/>"openai/gpt-5.2",<br/>"anthropic/claude-4.5-opus-20251124",<br/>"deepseek/deepseek-r1-0528:free"<br/>] |
| `enforce_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention | false |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -115,7 +123,7 @@ with OpenRouter(
## get
Get a single guardrail by ID. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Get a single guardrail by ID. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -126,6 +134,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -138,10 +148,12 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail to retrieve | 550e8400-e29b-41d4-a716-446655440000 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail to retrieve | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -158,7 +170,7 @@ with OpenRouter(
## update
Update an existing guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Update an existing guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -169,6 +181,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -181,17 +195,19 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail to update | 550e8400-e29b-41d4-a716-446655440000 |
| `name` | *Optional[str]* | :heavy_minus_sign: | New name for the guardrail | Updated Guardrail Name |
| `description` | *OptionalNullable[str]* | :heavy_minus_sign: | New description for the guardrail | Updated description |
| `limit_usd` | *OptionalNullable[float]* | :heavy_minus_sign: | New spending limit in USD | 75 |
| `reset_interval` | [OptionalNullable[operations.UpdateGuardrailResetIntervalRequest]](../../operations/updateguardrailresetintervalrequest.md) | :heavy_minus_sign: | Interval at which the limit resets (daily, weekly, monthly) | monthly |
| `allowed_providers` | List[*str*] | :heavy_minus_sign: | New list of allowed provider IDs | [<br/>"openai",<br/>"anthropic",<br/>"deepseek"<br/>] |
| `allowed_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers (slug or canonical_slug accepted) | [<br/>"openai/gpt-5.2"<br/>] |
| `enforce_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention | true |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail to update | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `name` | *Optional[str]* | :heavy_minus_sign: | New name for the guardrail | Updated Guardrail Name |
| `description` | *OptionalNullable[str]* | :heavy_minus_sign: | New description for the guardrail | Updated description |
| `limit_usd` | *OptionalNullable[float]* | :heavy_minus_sign: | New spending limit in USD | 75 |
| `reset_interval` | [OptionalNullable[operations.UpdateGuardrailResetIntervalRequest]](../../operations/updateguardrailresetintervalrequest.md) | :heavy_minus_sign: | Interval at which the limit resets (daily, weekly, monthly) | monthly |
| `allowed_providers` | List[*str*] | :heavy_minus_sign: | New list of allowed provider IDs | [<br/>"openai",<br/>"anthropic",<br/>"deepseek"<br/>] |
| `allowed_models` | List[*str*] | :heavy_minus_sign: | Array of model identifiers (slug or canonical_slug accepted) | [<br/>"openai/gpt-5.2"<br/>] |
| `enforce_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to enforce zero data retention | true |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -209,7 +225,7 @@ with OpenRouter(
## delete
Delete an existing guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Delete an existing guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -220,6 +236,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -232,10 +250,12 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail to delete | 550e8400-e29b-41d4-a716-446655440000 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail to delete | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -252,7 +272,7 @@ with OpenRouter(
## list_key_assignments
List all API key guardrail assignments for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
List all API key guardrail assignments for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -263,6 +283,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -275,11 +297,13 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
| `limit` | *Optional[str]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
| `limit` | *Optional[str]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -295,7 +319,7 @@ with OpenRouter(
## list_member_assignments
List all organization member guardrail assignments for the authenticated user. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
List all organization member guardrail assignments for the authenticated user. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -306,6 +330,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -318,11 +344,13 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
| `limit` | *Optional[str]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
| `limit` | *Optional[str]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -338,7 +366,7 @@ with OpenRouter(
## list_guardrail_key_assignments
List all API key assignments for a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
List all API key assignments for a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -349,6 +377,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -361,12 +391,14 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
| `limit` | *Optional[str]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
| `limit` | *Optional[str]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -383,7 +415,7 @@ with OpenRouter(
## bulk_assign_keys
Assign multiple API keys to a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Assign multiple API keys to a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -394,6 +426,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -408,11 +442,13 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `key_hashes` | List[*str*] | :heavy_check_mark: | Array of API key hashes to assign to the guardrail | [<br/>"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"<br/>] |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `key_hashes` | List[*str*] | :heavy_check_mark: | Array of API key hashes to assign to the guardrail | [<br/>"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"<br/>] |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -430,7 +466,7 @@ with OpenRouter(
## list_guardrail_member_assignments
List all organization member assignments for a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
List all organization member assignments for a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -441,6 +477,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -453,12 +491,14 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
| `limit` | *Optional[str]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `offset` | *Optional[str]* | :heavy_minus_sign: | Number of records to skip for pagination | 0 |
| `limit` | *Optional[str]* | :heavy_minus_sign: | Maximum number of records to return (max 100) | 50 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -475,7 +515,7 @@ with OpenRouter(
## bulk_assign_members
Assign multiple organization members to a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Assign multiple organization members to a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -486,6 +526,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -501,11 +543,13 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `member_user_ids` | List[*str*] | :heavy_check_mark: | Array of member user IDs to assign to the guardrail | [<br/>"user_abc123",<br/>"user_def456"<br/>] |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `member_user_ids` | List[*str*] | :heavy_check_mark: | Array of member user IDs to assign to the guardrail | [<br/>"user_abc123",<br/>"user_def456"<br/>] |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -523,7 +567,7 @@ with OpenRouter(
## bulk_unassign_keys
Unassign multiple API keys from a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Unassign multiple API keys from a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -534,6 +578,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -548,11 +594,13 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `key_hashes` | List[*str*] | :heavy_check_mark: | Array of API key hashes to unassign from the guardrail | [<br/>"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"<br/>] |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `key_hashes` | List[*str*] | :heavy_check_mark: | Array of API key hashes to unassign from the guardrail | [<br/>"c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"<br/>] |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -570,7 +618,7 @@ with OpenRouter(
## bulk_unassign_members
Unassign multiple organization members from a specific guardrail. [Provisioning key](/docs/guides/overview/auth/provisioning-api-keys) required.
Unassign multiple organization members from a specific guardrail. [Management key](/docs/guides/overview/auth/management-api-keys) required.
### Example Usage
@@ -581,6 +629,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -596,11 +646,13 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `member_user_ids` | List[*str*] | :heavy_check_mark: | Array of member user IDs to unassign from the guardrail | [<br/>"user_abc123",<br/>"user_def456"<br/>] |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | *str* | :heavy_check_mark: | The unique identifier of the guardrail | 550e8400-e29b-41d4-a716-446655440000 |
| `member_user_ids` | List[*str*] | :heavy_check_mark: | Array of member user IDs to unassign from the guardrail | [<br/>"user_abc123",<br/>"user_def456"<br/>] |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
+29 -15
View File
@@ -9,7 +9,7 @@ Model information endpoints
* [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
* [list_for_user](#list_for_user) - List models filtered by user provider preferences, privacy settings, and guardrails
## count
@@ -24,6 +24,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -36,9 +38,11 @@ with OpenRouter(
### 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. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response
@@ -64,6 +68,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -76,11 +82,13 @@ with OpenRouter(
### 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. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `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
@@ -96,7 +104,7 @@ with OpenRouter(
## list_for_user
List models filtered by user provider preferences
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
@@ -106,7 +114,10 @@ from openrouter import OpenRouter, operations
import os
with OpenRouter() as open_router:
with OpenRouter(
http_referer="<value>",
x_title="<value>",
) as open_router:
res = open_router.models.list_for_user(security=operations.ListModelsUserSecurity(
bearer=os.getenv("OPENROUTER_BEARER", ""),
@@ -119,10 +130,12 @@ with OpenRouter() as open_router:
### 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. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `security` | [operations.ListModelsUserSecurity](../../operations/listmodelsusersecurity.md) | :heavy_check_mark: | N/A |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response
@@ -133,5 +146,6 @@ with OpenRouter() as open_router:
| 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 | \*/\* |
+22 -14
View File
@@ -23,6 +23,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -35,12 +37,14 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `code` | *str* | :heavy_check_mark: | The authorization code received from the OAuth redirect | auth_code_abc123def456 |
| `code_verifier` | *Optional[str]* | :heavy_minus_sign: | The code verifier if code_challenge was used in the authorization request | dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk |
| `code_challenge_method` | [OptionalNullable[operations.ExchangeAuthCodeForAPIKeyCodeChallengeMethod]](../../operations/exchangeauthcodeforapikeycodechallengemethod.md) | :heavy_minus_sign: | The method used to generate the code challenge | S256 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `code` | *str* | :heavy_check_mark: | The authorization code received from the OAuth redirect | auth_code_abc123def456 |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `code_verifier` | *Optional[str]* | :heavy_minus_sign: | The code verifier if code_challenge was used in the authorization request | dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk |
| `code_challenge_method` | [OptionalNullable[operations.ExchangeAuthCodeForAPIKeyCodeChallengeMethod]](../../operations/exchangeauthcodeforapikeycodechallengemethod.md) | :heavy_minus_sign: | The method used to generate the code challenge | S256 |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
@@ -68,6 +72,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -80,14 +86,16 @@ with OpenRouter(
### Parameters
| Parameter | Type | Required | Description | Example |
| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `callback_url` | *str* | :heavy_check_mark: | The callback URL to redirect to after authorization. Note, only https URLs on ports 443 and 3000 are allowed. | https://myapp.com/auth/callback |
| `code_challenge` | *Optional[str]* | :heavy_minus_sign: | PKCE code challenge for enhanced security | E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM |
| `code_challenge_method` | [Optional[operations.CreateAuthKeysCodeCodeChallengeMethod]](../../operations/createauthkeyscodecodechallengemethod.md) | :heavy_minus_sign: | The method used to generate the code challenge | S256 |
| `limit` | *Optional[float]* | :heavy_minus_sign: | Credit limit for the API key to be created | 100 |
| `expires_at` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | :heavy_minus_sign: | Optional expiration time for the API key to be created | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
| Parameter | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `callback_url` | *str* | :heavy_check_mark: | The callback URL to redirect to after authorization. Note, only https URLs on ports 443 and 3000 are allowed. | https://myapp.com/auth/callback |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `code_challenge` | *Optional[str]* | :heavy_minus_sign: | PKCE code challenge for enhanced security | E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM |
| `code_challenge_method` | [Optional[operations.CreateAuthKeysCodeCodeChallengeMethod]](../../operations/createauthkeyscodecodechallengemethod.md) | :heavy_minus_sign: | The method used to generate the code challenge | S256 |
| `limit` | *Optional[float]* | :heavy_minus_sign: | Credit limit for the API key to be created | 100 |
| `expires_at` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | :heavy_minus_sign: | Optional expiration time for the API key to be created | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response
+7 -3
View File
@@ -22,6 +22,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -34,9 +36,11 @@ with OpenRouter(
### 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. |
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response
+6 -2
View File
@@ -22,6 +22,8 @@ import os
with OpenRouter(
http_referer="<value>",
x_title="<value>",
api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:
@@ -38,6 +40,8 @@ with OpenRouter(
| Parameter | Type | Required | Description | Example |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> | |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> | |
| `input` | [Optional[components.OpenResponsesInput]](../../components/openresponsesinput.md) | :heavy_minus_sign: | Input for a response request - can be a string or array of items | [<br/>{<br/>"role": "user",<br/>"content": "What is the weather today?"<br/>}<br/>] |
| `instructions` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | 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. | {<br/>"user_id": "123",<br/>"session_id": "abc-def-ghi"<br/>} |
@@ -67,8 +71,8 @@ with OpenRouter(
| `service_tier` | [Optional[components.ServiceTier]](../../components/servicetier.md) | :heavy_minus_sign: | N/A | |
| `truncation` | [OptionalNullable[components.Truncation]](../../components/truncation.md) | :heavy_minus_sign: | N/A | auto |
| `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A | |
| `provider` | [OptionalNullable[components.OpenResponsesRequestProvider]](../../components/openresponsesrequestprovider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | |
| `plugins` | List[[components.OpenResponsesRequestPluginUnion](../../components/openresponsesrequestpluginunion.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
| `provider` | [OptionalNullable[components.Provider]](../../components/provider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | |
| `plugins` | List[[components.Plugin](../../components/plugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
| `user` | *Optional[str]* | :heavy_minus_sign: | A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters. | |
| `session_id` | *Optional[str]* | :heavy_minus_sign: | 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. | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |