mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-31 12:30:30 +08:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71ab77e5e8 | ||
|
|
05f81a553c | ||
|
|
dede1d21ec | ||
|
|
43cf059ae0 | ||
|
|
5fc522c72f |
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(python3:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
|
||||
<div align="center">
|
||||
<a href="https://codespaces.new/speakeasy-sdks/openrouter-python-sdk.git/tree/main"><img src="https://github.com/codespaces/badge.svg" /></a>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
> **Remember to shutdown a GitHub Codespace when it is not in use!**
|
||||
|
||||
# Dev Containers Quick Start
|
||||
|
||||
@@ -30,4 +30,5 @@ jobs:
|
||||
set_version: ${{ github.event.inputs.set_version }}
|
||||
secrets:
|
||||
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
pypi_token: ${{ secrets.PYPI_TOKEN }}
|
||||
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
name: Speakeasy Tagging
|
||||
name: Publish
|
||||
permissions:
|
||||
checks: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
statuses: write
|
||||
id-token: write
|
||||
"on":
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- .speakeasy/gen.lock
|
||||
workflow_dispatch: {}
|
||||
jobs:
|
||||
tag:
|
||||
uses: speakeasy-api/sdk-generation-action/.github/workflows/tag.yaml@v15
|
||||
publish:
|
||||
uses: speakeasy-api/sdk-generation-action/.github/workflows/sdk-publish.yaml@v15
|
||||
with:
|
||||
registry_tags: main
|
||||
target: open-router
|
||||
secrets:
|
||||
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
|
||||
pypi_token: ${{ secrets.PYPI_TOKEN }}
|
||||
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
|
||||
+1
-1
@@ -1,4 +1,3 @@
|
||||
.env.local
|
||||
.venv/
|
||||
venv/
|
||||
src/*.egg-info/
|
||||
@@ -11,3 +10,4 @@ pyrightconfig.json
|
||||
**/.speakeasy/logs/
|
||||
.speakeasy/reports
|
||||
.env
|
||||
.env.local
|
||||
|
||||
+984
-168
File diff suppressed because it is too large
Load Diff
+12
-5
@@ -22,28 +22,34 @@ generation:
|
||||
hoistGlobalSecurity: true
|
||||
inferSSEOverload: true
|
||||
sdkHooksConfigAccess: true
|
||||
schemas:
|
||||
allOfMergeStrategy: shallowMerge
|
||||
requestBodyFieldName: body
|
||||
tests:
|
||||
generateTests: false
|
||||
generateNewTests: true
|
||||
skipResponseBodyAssertions: false
|
||||
python:
|
||||
version: 0.6.3
|
||||
version: 0.0.4
|
||||
additionalDependencies:
|
||||
dev: {}
|
||||
main: {}
|
||||
allowedRedefinedBuiltins:
|
||||
- id
|
||||
- object
|
||||
- input
|
||||
asyncMode: both
|
||||
authors:
|
||||
- Speakeasy
|
||||
- OpenRouter
|
||||
baseErrorName: OpenRouterError
|
||||
clientServerStatusCodesAsErrors: true
|
||||
defaultErrorName: OpenRouterDefaultError
|
||||
description: Python Client SDK Generated by Speakeasy.
|
||||
enableCustomCodeRegions: true
|
||||
description: Official Python Client SDK for OpenRouter.
|
||||
enableCustomCodeRegions: false
|
||||
enumFormat: union
|
||||
envVarPrefix: OPENROUTER
|
||||
fixFlags:
|
||||
asyncPaginationSep2025: true
|
||||
responseRequiredSep2024: true
|
||||
flattenGlobalSecurity: true
|
||||
flattenRequests: true
|
||||
@@ -57,6 +63,7 @@ python:
|
||||
shared: ""
|
||||
webhooks: ""
|
||||
inputModelSuffix: input
|
||||
legacyPyright: false
|
||||
maxMethodParams: 999
|
||||
methodArguments: infer-optional-args
|
||||
moduleName: ""
|
||||
@@ -66,5 +73,5 @@ python:
|
||||
pytestFilterWarnings: []
|
||||
pytestTimeout: 0
|
||||
responseFormat: flat
|
||||
sseFlatResponse: false
|
||||
sseFlatResponse: true
|
||||
templateVersion: v2
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+8347
-1531
File diff suppressed because it is too large
Load Diff
+15
-16
@@ -1,38 +1,37 @@
|
||||
speakeasyVersion: 1.617.1
|
||||
speakeasyVersion: 1.656.2
|
||||
sources:
|
||||
OpenRouter Chat Completions API:
|
||||
-OAS:
|
||||
sourceNamespace: open-router-chat-completions-api
|
||||
sourceRevisionDigest: sha256:a7746404e672bbb6dcd8354532d0c627d24522844c39d58011d4cd9c7e8ebd20
|
||||
sourceBlobDigest: sha256:67c793fef9c039a2c351fc6ba7ed9a6119059023fe3fbd1022645d7494c2c63c
|
||||
sourceRevisionDigest: sha256:08647b466c00989914e3a2436175152270f771f0a57d055f5bab14cc2d4be89e
|
||||
sourceBlobDigest: sha256:53027ec57392d9617cc001ece83c2fe1aa6e5dbfd52d170381c34c33c6042c23
|
||||
tags:
|
||||
- latest
|
||||
- speakeasy-sdk-regen-1757290070
|
||||
- 1.0.0
|
||||
targets:
|
||||
open-router:
|
||||
source: OpenRouter Chat Completions API
|
||||
source: -OAS
|
||||
sourceNamespace: open-router-chat-completions-api
|
||||
sourceRevisionDigest: sha256:a7746404e672bbb6dcd8354532d0c627d24522844c39d58011d4cd9c7e8ebd20
|
||||
sourceBlobDigest: sha256:67c793fef9c039a2c351fc6ba7ed9a6119059023fe3fbd1022645d7494c2c63c
|
||||
codeSamplesNamespace: open-router-chat-completions-api-python-code-samples
|
||||
codeSamplesRevisionDigest: sha256:fb054934c4d0de58a48ca8cdfde7b4210f71c425fb9dfad02e8824b8a1848774
|
||||
sourceRevisionDigest: sha256:08647b466c00989914e3a2436175152270f771f0a57d055f5bab14cc2d4be89e
|
||||
sourceBlobDigest: sha256:53027ec57392d9617cc001ece83c2fe1aa6e5dbfd52d170381c34c33c6042c23
|
||||
workflow:
|
||||
workflowVersion: 1.0.0
|
||||
speakeasyVersion: latest
|
||||
sources:
|
||||
OpenRouter Chat Completions API:
|
||||
-OAS:
|
||||
inputs:
|
||||
- location: .speakeasy/in.openapi.yaml
|
||||
- location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api:main
|
||||
output: .speakeasy/out.openapi.yaml
|
||||
registry:
|
||||
location: registry.speakeasyapi.dev/sheldon-vaughn-test/sandbox/open-router-chat-completions-api
|
||||
location: registry.speakeasyapi.dev/openrouter/sdk/-oas
|
||||
targets:
|
||||
open-router:
|
||||
target: python
|
||||
source: OpenRouter Chat Completions API
|
||||
source: -OAS
|
||||
publish:
|
||||
pypi:
|
||||
token: $pypi_token
|
||||
codeSamples:
|
||||
registry:
|
||||
location: registry.speakeasyapi.dev/sheldon-vaughn-test/sandbox/open-router-chat-completions-api-python-code-samples
|
||||
location: registry.speakeasyapi.dev/openrouter/sdk/-oas-python-code-samples
|
||||
labelOverride:
|
||||
fixedValue: Python (SDK)
|
||||
blocking: false
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
workflowVersion: 1.0.0
|
||||
speakeasyVersion: latest
|
||||
sources:
|
||||
OpenRouter Chat Completions API:
|
||||
-OAS:
|
||||
inputs:
|
||||
- location: .speakeasy/in.openapi.yaml
|
||||
- location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api:main
|
||||
output: .speakeasy/out.openapi.yaml
|
||||
registry:
|
||||
location: registry.speakeasyapi.dev/sheldon-vaughn-test/sandbox/open-router-chat-completions-api
|
||||
location: registry.speakeasyapi.dev/openrouter/sdk/-oas
|
||||
targets:
|
||||
open-router:
|
||||
target: python
|
||||
source: OpenRouter Chat Completions API
|
||||
source: -OAS
|
||||
publish:
|
||||
pypi:
|
||||
token: $pypi_token
|
||||
codeSamples:
|
||||
registry:
|
||||
location: registry.speakeasyapi.dev/sheldon-vaughn-test/sandbox/open-router-chat-completions-api-python-code-samples
|
||||
location: registry.speakeasyapi.dev/openrouter/sdk/-oas-python-code-samples
|
||||
labelOverride:
|
||||
fixedValue: Python (SDK)
|
||||
blocking: false
|
||||
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
# OpenRouter Python SDK
|
||||
|
||||
The OpenRouter Python SDK is a type-safe toolkit for building AI applications with access to 300+ language models through a unified API.
|
||||
|
||||
## Why use the OpenRouter SDK?
|
||||
|
||||
Integrating AI models into applications involves handling different provider APIs, managing model-specific requirements, and avoiding common implementation mistakes. The OpenRouter SDK standardizes these integrations and protects you from footguns.
|
||||
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY")
|
||||
) as client:
|
||||
response = client.chat.send(
|
||||
model="minimax/minimax-m2",
|
||||
messages=[
|
||||
{"role": "user", "content": "Explain quantum computing"}
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
The SDK provides three core benefits:
|
||||
|
||||
### Auto-generated from API specifications
|
||||
|
||||
The SDK is automatically generated from OpenRouter's OpenAPI specs and updated with every API change. New models, parameters, and features appear in your IDE autocomplete immediately. No manual updates. No version drift.
|
||||
|
||||
```python
|
||||
# When new models launch, they're available instantly
|
||||
response = client.chat.send(
|
||||
model="minimax/minimax-m2"
|
||||
)
|
||||
```
|
||||
|
||||
### Type-safe by default
|
||||
|
||||
Every parameter, response field, and configuration option is fully typed with Python type hints and validated with Pydantic. Invalid configurations are caught at runtime with clear error messages.
|
||||
|
||||
```python
|
||||
response = client.chat.send(
|
||||
model="minimax/minimax-m2",
|
||||
messages=[
|
||||
{"role": "user", "content": "Hello"}
|
||||
# ← Pydantic validates message structure
|
||||
],
|
||||
temperature=0.7, # ← Type-checked and validated
|
||||
stream=True # ← Response type changes based on this
|
||||
)
|
||||
```
|
||||
|
||||
**Actionable error messages:**
|
||||
|
||||
```python
|
||||
# Instead of generic errors, get specific guidance:
|
||||
# "Model 'openai/o1-preview' requires at least 2 messages.
|
||||
# You provided 1 message. Add a system or user message."
|
||||
```
|
||||
|
||||
**Type-safe streaming:**
|
||||
|
||||
```python
|
||||
stream = client.chat.send(
|
||||
model="minimax/minimax-m2",
|
||||
messages=[{"role": "user", "content": "Write a story"}],
|
||||
stream=True
|
||||
)
|
||||
|
||||
for event in stream:
|
||||
# Full type information for streaming responses
|
||||
content = event.choices[0].delta.content if event.choices else None
|
||||
```
|
||||
|
||||
**Async support:**
|
||||
|
||||
```python
|
||||
import asyncio
|
||||
|
||||
async def main():
|
||||
async with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY")
|
||||
) as client:
|
||||
response = await client.chat.send_async(
|
||||
model="minimax/minimax-m2",
|
||||
messages=[{"role": "user", "content": "Hello"}]
|
||||
)
|
||||
print(response.choices[0].message.content)
|
||||
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# Using uv (recommended)
|
||||
uv add openrouter
|
||||
|
||||
# Using pip
|
||||
pip install openrouter
|
||||
|
||||
# Using poetry
|
||||
poetry add openrouter
|
||||
```
|
||||
|
||||
**Requirements:** Python 3.9 or higher
|
||||
|
||||
Get your API key from [openrouter.ai/settings/keys](https://openrouter.ai/settings/keys).
|
||||
|
||||
## Quick start
|
||||
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY")
|
||||
) as client:
|
||||
response = client.chat.send(
|
||||
model="minimax/minimax-m2",
|
||||
messages=[
|
||||
{"role": "user", "content": "Hello!"}
|
||||
]
|
||||
)
|
||||
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
-607
@@ -1,607 +0,0 @@
|
||||
|
||||
|
||||
|
||||
<div align="center">
|
||||
<img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/19d8ad52-cb56-4f87-8bce-9a9c2233ac16" />
|
||||
<h1>OpenRouter Python SDK</h1>
|
||||
<p>Developer-friendly Python SDK specifically catered to leverage the <strong>OpenRouter</strong> API.</p>
|
||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" /></a>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Start Summary [summary] -->
|
||||
## Summary
|
||||
|
||||
OpenRouter Chat Completions API: OpenAI-compatible Chat Completions API with additional OpenRouter features
|
||||
|
||||
For more information about the API: [OpenRouter Documentation](https://openrouter.ai/docs)
|
||||
<!-- End Summary [summary] -->
|
||||
|
||||
<!-- Start Table of Contents [toc] -->
|
||||
## Table of Contents
|
||||
<!-- $toc-max-depth=2 -->
|
||||
* [SDK Installation](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#sdk-installation)
|
||||
* [IDE Support](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#ide-support)
|
||||
* [SDK Example Usage](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#sdk-example-usage)
|
||||
* [Authentication](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#authentication)
|
||||
* [Available Resources and Operations](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#available-resources-and-operations)
|
||||
* [Server-sent event streaming](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#server-sent-event-streaming)
|
||||
* [Retries](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#retries)
|
||||
* [Error Handling](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#error-handling)
|
||||
* [Server Selection](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#server-selection)
|
||||
* [Custom HTTP Client](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#custom-http-client)
|
||||
* [Resource Management](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#resource-management)
|
||||
* [Debugging](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#debugging)
|
||||
* [Development](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#development)
|
||||
* [Maturity](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#maturity)
|
||||
* [Contributions](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#contributions)
|
||||
|
||||
<!-- End Table of Contents [toc] -->
|
||||
|
||||
<!-- Start SDK Installation [installation] -->
|
||||
## SDK Installation
|
||||
|
||||
> [!TIP]
|
||||
> To finish publishing your SDK to PyPI you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
|
||||
|
||||
|
||||
> [!NOTE]
|
||||
> **Python version upgrade policy**
|
||||
>
|
||||
> Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
|
||||
|
||||
The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
|
||||
|
||||
### uv
|
||||
|
||||
*uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
|
||||
|
||||
```bash
|
||||
uv add git+https://github.com/speakeasy-sdks/openrouter-python-sdk.git
|
||||
```
|
||||
|
||||
### PIP
|
||||
|
||||
*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
|
||||
|
||||
```bash
|
||||
pip install git+https://github.com/speakeasy-sdks/openrouter-python-sdk.git
|
||||
```
|
||||
|
||||
### Poetry
|
||||
|
||||
*Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
|
||||
|
||||
```bash
|
||||
poetry add git+https://github.com/speakeasy-sdks/openrouter-python-sdk.git
|
||||
```
|
||||
|
||||
### Shell and script usage with `uv`
|
||||
|
||||
You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:
|
||||
|
||||
```shell
|
||||
uvx --from openrouter python
|
||||
```
|
||||
|
||||
It's also possible to write a standalone Python script without needing to set up a whole project like so:
|
||||
|
||||
```python
|
||||
#!/usr/bin/env -S uv run --script
|
||||
# /// script
|
||||
# requires-python = ">=3.9"
|
||||
# dependencies = [
|
||||
# "openrouter",
|
||||
# ]
|
||||
# ///
|
||||
|
||||
from openrouter import OpenRouter
|
||||
|
||||
sdk = OpenRouter(
|
||||
# SDK arguments
|
||||
)
|
||||
|
||||
# Rest of script here...
|
||||
```
|
||||
|
||||
Once that is saved to a file, you can run it with `uv run script.py` where
|
||||
`script.py` can be replaced with the actual file name.
|
||||
<!-- End SDK Installation [installation] -->
|
||||
|
||||
<!-- Start IDE Support [idesupport] -->
|
||||
## IDE Support
|
||||
|
||||
### PyCharm
|
||||
|
||||
Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
|
||||
|
||||
- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
|
||||
<!-- End IDE Support [idesupport] -->
|
||||
|
||||
<!-- Start SDK Example Usage [usage] -->
|
||||
## SDK Example Usage
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
# Synchronous Example
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
```
|
||||
|
||||
</br>
|
||||
|
||||
The same SDK client can also be used to make asynchronous requests by importing asyncio.
|
||||
```python
|
||||
# Asynchronous Example
|
||||
import asyncio
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
async def main():
|
||||
|
||||
async with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = await open_router.chat.complete_async(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
async with res as event_stream:
|
||||
async for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
asyncio.run(main())
|
||||
```
|
||||
<!-- End SDK Example Usage [usage] -->
|
||||
|
||||
<!-- Start Authentication [security] -->
|
||||
## Authentication
|
||||
|
||||
### Per-Client Security Schemes
|
||||
|
||||
This SDK supports the following security scheme globally:
|
||||
|
||||
| Name | Type | Scheme | Environment Variable |
|
||||
| --------- | ---- | ----------- | -------------------- |
|
||||
| `api_key` | http | HTTP Bearer | `OPENROUTER_API_KEY` |
|
||||
|
||||
To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
<!-- End Authentication [security] -->
|
||||
|
||||
<!-- Start Available Resources and Operations [operations] -->
|
||||
## Available Resources and Operations
|
||||
|
||||
<details open>
|
||||
<summary>Available methods</summary>
|
||||
|
||||
### [chat](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/docs/sdks/chat/README.md)
|
||||
|
||||
* [complete](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/docs/sdks/chat/README.md#complete) - Create a chat completion
|
||||
|
||||
|
||||
</details>
|
||||
<!-- End Available Resources and Operations [operations] -->
|
||||
|
||||
<!-- Start Server-sent event streaming [eventstream] -->
|
||||
## Server-sent event streaming
|
||||
|
||||
[Server-sent events][mdn-sse] are used to stream content from certain
|
||||
operations. These operations will expose the stream as [Generator][generator] that
|
||||
can be consumed using a simple `for` loop. The loop will
|
||||
terminate when the server no longer has any events to send and closes the
|
||||
underlying connection.
|
||||
|
||||
The stream is also a [Context Manager][context-manager] and can be used with the `with` statement and will close the
|
||||
underlying connection when the context is exited.
|
||||
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
|
||||
[mdn-sse]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
|
||||
[generator]: https://book.pythontips.com/en/latest/generators.html
|
||||
[context-manager]: https://book.pythontips.com/en/latest/context_managers.html
|
||||
<!-- End Server-sent event streaming [eventstream] -->
|
||||
|
||||
<!-- Start Retries [retries] -->
|
||||
## Retries
|
||||
|
||||
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
|
||||
|
||||
To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
from openrouter.utils import BackoffStrategy, RetryConfig
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1,
|
||||
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
|
||||
If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
from openrouter.utils import BackoffStrategy, RetryConfig
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
<!-- End Retries [retries] -->
|
||||
|
||||
<!-- Start Error Handling [errors] -->
|
||||
## Error Handling
|
||||
|
||||
[`OpenRouterError`](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/./src/openrouter/errors/openroutererror.py) is the base class for all HTTP error responses. It has the following properties:
|
||||
|
||||
| Property | Type | Description |
|
||||
| ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
|
||||
| `err.message` | `str` | Error message |
|
||||
| `err.status_code` | `int` | HTTP response status code eg `404` |
|
||||
| `err.headers` | `httpx.Headers` | HTTP response headers |
|
||||
| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
|
||||
| `err.raw_response` | `httpx.Response` | Raw HTTP response |
|
||||
| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/#error-classes). |
|
||||
|
||||
### Example
|
||||
```python
|
||||
from openrouter import OpenRouter, errors
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
res = None
|
||||
try:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
|
||||
except errors.OpenRouterError as e:
|
||||
# The base class for HTTP error responses
|
||||
print(e.message)
|
||||
print(e.status_code)
|
||||
print(e.body)
|
||||
print(e.headers)
|
||||
print(e.raw_response)
|
||||
|
||||
# Depending on the method different errors may be thrown
|
||||
if isinstance(e, errors.ChatCompletionError):
|
||||
print(e.data.error) # models.Error
|
||||
```
|
||||
|
||||
### Error Classes
|
||||
**Primary errors:**
|
||||
* [`OpenRouterError`](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/./src/openrouter/errors/openroutererror.py): The base class for HTTP error responses.
|
||||
* [`ChatCompletionError`](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/./src/openrouter/errors/chatcompletionerror.py): Chat completion error response.
|
||||
|
||||
<details><summary>Less common errors (5)</summary>
|
||||
|
||||
<br />
|
||||
|
||||
**Network errors:**
|
||||
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
|
||||
* [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
|
||||
* [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
|
||||
|
||||
|
||||
**Inherit from [`OpenRouterError`](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/./src/openrouter/errors/openroutererror.py)**:
|
||||
* [`ResponseValidationError`](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/./src/openrouter/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
|
||||
|
||||
</details>
|
||||
<!-- End Error Handling [errors] -->
|
||||
|
||||
<!-- Start Server Selection [server] -->
|
||||
## Server Selection
|
||||
|
||||
### Server Variables
|
||||
|
||||
The default server `https://{provider_url}/api/v1` contains variables and is set to `https://openrouter.ai/api/v1` by default. To override default values, the following parameters are available when initializing the SDK client instance:
|
||||
|
||||
| Variable | Parameter | Default | Description |
|
||||
| -------------- | ------------------- | ----------------- | ----------- |
|
||||
| `provider_url` | `provider_url: str` | `"openrouter.ai"` | |
|
||||
|
||||
#### Example
|
||||
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
provider_url="https://ruddy-guacamole.info/"
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
|
||||
### Override Server URL Per-Client
|
||||
|
||||
The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
server_url="https://openrouter.ai/api/v1",
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
<!-- End Server Selection [server] -->
|
||||
|
||||
<!-- Start Custom HTTP Client [http-client] -->
|
||||
## Custom HTTP Client
|
||||
|
||||
The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
|
||||
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
|
||||
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
|
||||
|
||||
For example, you could specify a header for every request that this sdk makes as follows:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import httpx
|
||||
|
||||
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
|
||||
s = OpenRouter(client=http_client)
|
||||
```
|
||||
|
||||
or you could wrap the client with your own custom logic:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
from openrouter.httpclient import AsyncHttpClient
|
||||
import httpx
|
||||
|
||||
class CustomClient(AsyncHttpClient):
|
||||
client: AsyncHttpClient
|
||||
|
||||
def __init__(self, client: AsyncHttpClient):
|
||||
self.client = client
|
||||
|
||||
async def send(
|
||||
self,
|
||||
request: httpx.Request,
|
||||
*,
|
||||
stream: bool = False,
|
||||
auth: Union[
|
||||
httpx._types.AuthTypes, httpx._client.UseClientDefault, None
|
||||
] = httpx.USE_CLIENT_DEFAULT,
|
||||
follow_redirects: Union[
|
||||
bool, httpx._client.UseClientDefault
|
||||
] = httpx.USE_CLIENT_DEFAULT,
|
||||
) -> httpx.Response:
|
||||
request.headers["Client-Level-Header"] = "added by client"
|
||||
|
||||
return await self.client.send(
|
||||
request, stream=stream, auth=auth, follow_redirects=follow_redirects
|
||||
)
|
||||
|
||||
def build_request(
|
||||
self,
|
||||
method: str,
|
||||
url: httpx._types.URLTypes,
|
||||
*,
|
||||
content: Optional[httpx._types.RequestContent] = None,
|
||||
data: Optional[httpx._types.RequestData] = None,
|
||||
files: Optional[httpx._types.RequestFiles] = None,
|
||||
json: Optional[Any] = None,
|
||||
params: Optional[httpx._types.QueryParamTypes] = None,
|
||||
headers: Optional[httpx._types.HeaderTypes] = None,
|
||||
cookies: Optional[httpx._types.CookieTypes] = None,
|
||||
timeout: Union[
|
||||
httpx._types.TimeoutTypes, httpx._client.UseClientDefault
|
||||
] = httpx.USE_CLIENT_DEFAULT,
|
||||
extensions: Optional[httpx._types.RequestExtensions] = None,
|
||||
) -> httpx.Request:
|
||||
return self.client.build_request(
|
||||
method,
|
||||
url,
|
||||
content=content,
|
||||
data=data,
|
||||
files=files,
|
||||
json=json,
|
||||
params=params,
|
||||
headers=headers,
|
||||
cookies=cookies,
|
||||
timeout=timeout,
|
||||
extensions=extensions,
|
||||
)
|
||||
|
||||
s = OpenRouter(async_client=CustomClient(httpx.AsyncClient()))
|
||||
```
|
||||
<!-- End Custom HTTP Client [http-client] -->
|
||||
|
||||
<!-- Start Resource Management [resource-management] -->
|
||||
## Resource Management
|
||||
|
||||
The `OpenRouter` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
|
||||
|
||||
[context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
|
||||
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
def main():
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
# Rest of application here...
|
||||
|
||||
|
||||
# Or when using async:
|
||||
async def amain():
|
||||
|
||||
async with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
# Rest of application here...
|
||||
```
|
||||
<!-- End Resource Management [resource-management] -->
|
||||
|
||||
<!-- Start Debugging [debug] -->
|
||||
## Debugging
|
||||
|
||||
You can setup your SDK to emit debug logs for SDK requests and responses.
|
||||
|
||||
You can pass your own logger class directly into your SDK.
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import logging
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
s = OpenRouter(debug_logger=logging.getLogger("openrouter"))
|
||||
```
|
||||
|
||||
You can also enable a default debug logger by setting an environment variable `OPENROUTER_DEBUG` to true.
|
||||
<!-- End Debugging [debug] -->
|
||||
|
||||
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
||||
|
||||
# Development
|
||||
|
||||
## Maturity
|
||||
|
||||
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
|
||||
to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
|
||||
looking for the latest version.
|
||||
|
||||
## Contributions
|
||||
|
||||
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
|
||||
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
|
||||
|
||||
### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=open-router&utm_campaign=python)
|
||||
@@ -1,50 +1,18 @@
|
||||

|
||||
|
||||
# OpenRouter SDK (Beta)
|
||||
|
||||
The [OpenRouter SDK](https://openrouter.ai/docs/sdks/python) is a Python toolkit designed to help you build AI-powered features and solutions. Giving you easy access to over 300 models across providers in an easy and type-safe way.
|
||||
|
||||
<div align="center">
|
||||
<img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/19d8ad52-cb56-4f87-8bce-9a9c2233ac16" />
|
||||
<h1>OpenRouter Python SDK</h1>
|
||||
<p>Developer-friendly Python SDK specifically catered to leverage the <strong>OpenRouter</strong> API.</p>
|
||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" /></a>
|
||||
</div>
|
||||
To learn more about how to use the OpenRouter SDK, check out our [API Reference](https://openrouter.ai/docs/sdks/python/reference) and [Documentation](https://openrouter.ai/docs/sdks/python).
|
||||
|
||||
<!-- No Summary [summary] -->
|
||||
|
||||
<!-- Start Summary [summary] -->
|
||||
## Summary
|
||||
|
||||
OpenRouter Chat Completions API: OpenAI-compatible Chat Completions API with additional OpenRouter features
|
||||
|
||||
For more information about the API: [OpenRouter Documentation](https://openrouter.ai/docs)
|
||||
<!-- End Summary [summary] -->
|
||||
|
||||
<!-- Start Table of Contents [toc] -->
|
||||
## Table of Contents
|
||||
<!-- $toc-max-depth=2 -->
|
||||
* [SDK Installation](#sdk-installation)
|
||||
* [IDE Support](#ide-support)
|
||||
* [SDK Example Usage](#sdk-example-usage)
|
||||
* [Authentication](#authentication)
|
||||
* [Available Resources and Operations](#available-resources-and-operations)
|
||||
* [Server-sent event streaming](#server-sent-event-streaming)
|
||||
* [Retries](#retries)
|
||||
* [Error Handling](#error-handling)
|
||||
* [Server Selection](#server-selection)
|
||||
* [Custom HTTP Client](#custom-http-client)
|
||||
* [Resource Management](#resource-management)
|
||||
* [Debugging](#debugging)
|
||||
* [Development](#development)
|
||||
* [Maturity](#maturity)
|
||||
* [Contributions](#contributions)
|
||||
|
||||
<!-- End Table of Contents [toc] -->
|
||||
<!-- No Table of Contents [toc] -->
|
||||
|
||||
<!-- Start SDK Installation [installation] -->
|
||||
## SDK Installation
|
||||
|
||||
> [!TIP]
|
||||
> To finish publishing your SDK to PyPI you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
|
||||
|
||||
|
||||
> [!NOTE]
|
||||
> **Python version upgrade policy**
|
||||
>
|
||||
@@ -57,7 +25,7 @@ The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
|
||||
*uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
|
||||
|
||||
```bash
|
||||
uv add git+https://github.com/speakeasy-sdks/openrouter-python-sdk.git
|
||||
uv add openrouter
|
||||
```
|
||||
|
||||
### PIP
|
||||
@@ -65,7 +33,7 @@ uv add git+https://github.com/speakeasy-sdks/openrouter-python-sdk.git
|
||||
*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
|
||||
|
||||
```bash
|
||||
pip install git+https://github.com/speakeasy-sdks/openrouter-python-sdk.git
|
||||
pip install openrouter
|
||||
```
|
||||
|
||||
### Poetry
|
||||
@@ -73,7 +41,7 @@ pip install git+https://github.com/speakeasy-sdks/openrouter-python-sdk.git
|
||||
*Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
|
||||
|
||||
```bash
|
||||
poetry add git+https://github.com/speakeasy-sdks/openrouter-python-sdk.git
|
||||
poetry add openrouter
|
||||
```
|
||||
|
||||
### Shell and script usage with `uv`
|
||||
@@ -108,6 +76,12 @@ Once that is saved to a file, you can run it with `uv run script.py` where
|
||||
`script.py` can be replaced with the actual file name.
|
||||
<!-- End SDK Installation [installation] -->
|
||||
|
||||
<!-- Start Requirements [requirements] -->
|
||||
## Requirements
|
||||
|
||||
This SDK requires Python 3.9 or higher. For Python version support policy, see the SDK Installation section above.
|
||||
<!-- End Requirements [requirements] -->
|
||||
|
||||
<!-- Start IDE Support [idesupport] -->
|
||||
## IDE Support
|
||||
|
||||
@@ -118,10 +92,8 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
|
||||
- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
|
||||
<!-- End IDE Support [idesupport] -->
|
||||
|
||||
<!-- Start SDK Example Usage [usage] -->
|
||||
## SDK Example Usage
|
||||
|
||||
### Example
|
||||
<!-- No SDK Example Usage [usage] -->
|
||||
## SDK Usage
|
||||
|
||||
```python
|
||||
# Synchronous Example
|
||||
@@ -133,22 +105,25 @@ with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
res = open_router.chat.send(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
], model="anthropic/claude-4.5-sonnet", provider={
|
||||
"zdr": True,
|
||||
"sort": "price",
|
||||
}, stream=True)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
```
|
||||
|
||||
</br>
|
||||
|
||||
The same SDK client can also be used to make asynchronous requests by importing asyncio.
|
||||
|
||||
```python
|
||||
# Asynchronous Example
|
||||
import asyncio
|
||||
@@ -161,388 +136,40 @@ async def main():
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = await open_router.chat.complete_async(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
res = await open_router.chat.send_async(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], model="anthropic/claude-4.5-sonnet", provider={
|
||||
"zdr": True,
|
||||
"sort": "price",
|
||||
}, stream=True)
|
||||
|
||||
async with res as event_stream:
|
||||
async for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
async for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
asyncio.run(main())
|
||||
```
|
||||
<!-- End SDK Example Usage [usage] -->
|
||||
|
||||
<!-- Start Authentication [security] -->
|
||||
## Authentication
|
||||
<!-- No Authentication [security] -->
|
||||
|
||||
### Per-Client Security Schemes
|
||||
<!-- No Available Resources and Operations [operations] -->
|
||||
|
||||
This SDK supports the following security scheme globally:
|
||||
<!-- No Standalone functions [standalone-funcs] -->
|
||||
|
||||
| Name | Type | Scheme | Environment Variable |
|
||||
| --------- | ---- | ----------- | -------------------- |
|
||||
| `api_key` | http | HTTP Bearer | `OPENROUTER_API_KEY` |
|
||||
<!-- No React hooks with TanStack Query [react-query] -->
|
||||
|
||||
To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
<!-- No Server-sent event streaming [eventstream] -->
|
||||
|
||||
<!-- No Retries [retries] -->
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
<!-- No Error Handling [errors] -->
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
<!-- No Server Selection [server] -->
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
<!-- End Authentication [security] -->
|
||||
|
||||
<!-- Start Available Resources and Operations [operations] -->
|
||||
## Available Resources and Operations
|
||||
|
||||
<details open>
|
||||
<summary>Available methods</summary>
|
||||
|
||||
### [chat](docs/sdks/chat/README.md)
|
||||
|
||||
* [complete](docs/sdks/chat/README.md#complete) - Create a chat completion
|
||||
|
||||
|
||||
</details>
|
||||
<!-- End Available Resources and Operations [operations] -->
|
||||
|
||||
<!-- Start Server-sent event streaming [eventstream] -->
|
||||
## Server-sent event streaming
|
||||
|
||||
[Server-sent events][mdn-sse] are used to stream content from certain
|
||||
operations. These operations will expose the stream as [Generator][generator] that
|
||||
can be consumed using a simple `for` loop. The loop will
|
||||
terminate when the server no longer has any events to send and closes the
|
||||
underlying connection.
|
||||
|
||||
The stream is also a [Context Manager][context-manager] and can be used with the `with` statement and will close the
|
||||
underlying connection when the context is exited.
|
||||
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
|
||||
[mdn-sse]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
|
||||
[generator]: https://book.pythontips.com/en/latest/generators.html
|
||||
[context-manager]: https://book.pythontips.com/en/latest/context_managers.html
|
||||
<!-- End Server-sent event streaming [eventstream] -->
|
||||
|
||||
<!-- Start Retries [retries] -->
|
||||
## Retries
|
||||
|
||||
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
|
||||
|
||||
To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
from openrouter.utils import BackoffStrategy, RetryConfig
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1,
|
||||
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
|
||||
If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
from openrouter.utils import BackoffStrategy, RetryConfig
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
<!-- End Retries [retries] -->
|
||||
|
||||
<!-- Start Error Handling [errors] -->
|
||||
## Error Handling
|
||||
|
||||
[`OpenRouterError`](./src/openrouter/errors/openroutererror.py) is the base class for all HTTP error responses. It has the following properties:
|
||||
|
||||
| Property | Type | Description |
|
||||
| ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
|
||||
| `err.message` | `str` | Error message |
|
||||
| `err.status_code` | `int` | HTTP response status code eg `404` |
|
||||
| `err.headers` | `httpx.Headers` | HTTP response headers |
|
||||
| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
|
||||
| `err.raw_response` | `httpx.Response` | Raw HTTP response |
|
||||
| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
|
||||
|
||||
### Example
|
||||
```python
|
||||
from openrouter import OpenRouter, errors
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
res = None
|
||||
try:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
|
||||
except errors.OpenRouterError as e:
|
||||
# The base class for HTTP error responses
|
||||
print(e.message)
|
||||
print(e.status_code)
|
||||
print(e.body)
|
||||
print(e.headers)
|
||||
print(e.raw_response)
|
||||
|
||||
# Depending on the method different errors may be thrown
|
||||
if isinstance(e, errors.ChatCompletionError):
|
||||
print(e.data.error) # models.Error
|
||||
```
|
||||
|
||||
### Error Classes
|
||||
**Primary errors:**
|
||||
* [`OpenRouterError`](./src/openrouter/errors/openroutererror.py): The base class for HTTP error responses.
|
||||
* [`ChatCompletionError`](./src/openrouter/errors/chatcompletionerror.py): Chat completion error response.
|
||||
|
||||
<details><summary>Less common errors (5)</summary>
|
||||
|
||||
<br />
|
||||
|
||||
**Network errors:**
|
||||
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
|
||||
* [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
|
||||
* [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
|
||||
|
||||
|
||||
**Inherit from [`OpenRouterError`](./src/openrouter/errors/openroutererror.py)**:
|
||||
* [`ResponseValidationError`](./src/openrouter/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
|
||||
|
||||
</details>
|
||||
<!-- End Error Handling [errors] -->
|
||||
|
||||
<!-- Start Server Selection [server] -->
|
||||
## Server Selection
|
||||
|
||||
### Server Variables
|
||||
|
||||
The default server `https://{provider_url}/api/v1` contains variables and is set to `https://openrouter.ai/api/v1` by default. To override default values, the following parameters are available when initializing the SDK client instance:
|
||||
|
||||
| Variable | Parameter | Default | Description |
|
||||
| -------------- | ------------------- | ----------------- | ----------- |
|
||||
| `provider_url` | `provider_url: str` | `"openrouter.ai"` | |
|
||||
|
||||
#### Example
|
||||
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
provider_url="https://ruddy-guacamole.info/"
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
|
||||
### Override Server URL Per-Client
|
||||
|
||||
The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
server_url="https://openrouter.ai/api/v1",
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
```
|
||||
<!-- End Server Selection [server] -->
|
||||
|
||||
<!-- Start Custom HTTP Client [http-client] -->
|
||||
## Custom HTTP Client
|
||||
|
||||
The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
|
||||
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
|
||||
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
|
||||
|
||||
For example, you could specify a header for every request that this sdk makes as follows:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import httpx
|
||||
|
||||
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
|
||||
s = OpenRouter(client=http_client)
|
||||
```
|
||||
|
||||
or you could wrap the client with your own custom logic:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
from openrouter.httpclient import AsyncHttpClient
|
||||
import httpx
|
||||
|
||||
class CustomClient(AsyncHttpClient):
|
||||
client: AsyncHttpClient
|
||||
|
||||
def __init__(self, client: AsyncHttpClient):
|
||||
self.client = client
|
||||
|
||||
async def send(
|
||||
self,
|
||||
request: httpx.Request,
|
||||
*,
|
||||
stream: bool = False,
|
||||
auth: Union[
|
||||
httpx._types.AuthTypes, httpx._client.UseClientDefault, None
|
||||
] = httpx.USE_CLIENT_DEFAULT,
|
||||
follow_redirects: Union[
|
||||
bool, httpx._client.UseClientDefault
|
||||
] = httpx.USE_CLIENT_DEFAULT,
|
||||
) -> httpx.Response:
|
||||
request.headers["Client-Level-Header"] = "added by client"
|
||||
|
||||
return await self.client.send(
|
||||
request, stream=stream, auth=auth, follow_redirects=follow_redirects
|
||||
)
|
||||
|
||||
def build_request(
|
||||
self,
|
||||
method: str,
|
||||
url: httpx._types.URLTypes,
|
||||
*,
|
||||
content: Optional[httpx._types.RequestContent] = None,
|
||||
data: Optional[httpx._types.RequestData] = None,
|
||||
files: Optional[httpx._types.RequestFiles] = None,
|
||||
json: Optional[Any] = None,
|
||||
params: Optional[httpx._types.QueryParamTypes] = None,
|
||||
headers: Optional[httpx._types.HeaderTypes] = None,
|
||||
cookies: Optional[httpx._types.CookieTypes] = None,
|
||||
timeout: Union[
|
||||
httpx._types.TimeoutTypes, httpx._client.UseClientDefault
|
||||
] = httpx.USE_CLIENT_DEFAULT,
|
||||
extensions: Optional[httpx._types.RequestExtensions] = None,
|
||||
) -> httpx.Request:
|
||||
return self.client.build_request(
|
||||
method,
|
||||
url,
|
||||
content=content,
|
||||
data=data,
|
||||
files=files,
|
||||
json=json,
|
||||
params=params,
|
||||
headers=headers,
|
||||
cookies=cookies,
|
||||
timeout=timeout,
|
||||
extensions=extensions,
|
||||
)
|
||||
|
||||
s = OpenRouter(async_client=CustomClient(httpx.AsyncClient()))
|
||||
```
|
||||
<!-- End Custom HTTP Client [http-client] -->
|
||||
<!-- No Custom HTTP Client [http-client] -->
|
||||
|
||||
<!-- Start Resource Management [resource-management] -->
|
||||
## Resource Management
|
||||
@@ -593,15 +220,32 @@ You can also enable a default debug logger by setting an environment variable `O
|
||||
|
||||
# Development
|
||||
|
||||
## Running Tests
|
||||
|
||||
To run the test suite, you'll need to set up your environment with an OpenRouter API key.
|
||||
|
||||
### Local Development
|
||||
|
||||
1. Copy the example environment file:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
2. Edit `.env` and add your OpenRouter API key:
|
||||
|
||||
```bash
|
||||
OPENROUTER_API_KEY=your_api_key_here
|
||||
```
|
||||
|
||||
3. Run the tests:
|
||||
|
||||
```bash
|
||||
pytest
|
||||
```
|
||||
|
||||
## Maturity
|
||||
|
||||
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
|
||||
to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
|
||||
looking for the latest version.
|
||||
|
||||
## Contributions
|
||||
|
||||
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
|
||||
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
|
||||
|
||||
### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=open-router&utm_campaign=python)
|
||||
looking for the latest version.
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
|
||||
|
||||
## 2025-08-22 15:59:18
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc
|
||||
- Speakeasy CLI 1.606.2 (2.687.1) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [python v0.1.3] .
|
||||
|
||||
## 2025-09-17 00:07:51
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc
|
||||
- Speakeasy CLI 1.617.1 (2.701.8) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [python v0.6.3] .
|
||||
@@ -9,12 +9,61 @@ with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.chat.complete(messages=[
|
||||
res = open_router.beta.responses.send(input=[
|
||||
{
|
||||
"type": "message",
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
], metadata={
|
||||
"user_id": "123",
|
||||
"session_id": "abc-def-ghi",
|
||||
}, tools=[
|
||||
{
|
||||
"type": "function",
|
||||
"name": "get_current_weather",
|
||||
"description": "Get the current weather in a given location",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
], model="anthropic/claude-4.5-sonnet-20250929", text={
|
||||
"format_": {
|
||||
"type": "text",
|
||||
},
|
||||
"verbosity": "medium",
|
||||
}, reasoning={
|
||||
"summary": "auto",
|
||||
"enabled": True,
|
||||
}, temperature=0.7, top_p=0.9, prompt={
|
||||
"id": "<id>",
|
||||
"variables": {
|
||||
"key": {
|
||||
"type": "input_text",
|
||||
"text": "Hello, how can I help you?",
|
||||
},
|
||||
},
|
||||
}, service_tier="auto", truncation="auto", stream=False, provider={
|
||||
"data_collection": "deny",
|
||||
"zdr": True,
|
||||
"enforce_distillable_text": True,
|
||||
"order": [
|
||||
"OpenAI",
|
||||
],
|
||||
"only": [
|
||||
"OpenAI",
|
||||
],
|
||||
"ignore": [
|
||||
"OpenAI",
|
||||
],
|
||||
"quantizations": None,
|
||||
"sort": "price",
|
||||
})
|
||||
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
@@ -25,6 +74,7 @@ with OpenRouter(
|
||||
</br>
|
||||
|
||||
The same SDK client can also be used to make asynchronous requests by importing asyncio.
|
||||
|
||||
```python
|
||||
# Asynchronous Example
|
||||
import asyncio
|
||||
@@ -37,12 +87,61 @@ async def main():
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = await open_router.chat.complete_async(messages=[
|
||||
res = await open_router.beta.responses.send_async(input=[
|
||||
{
|
||||
"type": "message",
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
},
|
||||
], stream=False, temperature=1, top_p=1)
|
||||
], metadata={
|
||||
"user_id": "123",
|
||||
"session_id": "abc-def-ghi",
|
||||
}, tools=[
|
||||
{
|
||||
"type": "function",
|
||||
"name": "get_current_weather",
|
||||
"description": "Get the current weather in a given location",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
], model="anthropic/claude-4.5-sonnet-20250929", text={
|
||||
"format_": {
|
||||
"type": "text",
|
||||
},
|
||||
"verbosity": "medium",
|
||||
}, reasoning={
|
||||
"summary": "auto",
|
||||
"enabled": True,
|
||||
}, temperature=0.7, top_p=0.9, prompt={
|
||||
"id": "<id>",
|
||||
"variables": {
|
||||
"key": {
|
||||
"type": "input_text",
|
||||
"text": "Hello, how can I help you?",
|
||||
},
|
||||
},
|
||||
}, service_tier="auto", truncation="auto", stream=False, provider={
|
||||
"data_collection": "deny",
|
||||
"zdr": True,
|
||||
"enforce_distillable_text": True,
|
||||
"order": [
|
||||
"OpenAI",
|
||||
],
|
||||
"only": [
|
||||
"OpenAI",
|
||||
],
|
||||
"ignore": [
|
||||
"OpenAI",
|
||||
],
|
||||
"quantizations": None,
|
||||
"sort": "price",
|
||||
})
|
||||
|
||||
async with res as event_stream:
|
||||
async for event in event_stream:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
@@ -0,0 +1,10 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="400" viewBox="0 0 1200 400">
|
||||
<title>OpenRouter</title>
|
||||
<path fill="currentColor" d="M431.4 196.2c0 11.2-2.1 20.8-6.2 28.8a45 45 0 0 1-41 25 44.8 44.8 0 0 1-41-25c-4.2-8-6.2-17.7-6.2-28.8 0-11.2 2-20.8 6.1-28.8a44.9 44.9 0 0 1 41.1-25 45 45 0 0 1 41 25c4.1 8 6.2 17.6 6.2 28.8m-15.7 0c0-8.5-1.4-15.7-4.1-21.6a30.6 30.6 0 0 0-11.3-13.3c-4.7-3-10.1-4.5-16.1-4.5a30 30 0 0 0-16.2 4.5c-4.7 3-8.4 7.5-11.2 13.3-2.7 5.9-4.1 13-4.1 21.6 0 8.5 1.4 15.7 4.1 21.5A30.7 30.7 0 0 0 368 231c4.8 3 10.2 4.6 16.2 4.6s11.4-1.5 16.1-4.6c4.8-3 8.5-7.4 11.3-13.3 2.7-5.8 4.1-13 4.1-21.5Zm34 81.8V170h15v12.7h1.3c.9-1.6 2.1-3.5 3.8-5.6a22 22 0 0 1 18.7-8.1 30.6 30.6 0 0 1 28.7 18.6c2.9 6 4.3 13.3 4.3 21.8s-1.4 15.8-4.2 21.8a33 33 0 0 1-11.7 14 30 30 0 0 1-17 4.9c-4.7 0-8.6-.8-11.6-2.4a22 22 0 0 1-7.1-5.6c-1.7-2.2-3-4.1-4-5.8h-.8V278h-15.3m15-68.7c0 5.5.7 10.3 2.3 14.5 1.6 4.2 4 7.4 7 9.7 3 2.4 6.7 3.5 11.1 3.5 4.6 0 8.4-1.2 11.5-3.6 3-2.5 5.4-5.8 7-10 1.6-4.2 2.4-8.9 2.4-14.1 0-5.2-.8-9.9-2.4-14a21.7 21.7 0 0 0-7-9.7 18 18 0 0 0-11.5-3.6c-4.4 0-8.1 1.1-11.2 3.4-3 2.3-5.3 5.5-7 9.6a40 40 0 0 0-2.3 14.3ZM572.4 250c-7.8 0-14.4-1.6-20-5-5.6-3.3-9.9-8-12.9-14s-4.5-13.2-4.5-21.3c0-8 1.5-15.1 4.5-21.3a35 35 0 0 1 12.7-14.4 38.5 38.5 0 0 1 32-3 31.3 31.3 0 0 1 19 19.2c2 5 2.9 11 2.9 18.2v5.4h-62.5v-11.5h47.5c0-4-.8-7.6-2.5-10.7a18.6 18.6 0 0 0-17.2-10c-4.3 0-8 1-11.2 3a22.3 22.3 0 0 0-10 19.2v9c0 5.2 1 9.6 2.8 13.3 1.9 3.7 4.5 6.5 7.8 8.4a23 23 0 0 0 11.7 2.9c3 0 5.6-.4 8-1.3a16.4 16.4 0 0 0 10.2-10l14.4 2.7c-1.1 4.3-3.2 8-6.2 11.2-3 3.2-6.7 5.6-11.2 7.4a41.7 41.7 0 0 1-15.3 2.6Zm66-48.2v46.7h-15.3V170H638v12.8h1c1.8-4.2 4.6-7.5 8.5-10 3.8-2.6 8.7-3.8 14.6-3.8 5.4 0 10 1.1 14 3.3 4.1 2.3 7.2 5.6 9.4 10a36 36 0 0 1 3.4 16.3v50h-15.3v-48.2a19 19 0 0 0-4.5-13.3c-3-3.3-7-4.9-12.2-4.9a19 19 0 0 0-9.4 2.3 16.4 16.4 0 0 0-6.5 6.8 21.8 21.8 0 0 0-2.4 10.6Zm72 46.7V143.8h37.3c8 0 14.8 1.4 20.2 4.2 5.4 2.8 9.4 6.7 12 11.6a35 35 0 0 1 4 17c0 6.5-1.3 12.1-4 17a27.3 27.3 0 0 1-12 11.3c-5.4 2.7-12.2 4-20.3 4h-28.2v-13.6h26.8c5.1 0 9.3-.7 12.5-2.2 3.2-1.4 5.6-3.6 7-6.4a21 21 0 0 0 2.3-10c0-4-.7-7.4-2.2-10.3a15.2 15.2 0 0 0-7.1-6.7 29.3 29.3 0 0 0-12.7-2.3h-19.9v91.2h-15.7m51.7-47.3 25.8 47.3h-18l-25.3-47.3h17.5Zm73 48.8a34.1 34.1 0 0 1-32-19.2 47 47 0 0 1-4.6-21.3c0-8.1 1.5-15.2 4.5-21.3a34.1 34.1 0 0 1 32-19.3 34.1 34.1 0 0 1 32 19.3 45 45 0 0 1 4.7 21.3 47 47 0 0 1-4.6 21.3 34.1 34.1 0 0 1-32 19.2m0-12.8c4.8 0 8.8-1.3 11.9-3.8 3.1-2.5 5.4-5.9 7-10a42 42 0 0 0 2.2-14c0-5-.7-9.5-2.2-13.8a22.8 22.8 0 0 0-7-10.1 18.2 18.2 0 0 0-11.9-3.8c-4.8 0-8.8 1.2-12 3.8-3 2.6-5.4 6-7 10.2a40.5 40.5 0 0 0-2.2 13.8c0 5 .8 9.6 2.3 13.8 1.5 4.2 3.8 7.6 7 10.1 3.1 2.5 7.1 3.8 12 3.8ZM938.6 216v-46h15.3v78.6h-15v-13.7h-.8a24.4 24.4 0 0 1-23.5 14.7 26 26 0 0 1-13.4-3.4 23 23 0 0 1-9-10 36.3 36.3 0 0 1-3.4-16.2v-50h15.3v48.1a18 18 0 0 0 4.4 12.8c3 3.2 6.9 4.8 11.6 4.8a19 19 0 0 0 15.7-8.7c1.9-2.9 2.8-6.6 2.8-11Zm72.5-46v12.3h-43V170h43m-31.4-18.8H995v74.3c0 3 .4 5.2 1.3 6.7.9 1.4 2 2.5 3.5 3 1.4.5 3 .8 4.6.8a176.6 176.6 0 0 0 5.4-.7l2.7 12.6a27.2 27.2 0 0 1-10 1.7c-4 0-7.7-.7-11.2-2.2a19.3 19.3 0 0 1-8.4-7c-2.1-3-3.2-7-3.2-11.7v-77.5Zm82.1 99c-7.7 0-14.4-1.7-20-5-5.5-3.4-9.8-8-12.8-14.1-3-6-4.6-13.2-4.6-21.3a47 47 0 0 1 4.6-21.3c3-6.1 7.2-11 12.6-14.4a38.5 38.5 0 0 1 32-3 31.3 31.3 0 0 1 19 19.2c2 5 3 11 3 18.2v5.4H1033v-11.5h47.4c0-4-.8-7.6-2.4-10.7a18.7 18.7 0 0 0-17.3-10c-4.3 0-8 1-11.2 3a22.9 22.9 0 0 0-9.9 19.2v9c0 5.2.9 9.6 2.8 13.3 1.8 3.7 4.4 6.5 7.8 8.4a23 23 0 0 0 11.7 2.9 24 24 0 0 0 7.9-1.3 16.7 16.7 0 0 0 10.2-9.9l14.4 2.6a26 26 0 0 1-6.2 11.2 30 30 0 0 1-11.2 7.4 41.6 41.6 0 0 1-15.3 2.6Zm50.7-1.6V170h14.8v12.5h.8c1.5-4.2 4-7.6 7.6-10 3.7-2.5 7.8-3.7 12.4-3.7a68 68 0 0 1 6.5.4v14.6a31.9 31.9 0 0 0-8-1 20 20 0 0 0-9.6 2.4 17.2 17.2 0 0 0-9.2 15.4v48h-15.3Z"/>
|
||||
<g fill="currentColor" stroke="currentColor">
|
||||
<path stroke-width="35.3" d="M46.2 200.5c5.9 0 28.6-5.1 40.3-11.8 11.8-6.6 11.8-6.6 36.1-23.9 30.8-21.8 52.5-14.5 88.2-14.5"/>
|
||||
<path stroke-width=".4" d="M245.3 150.5 185 185.3v-69.6l60.3 34.8Z"/>
|
||||
<path stroke-width="35.3" d="M45 200.5c5.9 0 28.6 5 40.4 11.7 11.7 6.7 11.7 6.7 36 24 30.8 21.8 52.5 14.5 88.2 14.5"/>
|
||||
<path stroke-width=".4" d="m244.1 250.4-60.3-34.7v69.5l60.3-34.8Z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,11 @@
|
||||
# BadGatewayResponseError
|
||||
|
||||
Bad Gateway - Provider/upstream API failure
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
|
||||
| `error` | [models.BadGatewayResponseErrorData](../models/badgatewayresponseerrordata.md) | :heavy_check_mark: | Error data for BadGatewayResponse | {<br/>"code": 502,<br/>"message": "Provider returned error"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# BadRequestResponseError
|
||||
|
||||
Bad Request - Invalid request parameters or malformed input
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
|
||||
| `error` | [models.BadRequestResponseErrorData](../models/badrequestresponseerrordata.md) | :heavy_check_mark: | Error data for BadRequestResponse | {<br/>"code": 400,<br/>"message": "Invalid request parameters"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -1,10 +0,0 @@
|
||||
# ChatCompletionError
|
||||
|
||||
Chat completion error response
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------- | ---------------------------------- | ---------------------------------- | ---------------------------------- |
|
||||
| `error` | [models.Error](../models/error.md) | :heavy_check_mark: | Error object structure |
|
||||
@@ -1,10 +1,8 @@
|
||||
# ResponseFormatJSONObject
|
||||
|
||||
JSON object response format
|
||||
# ChatError
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- |
|
||||
| `type` | [models.TypeJSONObject](../models/typejsonobject.md) | :heavy_check_mark: | N/A |
|
||||
| `error` | [models.ChatErrorError](../models/chaterrorerror.md) | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,11 @@
|
||||
# EdgeNetworkTimeoutResponseError
|
||||
|
||||
Infrastructure Timeout - Provider request timed out at edge network
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| `error` | [models.EdgeNetworkTimeoutResponseErrorData](../models/edgenetworktimeoutresponseerrordata.md) | :heavy_check_mark: | Error data for EdgeNetworkTimeoutResponse | {<br/>"code": 524,<br/>"message": "Request timed out. Please try again later."<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ForbiddenResponseError
|
||||
|
||||
Forbidden - Authentication successful but insufficient permissions
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
|
||||
| `error` | [models.ForbiddenResponseErrorData](../models/forbiddenresponseerrordata.md) | :heavy_check_mark: | Error data for ForbiddenResponse | {<br/>"code": 403,<br/>"message": "Only provisioning keys can perform this operation"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# InternalServerResponseError
|
||||
|
||||
Internal Server Error - Unexpected server error
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||||
| `error` | [models.InternalServerResponseErrorData](../models/internalserverresponseerrordata.md) | :heavy_check_mark: | Error data for InternalServerResponse | {<br/>"code": 500,<br/>"message": "Internal Server Error"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# NotFoundResponseError
|
||||
|
||||
Not Found - Resource does not exist
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
||||
| `error` | [models.NotFoundResponseErrorData](../models/notfoundresponseerrordata.md) | :heavy_check_mark: | Error data for NotFoundResponse | {<br/>"code": 404,<br/>"message": "Resource not found"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# PayloadTooLargeResponseError
|
||||
|
||||
Payload Too Large - Request payload exceeds size limits
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
||||
| `error` | [models.PayloadTooLargeResponseErrorData](../models/payloadtoolargeresponseerrordata.md) | :heavy_check_mark: | Error data for PayloadTooLargeResponse | {<br/>"code": 413,<br/>"message": "Request payload too large"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# PaymentRequiredResponseError
|
||||
|
||||
Payment Required - Insufficient credits or quota to complete request
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
||||
| `error` | [models.PaymentRequiredResponseErrorData](../models/paymentrequiredresponseerrordata.md) | :heavy_check_mark: | Error data for PaymentRequiredResponse | {<br/>"code": 402,<br/>"message": "Insufficient credits. Add more using https://openrouter.ai/credits"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ProviderOverloadedResponseError
|
||||
|
||||
Provider Overloaded - Provider is temporarily overloaded
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| `error` | [models.ProviderOverloadedResponseErrorData](../models/provideroverloadedresponseerrordata.md) | :heavy_check_mark: | Error data for ProviderOverloadedResponse | {<br/>"code": 529,<br/>"message": "Provider returned error"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# RequestTimeoutResponseError
|
||||
|
||||
Request Timeout - Operation exceeded time limit
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||||
| `error` | [models.RequestTimeoutResponseErrorData](../models/requesttimeoutresponseerrordata.md) | :heavy_check_mark: | Error data for RequestTimeoutResponse | {<br/>"code": 408,<br/>"message": "Operation timed out. Please try again later."<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -1,10 +1,11 @@
|
||||
# File
|
||||
# ServiceUnavailableResponseError
|
||||
|
||||
Service Unavailable - Service temporarily unavailable
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| `hash` | *str* | :heavy_check_mark: | N/A |
|
||||
| `name` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
| `content` | List[[models.FileAnnotationDetailContentUnion](../models/fileannotationdetailcontentunion.md)] | :heavy_check_mark: | N/A |
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| `error` | [models.ServiceUnavailableResponseErrorData](../models/serviceunavailableresponseerrordata.md) | :heavy_check_mark: | Error data for ServiceUnavailableResponse | {<br/>"code": 503,<br/>"message": "Service temporarily unavailable"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# TooManyRequestsResponseError
|
||||
|
||||
Too Many Requests - Rate limit exceeded
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
||||
| `error` | [models.TooManyRequestsResponseErrorData](../models/toomanyrequestsresponseerrordata.md) | :heavy_check_mark: | Error data for TooManyRequestsResponse | {<br/>"code": 429,<br/>"message": "Rate limit exceeded"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# UnauthorizedResponseError
|
||||
|
||||
Unauthorized - Authentication required or invalid credentials
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
||||
| `error` | [models.UnauthorizedResponseErrorData](../models/unauthorizedresponseerrordata.md) | :heavy_check_mark: | Error data for UnauthorizedResponse | {<br/>"code": 401,<br/>"message": "Missing Authentication header"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,11 @@
|
||||
# UnprocessableEntityResponseError
|
||||
|
||||
Unprocessable Entity - Semantic validation failure
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
||||
| `error` | [models.UnprocessableEntityResponseErrorData](../models/unprocessableentityresponseerrordata.md) | :heavy_check_mark: | Error data for UnprocessableEntityResponse | {<br/>"code": 422,<br/>"message": "Invalid argument"<br/>} |
|
||||
| `user_id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
|
||||
@@ -0,0 +1,18 @@
|
||||
# ActivityItem
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- |
|
||||
| `date_` | *str* | :heavy_check_mark: | Date of the activity (YYYY-MM-DD format) | 2025-08-24 |
|
||||
| `model` | *str* | :heavy_check_mark: | Model slug (e.g., "openai/gpt-4.1") | openai/gpt-4.1 |
|
||||
| `model_permaslug` | *str* | :heavy_check_mark: | Model permaslug (e.g., "openai/gpt-4.1-2025-04-14") | openai/gpt-4.1-2025-04-14 |
|
||||
| `endpoint_id` | *str* | :heavy_check_mark: | Unique identifier for the endpoint | 550e8400-e29b-41d4-a716-446655440000 |
|
||||
| `provider_name` | *str* | :heavy_check_mark: | Name of the provider serving this endpoint | OpenAI |
|
||||
| `usage` | *float* | :heavy_check_mark: | Total cost in USD (OpenRouter credits spent) | 0.015 |
|
||||
| `byok_usage_inference` | *float* | :heavy_check_mark: | BYOK inference cost in USD (external credits spent) | 0.012 |
|
||||
| `requests` | *float* | :heavy_check_mark: | Number of requests made | 5 |
|
||||
| `prompt_tokens` | *float* | :heavy_check_mark: | Total prompt tokens used | 50 |
|
||||
| `completion_tokens` | *float* | :heavy_check_mark: | Total completion tokens generated | 125 |
|
||||
| `reasoning_tokens` | *float* | :heavy_check_mark: | Total reasoning tokens used | 25 |
|
||||
@@ -1,19 +0,0 @@
|
||||
# AnnotationDetail
|
||||
|
||||
Annotation information
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `models.FileAnnotationDetail`
|
||||
|
||||
```python
|
||||
value: models.FileAnnotationDetail = /* values here */
|
||||
```
|
||||
|
||||
### `models.URLCitationAnnotationDetail`
|
||||
|
||||
```python
|
||||
value: models.URLCitationAnnotationDetail = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# APIType
|
||||
|
||||
Type of API used for the generation
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------- | ------------- |
|
||||
| `COMPLETIONS` | completions |
|
||||
| `EMBEDDINGS` | embeddings |
|
||||
@@ -0,0 +1,14 @@
|
||||
# Architecture
|
||||
|
||||
Model architecture information
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- |
|
||||
| `tokenizer` | [Nullable[models.Tokenizer]](../models/tokenizer.md) | :heavy_check_mark: | N/A | GPT |
|
||||
| `instruct_type` | [Nullable[models.InstructType]](../models/instructtype.md) | :heavy_check_mark: | Instruction format type | |
|
||||
| `modality` | *Nullable[str]* | :heavy_check_mark: | Primary modality of the model | text |
|
||||
| `input_modalities` | List[[models.InputModality](../models/inputmodality.md)] | :heavy_check_mark: | Supported input modalities | |
|
||||
| `output_modalities` | List[[models.OutputModality](../models/outputmodality.md)] | :heavy_check_mark: | Supported output modalities | |
|
||||
@@ -1,16 +1,13 @@
|
||||
# ChatCompletionMessage
|
||||
|
||||
Assistant message in completion response
|
||||
# AssistantMessage
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
||||
| `role` | [models.ChatCompletionMessageRole](../models/chatcompletionmessagerole.md) | :heavy_check_mark: | N/A |
|
||||
| `content` | *Nullable[str]* | :heavy_check_mark: | Message content |
|
||||
| `reasoning` | *OptionalNullable[str]* | :heavy_minus_sign: | Reasoning output |
|
||||
| `refusal` | *Nullable[str]* | :heavy_check_mark: | Refusal message if content was refused |
|
||||
| `tool_calls` | List[[models.ChatCompletionMessageToolCall](../models/chatcompletionmessagetoolcall.md)] | :heavy_minus_sign: | Tool calls made by the assistant |
|
||||
| `reasoning_details` | List[[models.ReasoningDetail](../models/reasoningdetail.md)] | :heavy_minus_sign: | Reasoning details delta to send reasoning details back to upstream |
|
||||
| `annotations` | List[[models.AnnotationDetail](../models/annotationdetail.md)] | :heavy_minus_sign: | Annotations delta to send annotations back to upstream |
|
||||
| `role` | *Literal["assistant"]* | :heavy_check_mark: | N/A |
|
||||
| `content` | [OptionalNullable[models.AssistantMessageContent]](../models/assistantmessagecontent.md) | :heavy_minus_sign: | N/A |
|
||||
| `name` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
| `tool_calls` | List[[models.ChatMessageToolCall](../models/chatmessagetoolcall.md)] | :heavy_minus_sign: | N/A |
|
||||
| `refusal` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
| `reasoning` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,17 @@
|
||||
# AssistantMessageContent
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `str`
|
||||
|
||||
```python
|
||||
value: str = /* values here */
|
||||
```
|
||||
|
||||
### `List[models.ChatMessageContentItem]`
|
||||
|
||||
```python
|
||||
value: List[models.ChatMessageContentItem] = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# BadGatewayResponseErrorData
|
||||
|
||||
Error data for BadGatewayResponse
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------- | -------------------------- | -------------------------- | -------------------------- |
|
||||
| `code` | *int* | :heavy_check_mark: | N/A |
|
||||
| `message` | *str* | :heavy_check_mark: | N/A |
|
||||
| `metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,12 @@
|
||||
# BadRequestResponseErrorData
|
||||
|
||||
Error data for BadRequestResponse
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------- | -------------------------- | -------------------------- | -------------------------- |
|
||||
| `code` | *int* | :heavy_check_mark: | N/A |
|
||||
| `message` | *str* | :heavy_check_mark: | N/A |
|
||||
| `metadata` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,17 @@
|
||||
# CallData
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------- | -------------------- | -------------------- | -------------------- |
|
||||
| `deadline` | *str* | :heavy_check_mark: | N/A |
|
||||
| `fee_amount` | *str* | :heavy_check_mark: | N/A |
|
||||
| `id` | *str* | :heavy_check_mark: | N/A |
|
||||
| `operator` | *str* | :heavy_check_mark: | N/A |
|
||||
| `prefix` | *str* | :heavy_check_mark: | N/A |
|
||||
| `recipient` | *str* | :heavy_check_mark: | N/A |
|
||||
| `recipient_amount` | *str* | :heavy_check_mark: | N/A |
|
||||
| `recipient_currency` | *str* | :heavy_check_mark: | N/A |
|
||||
| `refund_destination` | *str* | :heavy_check_mark: | N/A |
|
||||
| `signature` | *str* | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,10 @@
|
||||
# ChainID
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| --------------------------------------------- | --------------------------------------------- |
|
||||
| `ONE` | 1 |
|
||||
| `ONE_HUNDRED_AND_THIRTY_SEVEN` | 137 |
|
||||
| `EIGHT_THOUSAND_FOUR_HUNDRED_AND_FIFTY_THREE` | 8453 |
|
||||
@@ -1,16 +0,0 @@
|
||||
# ChatCompletion
|
||||
|
||||
Chat completion response
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
||||
| `id` | *str* | :heavy_check_mark: | Unique completion identifier |
|
||||
| `choices` | List[[models.ChatCompletionChoice](../models/chatcompletionchoice.md)] | :heavy_check_mark: | List of completion choices |
|
||||
| `created` | *float* | :heavy_check_mark: | Unix timestamp of creation |
|
||||
| `model` | *str* | :heavy_check_mark: | Model used for completion |
|
||||
| `object` | [models.ChatCompletionObject](../models/chatcompletionobject.md) | :heavy_check_mark: | N/A |
|
||||
| `system_fingerprint` | *OptionalNullable[str]* | :heavy_minus_sign: | System fingerprint |
|
||||
| `usage` | [Optional[models.CompletionUsage]](../models/completionusage.md) | :heavy_minus_sign: | Token usage statistics |
|
||||
@@ -1,14 +0,0 @@
|
||||
# ChatCompletionAssistantMessageParam
|
||||
|
||||
Assistant message with tool calls and audio support
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `role` | [models.ChatCompletionAssistantMessageParamRole](../models/chatcompletionassistantmessageparamrole.md) | :heavy_check_mark: | N/A |
|
||||
| `content` | [OptionalNullable[models.ChatCompletionAssistantMessageParamContent]](../models/chatcompletionassistantmessageparamcontent.md) | :heavy_minus_sign: | Assistant message content |
|
||||
| `name` | *Optional[str]* | :heavy_minus_sign: | Optional name for the assistant |
|
||||
| `tool_calls` | List[[models.ChatCompletionMessageToolCall](../models/chatcompletionmessagetoolcall.md)] | :heavy_minus_sign: | Tool calls made by the assistant |
|
||||
| `refusal` | *OptionalNullable[str]* | :heavy_minus_sign: | Refusal message if content was refused |
|
||||
@@ -1,25 +0,0 @@
|
||||
# ChatCompletionAssistantMessageParamContent
|
||||
|
||||
Assistant message content
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `str`
|
||||
|
||||
```python
|
||||
value: str = /* values here */
|
||||
```
|
||||
|
||||
### `List[models.ChatCompletionContentPart]`
|
||||
|
||||
```python
|
||||
value: List[models.ChatCompletionContentPart] = /* values here */
|
||||
```
|
||||
|
||||
### `Any`
|
||||
|
||||
```python
|
||||
value: Any = /* values here */
|
||||
```
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
# ChatCompletionChoice
|
||||
|
||||
Chat completion choice
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
||||
| `finish_reason` | [Nullable[models.ChatCompletionChoiceFinishReason]](../models/chatcompletionchoicefinishreason.md) | :heavy_check_mark: | Reason the completion finished |
|
||||
| `index` | *float* | :heavy_check_mark: | Choice index |
|
||||
| `message` | [models.ChatCompletionMessage](../models/chatcompletionmessage.md) | :heavy_check_mark: | Assistant message in completion response |
|
||||
| `logprobs` | [OptionalNullable[models.ChatCompletionTokenLogprobs]](../models/chatcompletiontokenlogprobs.md) | :heavy_minus_sign: | Log probabilities for the completion |
|
||||
@@ -1,14 +0,0 @@
|
||||
# ChatCompletionChoiceFinishReason
|
||||
|
||||
Reason the completion finished
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ---------------- | ---------------- |
|
||||
| `TOOL_CALLS` | tool_calls |
|
||||
| `STOP` | stop |
|
||||
| `LENGTH` | length |
|
||||
| `CONTENT_FILTER` | content_filter |
|
||||
| `ERROR` | error |
|
||||
@@ -1,13 +0,0 @@
|
||||
# ChatCompletionChunkChoice
|
||||
|
||||
Streaming completion choice chunk
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ |
|
||||
| `delta` | [models.ChatCompletionChunkChoiceDelta](../models/chatcompletionchunkchoicedelta.md) | :heavy_check_mark: | Delta changes in streaming response |
|
||||
| `finish_reason` | [Nullable[models.ChatCompletionChunkChoiceFinishReason]](../models/chatcompletionchunkchoicefinishreason.md) | :heavy_check_mark: | N/A |
|
||||
| `index` | *float* | :heavy_check_mark: | N/A |
|
||||
| `logprobs` | [OptionalNullable[models.ChatCompletionTokenLogprobs]](../models/chatcompletiontokenlogprobs.md) | :heavy_minus_sign: | Log probabilities for the completion |
|
||||
@@ -1,16 +0,0 @@
|
||||
# ChatCompletionChunkChoiceDelta
|
||||
|
||||
Delta changes in streaming response
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| `role` | [Optional[models.ChatCompletionChunkChoiceDeltaRole]](../models/chatcompletionchunkchoicedeltarole.md) | :heavy_minus_sign: | The role of the message author |
|
||||
| `content` | *OptionalNullable[str]* | :heavy_minus_sign: | Message content delta |
|
||||
| `reasoning` | *OptionalNullable[str]* | :heavy_minus_sign: | Reasoning content delta |
|
||||
| `refusal` | *OptionalNullable[str]* | :heavy_minus_sign: | Refusal message delta |
|
||||
| `tool_calls` | List[[models.ChatCompletionChunkChoiceDeltaToolCall](../models/chatcompletionchunkchoicedeltatoolcall.md)] | :heavy_minus_sign: | Tool calls delta |
|
||||
| `reasoning_details` | List[[models.ReasoningDetail](../models/reasoningdetail.md)] | :heavy_minus_sign: | Reasoning details delta to send reasoning details back to upstream |
|
||||
| `annotations` | List[[models.AnnotationDetail](../models/annotationdetail.md)] | :heavy_minus_sign: | Annotations delta to send annotations back to upstream |
|
||||
@@ -1,13 +0,0 @@
|
||||
# ChatCompletionChunkChoiceDeltaToolCall
|
||||
|
||||
Tool call delta for streaming responses
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `index` | *float* | :heavy_check_mark: | Tool call index in the array |
|
||||
| `id` | *Optional[str]* | :heavy_minus_sign: | Tool call identifier |
|
||||
| `type` | [Optional[models.ChatCompletionChunkChoiceDeltaToolCallType]](../models/chatcompletionchunkchoicedeltatoolcalltype.md) | :heavy_minus_sign: | Tool call type |
|
||||
| `function` | [Optional[models.ChatCompletionChunkChoiceDeltaToolCallFunction]](../models/chatcompletionchunkchoicedeltatoolcallfunction.md) | :heavy_minus_sign: | Function call details |
|
||||
@@ -1,11 +0,0 @@
|
||||
# ChatCompletionChunkChoiceDeltaToolCallFunction
|
||||
|
||||
Function call details
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| --------------------------------- | --------------------------------- | --------------------------------- | --------------------------------- |
|
||||
| `name` | *Optional[str]* | :heavy_minus_sign: | Function name |
|
||||
| `arguments` | *Optional[str]* | :heavy_minus_sign: | Function arguments as JSON string |
|
||||
@@ -1,10 +0,0 @@
|
||||
# ChatCompletionChunkChoiceDeltaToolCallType
|
||||
|
||||
Tool call type
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ---------- | ---------- |
|
||||
| `FUNCTION` | function |
|
||||
@@ -1,8 +0,0 @@
|
||||
# ChatCompletionChunkWrapper
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- |
|
||||
| `data` | [models.ChatCompletionChunk](../models/chatcompletionchunk.md) | :heavy_check_mark: | Streaming chat completion chunk |
|
||||
@@ -1,25 +0,0 @@
|
||||
# ChatCompletionContentPart
|
||||
|
||||
Content part for chat completion messages
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `models.ChatCompletionContentPartText`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionContentPartText = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatCompletionContentPartImage`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionContentPartImage = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatCompletionContentPartAudio`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionContentPartAudio = /* values here */
|
||||
```
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# ChatCompletionContentPartAudio
|
||||
|
||||
Audio input content part
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| `type` | [models.ChatCompletionContentPartAudioType](../models/chatcompletioncontentpartaudiotype.md) | :heavy_check_mark: | N/A |
|
||||
| `input_audio` | [models.InputAudio](../models/inputaudio.md) | :heavy_check_mark: | N/A |
|
||||
@@ -1,9 +0,0 @@
|
||||
# ChatCompletionContentPartImageImageURL
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- |
|
||||
| `url` | *str* | :heavy_check_mark: | URL of the image (data: URLs supported) |
|
||||
| `detail` | [Optional[models.Detail]](../models/detail.md) | :heavy_minus_sign: | Image detail level for vision models |
|
||||
@@ -1,8 +0,0 @@
|
||||
# ChatCompletionContentPartTextType
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------ | ------ |
|
||||
| `TEXT` | text |
|
||||
@@ -1,34 +0,0 @@
|
||||
# ChatCompletionCreateParams
|
||||
|
||||
Chat completion request parameters
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
||||
| `messages` | List[[models.ChatCompletionMessageParam](../models/chatcompletionmessageparam.md)] | :heavy_check_mark: | List of messages for the conversation | [<br/>{<br/>"role": "user",<br/>"content": "Hello, how are you?"<br/>}<br/>] |
|
||||
| `model` | *Optional[str]* | :heavy_minus_sign: | Model to use for completion | |
|
||||
| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Frequency penalty (-2.0 to 2.0) | |
|
||||
| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | Token logit bias adjustments | |
|
||||
| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | Return log probabilities | |
|
||||
| `top_logprobs` | *OptionalNullable[float]* | :heavy_minus_sign: | Number of top log probabilities to return (0-20) | |
|
||||
| `max_completion_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens in completion | |
|
||||
| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens (deprecated, use max_completion_tokens) | |
|
||||
| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | |
|
||||
| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Presence penalty (-2.0 to 2.0) | |
|
||||
| `reasoning` | [OptionalNullable[models.Reasoning]](../models/reasoning.md) | :heavy_minus_sign: | Reasoning configuration | |
|
||||
| `response_format` | [Optional[models.ResponseFormat]](../models/responseformat.md) | :heavy_minus_sign: | Response format configuration | |
|
||||
| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | Random seed for deterministic outputs | |
|
||||
| `stop` | [OptionalNullable[models.Stop]](../models/stop.md) | :heavy_minus_sign: | Stop sequences (up to 4) | |
|
||||
| `stream` | *OptionalNullable[bool]* | :heavy_minus_sign: | Enable streaming response | |
|
||||
| `stream_options` | [OptionalNullable[models.StreamOptions]](../models/streamoptions.md) | :heavy_minus_sign: | N/A | |
|
||||
| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | Sampling temperature (0-2) | |
|
||||
| `tool_choice` | [Optional[models.ChatCompletionToolChoiceOption]](../models/chatcompletiontoolchoiceoption.md) | :heavy_minus_sign: | Tool choice configuration | |
|
||||
| `tools` | List[[models.ChatCompletionTool](../models/chatcompletiontool.md)] | :heavy_minus_sign: | Available tools for function calling | |
|
||||
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | Nucleus sampling parameter (0-1) | |
|
||||
| `user` | *Optional[str]* | :heavy_minus_sign: | Unique user identifier | |
|
||||
| `fallback_models` | List[*str*] | :heavy_minus_sign: | Order of models to fallback to for this request | |
|
||||
| `reasoning_effort` | [OptionalNullable[models.ReasoningEffort]](../models/reasoningeffort.md) | :heavy_minus_sign: | Reasoning effort | |
|
||||
| `provider` | [OptionalNullable[models.Provider]](../models/provider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | |
|
||||
| `plugins` | List[[models.Plugin](../models/plugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
|
||||
@@ -1,8 +0,0 @@
|
||||
# ChatCompletionCreateParamsTypeText
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------ | ------ |
|
||||
| `TEXT` | text |
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# ChatCompletionChunkChoiceFinishReason
|
||||
# ChatCompletionFinishReason
|
||||
|
||||
|
||||
## Values
|
||||
@@ -1,31 +0,0 @@
|
||||
# ChatCompletionMessageParam
|
||||
|
||||
Chat completion message with role-based discrimination
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `models.ChatCompletionSystemMessageParam`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionSystemMessageParam = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatCompletionUserMessageParam`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionUserMessageParam = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatCompletionAssistantMessageParam`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionAssistantMessageParam = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatCompletionToolMessageParam`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionToolMessageParam = /* values here */
|
||||
```
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# ChatCompletionMessageToolCallFunction
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| --------------------------------- | --------------------------------- | --------------------------------- | --------------------------------- |
|
||||
| `name` | *str* | :heavy_check_mark: | Function name to call |
|
||||
| `arguments` | *str* | :heavy_check_mark: | Function arguments as JSON string |
|
||||
@@ -1,8 +0,0 @@
|
||||
# ChatCompletionNamedToolChoiceFunction
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| --------------------- | --------------------- | --------------------- | --------------------- |
|
||||
| `name` | *str* | :heavy_check_mark: | Function name to call |
|
||||
@@ -1,19 +0,0 @@
|
||||
# ChatCompletionSystemMessageParamContent
|
||||
|
||||
System message content
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `str`
|
||||
|
||||
```python
|
||||
value: str = /* values here */
|
||||
```
|
||||
|
||||
### `List[models.ChatCompletionContentPartText]`
|
||||
|
||||
```python
|
||||
value: List[models.ChatCompletionContentPartText] = /* values here */
|
||||
```
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# ChatCompletionToolChoiceOption
|
||||
|
||||
Tool choice configuration
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `models.ChatCompletionToolChoiceOptionNone`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionToolChoiceOptionNone = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatCompletionToolChoiceOptionAuto`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionToolChoiceOptionAuto = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatCompletionToolChoiceOptionRequired`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionToolChoiceOptionRequired = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatCompletionNamedToolChoice`
|
||||
|
||||
```python
|
||||
value: models.ChatCompletionNamedToolChoice = /* values here */
|
||||
```
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# ChatCompletionToolMessageParamContent
|
||||
|
||||
Tool response content
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `str`
|
||||
|
||||
```python
|
||||
value: str = /* values here */
|
||||
```
|
||||
|
||||
### `List[models.ChatCompletionContentPart]`
|
||||
|
||||
```python
|
||||
value: List[models.ChatCompletionContentPart] = /* values here */
|
||||
```
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# ChatCompletionToolMessageParamRole
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------ | ------ |
|
||||
| `TOOL` | tool |
|
||||
@@ -1,19 +0,0 @@
|
||||
# ChatCompletionUserMessageParamContent
|
||||
|
||||
User message content
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `str`
|
||||
|
||||
```python
|
||||
value: str = /* values here */
|
||||
```
|
||||
|
||||
### `List[models.ChatCompletionContentPart]`
|
||||
|
||||
```python
|
||||
value: List[models.ChatCompletionContentPart] = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatErrorError
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ |
|
||||
| `code` | [Nullable[models.Code]](../models/code.md) | :heavy_check_mark: | N/A |
|
||||
| `message` | *str* | :heavy_check_mark: | N/A |
|
||||
| `param` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
| `type` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,29 @@
|
||||
# ChatGenerationParams
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
||||
| `messages` | List[[models.Message](../models/message.md)] | :heavy_check_mark: | 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[models.Reasoning]](../models/reasoning.md) | :heavy_minus_sign: | N/A |
|
||||
| `response_format` | [Optional[models.ChatGenerationParamsResponseFormatUnion]](../models/chatgenerationparamsresponseformatunion.md) | :heavy_minus_sign: | N/A |
|
||||
| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | N/A |
|
||||
| `stop` | [OptionalNullable[models.ChatGenerationParamsStop]](../models/chatgenerationparamsstop.md) | :heavy_minus_sign: | N/A |
|
||||
| `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A |
|
||||
| `stream_options` | [OptionalNullable[models.ChatStreamOptions]](../models/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[[models.ToolDefinitionJSON](../models/tooldefinitionjson.md)] | :heavy_minus_sign: | N/A |
|
||||
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
|
||||
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsResponseFormatJSONObject
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------ | ------------------------ | ------------------------ | ------------------------ |
|
||||
| `type` | *Literal["json_object"]* | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsResponseFormatPython
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------- | ------------------- | ------------------- | ------------------- |
|
||||
| `type` | *Literal["python"]* | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsResponseFormatText
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------ | ------------------ | ------------------ | ------------------ |
|
||||
| `type` | *Literal["text"]* | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,35 @@
|
||||
# ChatGenerationParamsResponseFormatUnion
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `models.ChatGenerationParamsResponseFormatText`
|
||||
|
||||
```python
|
||||
value: models.ChatGenerationParamsResponseFormatText = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatGenerationParamsResponseFormatJSONObject`
|
||||
|
||||
```python
|
||||
value: models.ChatGenerationParamsResponseFormatJSONObject = /* values here */
|
||||
```
|
||||
|
||||
### `models.ResponseFormatJSONSchema`
|
||||
|
||||
```python
|
||||
value: models.ResponseFormatJSONSchema = /* values here */
|
||||
```
|
||||
|
||||
### `models.ResponseFormatTextGrammar`
|
||||
|
||||
```python
|
||||
value: models.ResponseFormatTextGrammar = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatGenerationParamsResponseFormatPython`
|
||||
|
||||
```python
|
||||
value: models.ChatGenerationParamsResponseFormatPython = /* values here */
|
||||
```
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
# Stop
|
||||
|
||||
Stop sequences (up to 4)
|
||||
# ChatGenerationParamsStop
|
||||
|
||||
|
||||
## Supported Types
|
||||
@@ -17,9 +15,3 @@ value: str = /* values here */
|
||||
value: List[str] = /* values here */
|
||||
```
|
||||
|
||||
### `Any`
|
||||
|
||||
```python
|
||||
value: Any = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# ChatGenerationTokenUsage
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
||||
| `completion_tokens` | *float* | :heavy_check_mark: | N/A |
|
||||
| `prompt_tokens` | *float* | :heavy_check_mark: | N/A |
|
||||
| `total_tokens` | *float* | :heavy_check_mark: | N/A |
|
||||
| `completion_tokens_details` | [OptionalNullable[models.CompletionTokensDetails]](../models/completiontokensdetails.md) | :heavy_minus_sign: | N/A |
|
||||
| `prompt_tokens_details` | [OptionalNullable[models.PromptTokensDetails]](../models/prompttokensdetails.md) | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,29 @@
|
||||
# ChatMessageContentItem
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `models.ChatMessageContentItemText`
|
||||
|
||||
```python
|
||||
value: models.ChatMessageContentItemText = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatMessageContentItemImage`
|
||||
|
||||
```python
|
||||
value: models.ChatMessageContentItemImage = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatMessageContentItemAudio`
|
||||
|
||||
```python
|
||||
value: models.ChatMessageContentItemAudio = /* values here */
|
||||
```
|
||||
|
||||
### `models.ChatMessageContentItemVideo`
|
||||
|
||||
```python
|
||||
value: models.ChatMessageContentItemVideo = /* values here */
|
||||
```
|
||||
|
||||
+3
-6
@@ -1,12 +1,9 @@
|
||||
# ChatCompletionUserMessageParam
|
||||
|
||||
User message
|
||||
# ChatMessageContentItemAudio
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
||||
| `role` | [models.ChatCompletionUserMessageParamRole](../models/chatcompletionusermessageparamrole.md) | :heavy_check_mark: | N/A |
|
||||
| `content` | [models.ChatCompletionUserMessageParamContent](../models/chatcompletionusermessageparamcontent.md) | :heavy_check_mark: | User message content |
|
||||
| `name` | *Optional[str]* | :heavy_minus_sign: | Optional name for the user |
|
||||
| `type` | *Literal["input_audio"]* | :heavy_check_mark: | N/A |
|
||||
| `input_audio` | [models.ChatMessageContentItemAudioInputAudio](../models/chatmessagecontentitemaudioinputaudio.md) | :heavy_check_mark: | N/A |
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
# ChatCompletionContentPartAudioFormat
|
||||
|
||||
Audio format
|
||||
# ChatMessageContentItemAudioFormat
|
||||
|
||||
|
||||
## Values
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatMessageContentItemAudioInputAudio
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
|
||||
| `data` | *str* | :heavy_check_mark: | N/A |
|
||||
| `format_` | [models.ChatMessageContentItemAudioFormat](../models/chatmessagecontentitemaudioformat.md) | :heavy_check_mark: | N/A |
|
||||
@@ -1,11 +1,9 @@
|
||||
# FileAnnotationDetail
|
||||
|
||||
File annotation with content
|
||||
# ChatMessageContentItemImage
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
|
||||
| `type` | [models.TypeFile](../models/typefile.md) | :heavy_check_mark: | N/A |
|
||||
| `file` | [models.File](../models/file.md) | :heavy_check_mark: | N/A |
|
||||
| `type` | *Literal["image_url"]* | :heavy_check_mark: | N/A |
|
||||
| `image_url` | [models.ImageURL](../models/imageurl.md) | :heavy_check_mark: | N/A |
|
||||
@@ -1,6 +1,4 @@
|
||||
# Detail
|
||||
|
||||
Image detail level for vision models
|
||||
# ChatMessageContentItemImageDetail
|
||||
|
||||
|
||||
## Values
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatMessageContentItemText
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------ | ------------------ | ------------------ | ------------------ |
|
||||
| `type` | *Literal["text"]* | :heavy_check_mark: | N/A |
|
||||
| `text` | *str* | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatMessageContentItemVideo
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
|
||||
| `type` | *Literal["input_video"]* | :heavy_check_mark: | N/A |
|
||||
| `video_url` | [models.VideoURL](../models/videourl.md) | :heavy_check_mark: | N/A |
|
||||
@@ -1,13 +1,11 @@
|
||||
# ChatCompletionTokenLogprob
|
||||
|
||||
Token log probability information
|
||||
# ChatMessageTokenLogprob
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- |
|
||||
| `token` | *str* | :heavy_check_mark: | The token |
|
||||
| `logprob` | *float* | :heavy_check_mark: | Log probability of the token |
|
||||
| `bytes_` | List[*float*] | :heavy_check_mark: | UTF-8 bytes of the token |
|
||||
| `top_logprobs` | List[[models.TopLogprob](../models/toplogprob.md)] | :heavy_check_mark: | Top alternative tokens with probabilities |
|
||||
| `token` | *str* | :heavy_check_mark: | N/A |
|
||||
| `logprob` | *float* | :heavy_check_mark: | N/A |
|
||||
| `bytes_` | List[*float*] | :heavy_check_mark: | N/A |
|
||||
| `top_logprobs` | List[[models.TopLogprob](../models/toplogprob.md)] | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatMessageTokenLogprobs
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
||||
| `content` | List[[models.ChatMessageTokenLogprob](../models/chatmessagetokenlogprob.md)] | :heavy_check_mark: | N/A |
|
||||
| `refusal` | List[[models.ChatMessageTokenLogprob](../models/chatmessagetokenlogprob.md)] | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,10 @@
|
||||
# ChatMessageToolCall
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
|
||||
| `id` | *str* | :heavy_check_mark: | N/A |
|
||||
| `type` | *Literal["function"]* | :heavy_check_mark: | N/A |
|
||||
| `function` | [models.ChatMessageToolCallFunction](../models/chatmessagetoolcallfunction.md) | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatMessageToolCallFunction
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------ | ------------------ | ------------------ | ------------------ |
|
||||
| `name` | *str* | :heavy_check_mark: | N/A |
|
||||
| `arguments` | *str* | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,14 @@
|
||||
# ChatResponse
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
||||
| `id` | *str* | :heavy_check_mark: | N/A |
|
||||
| `choices` | List[[models.ChatResponseChoice](../models/chatresponsechoice.md)] | :heavy_check_mark: | N/A |
|
||||
| `created` | *float* | :heavy_check_mark: | N/A |
|
||||
| `model` | *str* | :heavy_check_mark: | N/A |
|
||||
| `object` | *Literal["chat.completion"]* | :heavy_check_mark: | N/A |
|
||||
| `system_fingerprint` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
| `usage` | [Optional[models.ChatGenerationTokenUsage]](../models/chatgenerationtokenusage.md) | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatResponseChoice
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
|
||||
| `finish_reason` | [Nullable[models.ChatCompletionFinishReason]](../models/chatcompletionfinishreason.md) | :heavy_check_mark: | N/A |
|
||||
| `index` | *float* | :heavy_check_mark: | N/A |
|
||||
| `message` | [models.AssistantMessage](../models/assistantmessage.md) | :heavy_check_mark: | N/A |
|
||||
| `logprobs` | [OptionalNullable[models.ChatMessageTokenLogprobs]](../models/chatmessagetokenlogprobs.md) | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatStreamingChoice
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
|
||||
| `delta` | [models.ChatStreamingMessageChunk](../models/chatstreamingmessagechunk.md) | :heavy_check_mark: | N/A |
|
||||
| `finish_reason` | [Nullable[models.ChatCompletionFinishReason]](../models/chatcompletionfinishreason.md) | :heavy_check_mark: | N/A |
|
||||
| `index` | *float* | :heavy_check_mark: | N/A |
|
||||
| `logprobs` | [OptionalNullable[models.ChatMessageTokenLogprobs]](../models/chatmessagetokenlogprobs.md) | :heavy_minus_sign: | N/A |
|
||||
@@ -1,15 +1,12 @@
|
||||
# ReasoningDetailText
|
||||
|
||||
Text reasoning detail
|
||||
# ChatStreamingMessageChunk
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| `type` | [models.ReasoningDetailTextType](../models/reasoningdetailtexttype.md) | :heavy_check_mark: | N/A |
|
||||
| `text` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
| `signature` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
| `id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
| `format_` | [OptionalNullable[models.ReasoningDetailTextFormat]](../models/reasoningdetailtextformat.md) | :heavy_minus_sign: | N/A |
|
||||
| `index` | *Optional[float]* | :heavy_minus_sign: | N/A |
|
||||
| `role` | [Optional[models.ChatStreamingMessageChunkRole]](../models/chatstreamingmessagechunkrole.md) | :heavy_minus_sign: | N/A |
|
||||
| `content` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
| `reasoning` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
| `refusal` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
| `tool_calls` | List[[models.ChatStreamingMessageToolCall](../models/chatstreamingmessagetoolcall.md)] | :heavy_minus_sign: | N/A |
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# ChatCompletionAssistantMessageParamRole
|
||||
# ChatStreamingMessageChunkRole
|
||||
|
||||
|
||||
## Values
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatStreamingMessageToolCall
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| `index` | *float* | :heavy_check_mark: | N/A |
|
||||
| `id` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
| `type` | *Optional[Literal["function"]]* | :heavy_minus_sign: | N/A |
|
||||
| `function` | [Optional[models.ChatStreamingMessageToolCallFunction]](../models/chatstreamingmessagetoolcallfunction.md) | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatStreamingMessageToolCallFunction
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------ | ------------------ | ------------------ | ------------------ |
|
||||
| `name` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
| `arguments` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatStreamingResponseChunk
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
|
||||
| `data` | [models.ChatStreamingResponseChunkData](../models/chatstreamingresponsechunkdata.md) | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,15 @@
|
||||
# ChatStreamingResponseChunkData
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
||||
| `id` | *str* | :heavy_check_mark: | N/A |
|
||||
| `choices` | List[[models.ChatStreamingChoice](../models/chatstreamingchoice.md)] | :heavy_check_mark: | N/A |
|
||||
| `created` | *float* | :heavy_check_mark: | N/A |
|
||||
| `model` | *str* | :heavy_check_mark: | N/A |
|
||||
| `object` | *Literal["chat.completion.chunk"]* | :heavy_check_mark: | N/A |
|
||||
| `system_fingerprint` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
| `error` | [Optional[models.ChatStreamingResponseChunkError]](../models/chatstreamingresponsechunkerror.md) | :heavy_minus_sign: | N/A |
|
||||
| `usage` | [Optional[models.ChatGenerationTokenUsage]](../models/chatgenerationtokenusage.md) | :heavy_minus_sign: | N/A |
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user