mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-31 12:30:30 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13d706e274 |
@@ -1,86 +0,0 @@
|
||||
name: Auto-merge Speakeasy PR
|
||||
|
||||
# Speakeasy mode:pr opens PRs (speakeasy-sdk-regen-*) and labels them
|
||||
# patch/minor/major. Merge automatically so sdk_publish.yaml can run.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [labeled]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
concurrency:
|
||||
group: auto-merge-speakeasy
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
auto-merge:
|
||||
if: |
|
||||
github.event.sender.login == 'github-actions[bot]' &&
|
||||
github.event.pull_request.user.login == 'github-actions[bot]' &&
|
||||
startsWith(github.event.pull_request.head.ref, 'speakeasy-sdk-regen-') &&
|
||||
contains(github.event.pull_request.title, '🐝 Update SDK') &&
|
||||
contains(fromJSON('["patch", "minor", "major"]'), github.event.label.name)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Close superseded Speakeasy PRs
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
CURRENT_PR="${{ github.event.pull_request.number }}"
|
||||
|
||||
PRIOR_JSON=$(gh pr list \
|
||||
--repo "${{ github.repository }}" \
|
||||
--state open \
|
||||
--search "head:speakeasy-sdk-regen-" \
|
||||
--limit 500 \
|
||||
--json number \
|
||||
| jq -r --arg cur "$CURRENT_PR" \
|
||||
'[.[].number | select(tostring != $cur)] | .[]')
|
||||
|
||||
if [ -z "$PRIOR_JSON" ]; then
|
||||
echo "No superseded Speakeasy PRs to close"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mapfile -t PRIOR <<< "$PRIOR_JSON"
|
||||
|
||||
echo "Closing ${#PRIOR[@]} superseded Speakeasy PR(s)"
|
||||
for N in "${PRIOR[@]}"; do
|
||||
gh pr close "$N" --repo "${{ github.repository }}" --delete-branch \
|
||||
--comment "Superseded by newer Speakeasy SDK generation PR #${CURRENT_PR}" \
|
||||
|| echo "::warning::Failed to close PR #$N (continuing)"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
- name: Auto-merge Speakeasy PR
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
PR_NUM="${{ github.event.pull_request.number }}"
|
||||
REPO="${{ github.repository }}"
|
||||
|
||||
STATE=$(gh pr view "$PR_NUM" --repo "$REPO" --json state --jq .state)
|
||||
if [ "$STATE" != "OPEN" ]; then
|
||||
echo "PR #$PR_NUM is $STATE — skipping merge"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Prefer GitHub auto-merge when required checks exist; otherwise
|
||||
# squash-merge directly (same pattern as sdk-release-prs.yaml).
|
||||
AUTO_MERGE_NOOP_PATTERN='is in clean status|protected branch rules|Branch does not have required protected branch rules'
|
||||
if gh pr merge "$PR_NUM" --repo "$REPO" --squash --auto --delete-branch 2> /tmp/gh-merge.err; then
|
||||
echo "Auto-merge enabled for Speakeasy PR #$PR_NUM"
|
||||
elif grep -qiE "$AUTO_MERGE_NOOP_PATTERN" /tmp/gh-merge.err; then
|
||||
echo "Auto-merge not applicable — merging PR #$PR_NUM directly"
|
||||
cat /tmp/gh-merge.err >&2
|
||||
gh pr merge "$PR_NUM" --repo "$REPO" --squash --delete-branch
|
||||
else
|
||||
echo "::error::Failed to enable auto-merge on Speakeasy PR #$PR_NUM"
|
||||
cat /tmp/gh-merge.err >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,36 +0,0 @@
|
||||
name: Generate (spec change merged)
|
||||
permissions:
|
||||
checks: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
statuses: write
|
||||
id-token: write
|
||||
"on":
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
force:
|
||||
description: Force generation of SDKs
|
||||
type: boolean
|
||||
default: false
|
||||
set_version:
|
||||
description: optionally set a specific SDK version
|
||||
type: string
|
||||
pull_request:
|
||||
types: [closed]
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- .speakeasy/in.openapi.yaml
|
||||
|
||||
jobs:
|
||||
generate:
|
||||
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
|
||||
uses: speakeasy-api/sdk-generation-action/.github/workflows/workflow-executor.yaml@v15
|
||||
with:
|
||||
force: ${{ github.event.inputs.force }}
|
||||
mode: pr
|
||||
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 }}
|
||||
+2
-14
@@ -1,25 +1,13 @@
|
||||
.venv/
|
||||
venv/
|
||||
src/*.egg-info/
|
||||
**/__pycache__/
|
||||
.pytest_cache/
|
||||
.python-version
|
||||
.DS_Store
|
||||
pyrightconfig.json
|
||||
**/.speakeasy/temp/
|
||||
**/.speakeasy/logs/
|
||||
.speakeasy/reports
|
||||
# Build artifacts
|
||||
/dist
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*.egg-info/
|
||||
*.egg
|
||||
# Speakeasy generation artifacts (generated in OSS repo, not here)
|
||||
.speakeasy/*.lock
|
||||
.speakeasy/*.openapi.yaml
|
||||
/docs
|
||||
# Environment
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
.DS_Store
|
||||
.venv/
|
||||
|
||||
+1255
-9606
File diff suppressed because it is too large
Load Diff
+1
-5
@@ -25,14 +25,13 @@ generation:
|
||||
schemas:
|
||||
allOfMergeStrategy: shallowMerge
|
||||
requestBodyFieldName: ""
|
||||
persistentEdits: {}
|
||||
tests:
|
||||
generateTests: false
|
||||
generateNewTests: true
|
||||
skipResponseBodyAssertions: false
|
||||
preApplyUnionDiscriminators: true
|
||||
python:
|
||||
version: 0.10.1
|
||||
version: 0.9.0
|
||||
additionalDependencies:
|
||||
dev: {}
|
||||
main: {}
|
||||
@@ -47,7 +46,6 @@ python:
|
||||
- OpenRouter
|
||||
baseErrorName: OpenRouterError
|
||||
clientServerStatusCodesAsErrors: true
|
||||
constFieldCasing: upper
|
||||
defaultErrorName: OpenRouterDefaultError
|
||||
description: Official Python Client SDK for OpenRouter.
|
||||
enableCustomCodeRegions: false
|
||||
@@ -59,7 +57,6 @@ python:
|
||||
flattenGlobalSecurity: true
|
||||
flattenRequests: true
|
||||
flatteningOrder: parameters-first
|
||||
forwardCompatibleUnionsByDefault: tagged-only
|
||||
imports:
|
||||
option: openapi
|
||||
paths:
|
||||
@@ -80,7 +77,6 @@ python:
|
||||
outputModelSuffix: output
|
||||
packageManager: uv
|
||||
packageName: openrouter
|
||||
preApplyUnionDiscriminators: false
|
||||
pytestFilterWarnings: []
|
||||
pytestTimeout: 0
|
||||
responseFormat: flat
|
||||
|
||||
+17087
-31189
File diff suppressed because it is too large
Load Diff
+17029
-30996
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
overlay: 1.0.0
|
||||
x-speakeasy-jsonpath: rfc9535
|
||||
info:
|
||||
title: Simplify redundant allOf inline schemas
|
||||
version: 0.0.0
|
||||
actions:
|
||||
- target: "$..allOf[?@.enum && !@['$ref']]"
|
||||
description: >
|
||||
Remove inline enum definitions that duplicate a $ref enum in the same
|
||||
allOf. These are artifacts from zod-openapi .extend() serialization.
|
||||
remove: true
|
||||
@@ -1,10 +0,0 @@
|
||||
overlay: 1.0.0
|
||||
x-speakeasy-jsonpath: rfc9535
|
||||
info:
|
||||
title: Convert boolean query params from string to boolean
|
||||
version: 0.0.0
|
||||
actions:
|
||||
- target: $..parameters[?@.schema["x-openrouter-type"] == "boolean"].schema
|
||||
description: Convert x-openrouter-type boolean params from string to boolean
|
||||
update:
|
||||
type: boolean
|
||||
@@ -1,10 +0,0 @@
|
||||
overlay: 1.0.0
|
||||
x-speakeasy-jsonpath: rfc9535
|
||||
info:
|
||||
title: Fix nullable pagination params
|
||||
version: 0.0.0
|
||||
actions:
|
||||
- target: $..parameters[?@.name == "offset" && @.in == "query"].schema
|
||||
description: Remove nullable from offset query params to fix mypy errors in pagination helpers
|
||||
update:
|
||||
nullable: false
|
||||
+15
-12
@@ -1,24 +1,30 @@
|
||||
speakeasyVersion: 1.680.0
|
||||
speakeasyVersion: 1.666.0
|
||||
sources:
|
||||
OpenRouter API:
|
||||
-OAS:
|
||||
sourceNamespace: open-router-chat-completions-api
|
||||
sourceRevisionDigest: sha256:6ca77315c3cd31ab7e308e010b26b7c9eb366b11b78ea9c71179facc4daaf97b
|
||||
sourceBlobDigest: sha256:8bada810c7c5ddb302c51dbbbb36dd0c9a45c4ba1c5e44af1646f69fc2a38751
|
||||
sourceRevisionDigest: sha256:01256c8494de6bfc13c36d82ae316a6a13d402194f844618bcd4d59e34f325f3
|
||||
sourceBlobDigest: sha256:4c80e48fd5e1cd030e68d664eb93984b4d5946867252ff1755a2bd2a05eccd4e
|
||||
tags:
|
||||
- latest
|
||||
- speakeasy-sdk-regen-1781819160
|
||||
OpenRouter API:
|
||||
sourceNamespace: open-router-chat-completions-api
|
||||
sourceRevisionDigest: sha256:33bc86b7a9b24082a410a8b5cbdd05ee359c9be2c88a2947893942d6bca20dca
|
||||
sourceBlobDigest: sha256:63c840be5dfe448c1d3f6ec9c15e1d92d117b35cccd134b1e736e1fb563d013d
|
||||
tags:
|
||||
- latest
|
||||
- main
|
||||
- 1.0.0
|
||||
targets:
|
||||
open-router:
|
||||
source: OpenRouter API
|
||||
sourceNamespace: open-router-chat-completions-api
|
||||
sourceRevisionDigest: sha256:6ca77315c3cd31ab7e308e010b26b7c9eb366b11b78ea9c71179facc4daaf97b
|
||||
sourceBlobDigest: sha256:8bada810c7c5ddb302c51dbbbb36dd0c9a45c4ba1c5e44af1646f69fc2a38751
|
||||
sourceRevisionDigest: sha256:33bc86b7a9b24082a410a8b5cbdd05ee359c9be2c88a2947893942d6bca20dca
|
||||
sourceBlobDigest: sha256:63c840be5dfe448c1d3f6ec9c15e1d92d117b35cccd134b1e736e1fb563d013d
|
||||
codeSamplesNamespace: open-router-python-code-samples
|
||||
codeSamplesRevisionDigest: sha256:80ceff338c097e19bf3951fd00e8010fc7c102b916a684eeec33d507b7a3844f
|
||||
codeSamplesRevisionDigest: sha256:b23dcc24419d8d006315e89e7a2fe131e28d72f19edb4fa920c97658e9e78073
|
||||
workflow:
|
||||
workflowVersion: 1.0.0
|
||||
speakeasyVersion: 1.680.0
|
||||
speakeasyVersion: 1.666.0
|
||||
sources:
|
||||
OpenRouter API:
|
||||
inputs:
|
||||
@@ -27,9 +33,6 @@ workflow:
|
||||
- location: .speakeasy/overlays/open-enums.overlay.yaml
|
||||
- location: .speakeasy/overlays/remove-rss-responses.overlay.yaml
|
||||
- location: .speakeasy/overlays/add-headers.overlay.yaml
|
||||
- location: .speakeasy/overlays/allof-simplify.overlay.yaml
|
||||
- location: .speakeasy/overlays/boolean-query-params.overlay.yaml
|
||||
- location: .speakeasy/overlays/fix-nullable-pagination.overlay.yaml
|
||||
output: .speakeasy/out.openapi.yaml
|
||||
registry:
|
||||
location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
workflowVersion: 1.0.0
|
||||
speakeasyVersion: 1.680.0
|
||||
speakeasyVersion: 1.666.0
|
||||
sources:
|
||||
OpenRouter API:
|
||||
inputs:
|
||||
@@ -8,9 +8,6 @@ sources:
|
||||
- location: .speakeasy/overlays/open-enums.overlay.yaml
|
||||
- location: .speakeasy/overlays/remove-rss-responses.overlay.yaml
|
||||
- location: .speakeasy/overlays/add-headers.overlay.yaml
|
||||
- location: .speakeasy/overlays/allof-simplify.overlay.yaml
|
||||
- location: .speakeasy/overlays/boolean-query-params.overlay.yaml
|
||||
- location: .speakeasy/overlays/fix-nullable-pagination.overlay.yaml
|
||||
output: .speakeasy/out.openapi.yaml
|
||||
registry:
|
||||
location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# OpenRouter Python SDK
|
||||
|
||||
The OpenRouter Python SDK is a type-safe toolkit for building AI applications with access to 400+ language models through a unified API.
|
||||
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?
|
||||
|
||||
|
||||
+9
-66
@@ -1,6 +1,6 @@
|
||||
# OpenRouter SDK
|
||||
# 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 400+ models across providers in an easy and type-safe way.
|
||||
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.
|
||||
|
||||
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).
|
||||
|
||||
@@ -169,69 +169,6 @@ asyncio.run(main())
|
||||
|
||||
<!-- No Custom HTTP Client [http-client] -->
|
||||
|
||||
<!-- Start Pagination [pagination] -->
|
||||
## Pagination
|
||||
|
||||
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
|
||||
returned response object will have a `Next` method that can be called to pull down the next group of results. If the
|
||||
return value of `Next` is `None`, then there are no more pages to be fetched.
|
||||
|
||||
Here's an example of one such pagination call:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
http_referer="<value>",
|
||||
x_open_router_title="<value>",
|
||||
x_open_router_categories="<value>",
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.byok.list()
|
||||
|
||||
while res is not None:
|
||||
# Handle items
|
||||
|
||||
res = res.next()
|
||||
|
||||
```
|
||||
<!-- End Pagination [pagination] -->
|
||||
|
||||
<!-- Start File uploads [file-upload] -->
|
||||
## File uploads
|
||||
|
||||
Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
|
||||
>
|
||||
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
http_referer="<value>",
|
||||
x_open_router_title="<value>",
|
||||
x_open_router_categories="<value>",
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.files.upload(file={
|
||||
"file_name": "example.file",
|
||||
"content": open("example.file", "rb"),
|
||||
})
|
||||
|
||||
# Handle response
|
||||
print(res)
|
||||
|
||||
```
|
||||
<!-- End File uploads [file-upload] -->
|
||||
|
||||
<!-- Start Resource Management [resource-management] -->
|
||||
## Resource Management
|
||||
|
||||
@@ -309,4 +246,10 @@ To run the test suite, you'll need to set up your environment with an OpenRouter
|
||||
|
||||
```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.
|
||||
@@ -1,6 +1,6 @@
|
||||
# OpenRouter SDK
|
||||
# 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 400+ models across providers in an easy and type-safe way.
|
||||
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.
|
||||
|
||||
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).
|
||||
|
||||
@@ -169,69 +169,6 @@ asyncio.run(main())
|
||||
|
||||
<!-- No Custom HTTP Client [http-client] -->
|
||||
|
||||
<!-- Start Pagination [pagination] -->
|
||||
## Pagination
|
||||
|
||||
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
|
||||
returned response object will have a `Next` method that can be called to pull down the next group of results. If the
|
||||
return value of `Next` is `None`, then there are no more pages to be fetched.
|
||||
|
||||
Here's an example of one such pagination call:
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
http_referer="<value>",
|
||||
x_open_router_title="<value>",
|
||||
x_open_router_categories="<value>",
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.byok.list()
|
||||
|
||||
while res is not None:
|
||||
# Handle items
|
||||
|
||||
res = res.next()
|
||||
|
||||
```
|
||||
<!-- End Pagination [pagination] -->
|
||||
|
||||
<!-- Start File uploads [file-upload] -->
|
||||
## File uploads
|
||||
|
||||
Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
|
||||
>
|
||||
|
||||
```python
|
||||
from openrouter import OpenRouter
|
||||
import os
|
||||
|
||||
|
||||
with OpenRouter(
|
||||
http_referer="<value>",
|
||||
x_open_router_title="<value>",
|
||||
x_open_router_categories="<value>",
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.files.upload(file={
|
||||
"file_name": "example.file",
|
||||
"content": open("example.file", "rb"),
|
||||
})
|
||||
|
||||
# Handle response
|
||||
print(res)
|
||||
|
||||
```
|
||||
<!-- End File uploads [file-upload] -->
|
||||
|
||||
<!-- Start Resource Management [resource-management] -->
|
||||
## Resource Management
|
||||
|
||||
@@ -309,4 +246,10 @@ To run the test suite, you'll need to set up your environment with an OpenRouter
|
||||
|
||||
```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.
|
||||
+1
-31
@@ -8,34 +8,4 @@ Based on:
|
||||
### Generated
|
||||
- [python v0.0.16] .
|
||||
### Releases
|
||||
- [PyPI v0.0.16] https://pypi.org/project/openrouter/0.0.16 - .
|
||||
|
||||
## 2026-06-11 00:55:55
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc
|
||||
- Speakeasy CLI 1.680.0 (2.788.4) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [python v0.9.2] .
|
||||
### Releases
|
||||
- [PyPI v0.9.2] https://pypi.org/project/openrouter/0.9.2 - .
|
||||
|
||||
## 2026-06-17 00:59:07
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc
|
||||
- Speakeasy CLI 1.680.0 (2.788.4) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [python v0.10.0] .
|
||||
### Releases
|
||||
- [PyPI v0.10.0] https://pypi.org/project/openrouter/0.10.0 - .
|
||||
|
||||
## 2026-06-18 21:51:38
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc
|
||||
- Speakeasy CLI 1.680.0 (2.788.4) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [python v0.10.1] .
|
||||
### Releases
|
||||
- [PyPI v0.10.1] https://pypi.org/project/openrouter/0.10.1 - .
|
||||
- [PyPI v0.0.16] https://pypi.org/project/openrouter/0.0.16 - .
|
||||
@@ -12,10 +12,12 @@ with OpenRouter(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = open_router.analytics.get_user_activity()
|
||||
res = open_router.beta.responses.send(service_tier="auto", stream=False)
|
||||
|
||||
# Handle response
|
||||
print(res)
|
||||
with res as event_stream:
|
||||
for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
```
|
||||
|
||||
</br>
|
||||
@@ -37,10 +39,12 @@ async def main():
|
||||
api_key=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
) as open_router:
|
||||
|
||||
res = await open_router.analytics.get_user_activity_async()
|
||||
res = await open_router.beta.responses.send_async(service_tier="auto", stream=False)
|
||||
|
||||
# Handle response
|
||||
print(res)
|
||||
async with res as event_stream:
|
||||
async for event in event_stream:
|
||||
# handle event
|
||||
print(event, flush=True)
|
||||
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Action
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `components.ActionSearch`
|
||||
|
||||
```python
|
||||
value: components.ActionSearch = /* values here */
|
||||
```
|
||||
|
||||
### `components.ActionOpenPage`
|
||||
|
||||
```python
|
||||
value: components.ActionOpenPage = /* values here */
|
||||
```
|
||||
|
||||
### `components.ActionFindInPage`
|
||||
|
||||
```python
|
||||
value: components.ActionFindInPage = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# ActionFindInPage
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
|
||||
| `type` | [components.TypeFindInPage](../components/typefindinpage.md) | :heavy_check_mark: | N/A |
|
||||
| `pattern` | *str* | :heavy_check_mark: | N/A |
|
||||
| `url` | *str* | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ActionOpenPage
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- |
|
||||
| `type` | [components.TypeOpenPage](../components/typeopenpage.md) | :heavy_check_mark: | N/A |
|
||||
| `url` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ActionSearch
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- |
|
||||
| `type` | [components.TypeSearch](../components/typesearch.md) | :heavy_check_mark: | N/A |
|
||||
| `query` | *str* | :heavy_check_mark: | N/A |
|
||||
| `queries` | List[*str*] | :heavy_minus_sign: | N/A |
|
||||
| `sources` | List[[components.Source](../components/source.md)] | :heavy_minus_sign: | N/A |
|
||||
@@ -5,14 +5,14 @@
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- |
|
||||
| `byok_usage_inference` | *float* | :heavy_check_mark: | BYOK inference cost in USD (external credits spent) | 0.012 |
|
||||
| `completion_tokens` | *int* | :heavy_check_mark: | Total completion tokens generated | 125 |
|
||||
| `date_` | *str* | :heavy_check_mark: | Date of the activity (YYYY-MM-DD format) | 2025-08-24 |
|
||||
| `endpoint_id` | *str* | :heavy_check_mark: | Unique identifier for the endpoint | 550e8400-e29b-41d4-a716-446655440000 |
|
||||
| `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 |
|
||||
| `prompt_tokens` | *int* | :heavy_check_mark: | Total prompt tokens used | 50 |
|
||||
| `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 |
|
||||
| `reasoning_tokens` | *int* | :heavy_check_mark: | Total reasoning tokens used | 25 |
|
||||
| `requests` | *int* | :heavy_check_mark: | Number of requests made | 5 |
|
||||
| `usage` | *float* | :heavy_check_mark: | Total cost in USD (OpenRouter credits spent) | 0.015 |
|
||||
| `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 |
|
||||
@@ -0,0 +1,9 @@
|
||||
# AllowedTools
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------ | ------------------ | ------------------ | ------------------ |
|
||||
| `tool_names` | List[*str*] | :heavy_minus_sign: | N/A |
|
||||
| `read_only` | *Optional[bool]* | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,8 @@
|
||||
# Always
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------ | ------------------ | ------------------ | ------------------ |
|
||||
| `tool_names` | List[*str*] | :heavy_minus_sign: | N/A |
|
||||
@@ -7,8 +7,8 @@ Model architecture information
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
|
||||
| `input_modalities` | List[[components.InputModality](../components/inputmodality.md)] | :heavy_check_mark: | Supported input modalities | |
|
||||
| `instruct_type` | [Nullable[components.InstructType]](../components/instructtype.md) | :heavy_check_mark: | Instruction format type | chatml |
|
||||
| `tokenizer` | [Nullable[components.Tokenizer]](../components/tokenizer.md) | :heavy_check_mark: | N/A | GPT |
|
||||
| `instruct_type` | [Nullable[components.InstructType]](../components/instructtype.md) | :heavy_check_mark: | Instruction format type | |
|
||||
| `modality` | *Nullable[str]* | :heavy_check_mark: | Primary modality of the model | text |
|
||||
| `output_modalities` | List[[components.OutputModality](../components/outputmodality.md)] | :heavy_check_mark: | Supported output modalities | |
|
||||
| `tokenizer` | [Nullable[components.Tokenizer]](../components/tokenizer.md) | :heavy_check_mark: | N/A | GPT |
|
||||
| `input_modalities` | List[[components.InputModality](../components/inputmodality.md)] | :heavy_check_mark: | Supported input modalities | |
|
||||
| `output_modalities` | List[[components.OutputModality](../components/outputmodality.md)] | :heavy_check_mark: | Supported output modalities | |
|
||||
@@ -0,0 +1,18 @@
|
||||
# AssistantMessage
|
||||
|
||||
Assistant message for requests and responses
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `role` | [components.AssistantMessageRole](../components/assistantmessagerole.md) | :heavy_check_mark: | N/A | |
|
||||
| `content` | [OptionalNullable[components.AssistantMessageContent]](../components/assistantmessagecontent.md) | :heavy_minus_sign: | Assistant message content | |
|
||||
| `name` | *Optional[str]* | :heavy_minus_sign: | Optional name for the assistant | |
|
||||
| `tool_calls` | List[[components.ChatMessageToolCall](../components/chatmessagetoolcall.md)] | :heavy_minus_sign: | Tool calls made by the assistant | |
|
||||
| `refusal` | *OptionalNullable[str]* | :heavy_minus_sign: | Refusal message if content was refused | |
|
||||
| `reasoning` | *OptionalNullable[str]* | :heavy_minus_sign: | Reasoning output | |
|
||||
| `reasoning_details` | List[[components.ReasoningDetailUnion](../components/reasoningdetailunion.md)] | :heavy_minus_sign: | Reasoning details for extended thinking models | |
|
||||
| `images` | List[[components.AssistantMessageImages](../components/assistantmessageimages.md)] | :heavy_minus_sign: | Generated images from image generation models | [<br/>{<br/>"image_url": {<br/>"url": "data:image/png;base64,iVBORw0KGgo..."<br/>}<br/>}<br/>] |
|
||||
| `audio` | [Optional[components.ChatCompletionAudioOutput]](../components/chatcompletionaudiooutput.md) | :heavy_minus_sign: | Audio output data or reference | {<br/>"id": "audio_abc123",<br/>"expires_at": 1677652400,<br/>"data": "UklGRnoGAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQoGAACBhYqFbF1f",<br/>"transcript": "Hello! How can I help you today?"<br/>} |
|
||||
@@ -0,0 +1,25 @@
|
||||
# AssistantMessageContent
|
||||
|
||||
Assistant message content
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `str`
|
||||
|
||||
```python
|
||||
value: str = /* values here */
|
||||
```
|
||||
|
||||
### `List[components.ChatMessageContentItem]`
|
||||
|
||||
```python
|
||||
value: List[components.ChatMessageContentItem] = /* values here */
|
||||
```
|
||||
|
||||
### `Any`
|
||||
|
||||
```python
|
||||
value: Any = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# AssistantMessageImages
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| `image_url` | [components.AssistantMessageImagesImageURL](../components/assistantmessageimagesimageurl.md) | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,8 @@
|
||||
# AssistantMessageImagesImageURL
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- |
|
||||
| `url` | *str* | :heavy_check_mark: | URL or base64-encoded data of the generated image |
|
||||
@@ -0,0 +1,8 @@
|
||||
# AssistantMessageRole
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ----------- | ----------- |
|
||||
| `ASSISTANT` | assistant |
|
||||
@@ -0,0 +1,10 @@
|
||||
# Background
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------- | ------------- |
|
||||
| `TRANSPARENT` | transparent |
|
||||
| `OPAQUE` | opaque |
|
||||
| `AUTO` | auto |
|
||||
@@ -0,0 +1,11 @@
|
||||
# CacheControl
|
||||
|
||||
Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
||||
| `type` | [components.ChatGenerationParamsType](../components/chatgenerationparamstype.md) | :heavy_check_mark: | N/A |
|
||||
| `ttl` | [Optional[components.ChatGenerationParamsTTL]](../components/chatgenerationparamsttl.md) | :heavy_minus_sign: | 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 |
|
||||
@@ -0,0 +1,13 @@
|
||||
# ChatCompletionAudioOutput
|
||||
|
||||
Audio output data or reference
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------- | -------------------------- | -------------------------- | -------------------------- |
|
||||
| `id` | *Optional[str]* | :heavy_minus_sign: | Audio output identifier |
|
||||
| `expires_at` | *Optional[float]* | :heavy_minus_sign: | Audio expiration timestamp |
|
||||
| `data` | *Optional[str]* | :heavy_minus_sign: | Base64 encoded audio data |
|
||||
| `transcript` | *Optional[str]* | :heavy_minus_sign: | Audio transcript |
|
||||
@@ -0,0 +1,12 @@
|
||||
# ChatCompletionFinishReason
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ---------------- | ---------------- |
|
||||
| `TOOL_CALLS` | tool_calls |
|
||||
| `STOP` | stop |
|
||||
| `LENGTH` | length |
|
||||
| `CONTENT_FILTER` | content_filter |
|
||||
| `ERROR` | error |
|
||||
@@ -0,0 +1,40 @@
|
||||
# ChatGenerationParams
|
||||
|
||||
Chat completion request parameters
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `provider` | [OptionalNullable[components.ChatGenerationParamsProvider]](../components/chatgenerationparamsprovider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | |
|
||||
| `plugins` | List[[components.ChatGenerationParamsPluginUnion](../components/chatgenerationparamspluginunion.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
|
||||
| `user` | *Optional[str]* | :heavy_minus_sign: | Unique user identifier | user-123 |
|
||||
| `session_id` | *Optional[str]* | :heavy_minus_sign: | A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters. | |
|
||||
| `trace` | [Optional[components.ChatGenerationParamsTrace]](../components/chatgenerationparamstrace.md) | :heavy_minus_sign: | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | |
|
||||
| `messages` | List[[components.Message](../components/message.md)] | :heavy_check_mark: | List of messages for the conversation | [<br/>{<br/>"role": "user",<br/>"content": "Hello!"<br/>}<br/>] |
|
||||
| `model` | *Optional[str]* | :heavy_minus_sign: | Model to use for completion | openai/gpt-4 |
|
||||
| `models` | List[*str*] | :heavy_minus_sign: | Models to use for completion | [<br/>"openai/gpt-4",<br/>"openai/gpt-4o"<br/>] |
|
||||
| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Frequency penalty (-2.0 to 2.0) | 0 |
|
||||
| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | Token logit bias adjustments | {<br/>"50256": -100<br/>} |
|
||||
| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | Return log probabilities | false |
|
||||
| `top_logprobs` | *OptionalNullable[float]* | :heavy_minus_sign: | Number of top log probabilities to return (0-20) | 5 |
|
||||
| `max_completion_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens in completion | 100 |
|
||||
| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16. | 100 |
|
||||
| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | {<br/>"user_id": "user-123",<br/>"session_id": "session-456"<br/>} |
|
||||
| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Presence penalty (-2.0 to 2.0) | 0 |
|
||||
| `reasoning` | [Optional[components.Reasoning]](../components/reasoning.md) | :heavy_minus_sign: | Configuration options for reasoning models | {<br/>"effort": "medium",<br/>"summary": "concise"<br/>} |
|
||||
| `response_format` | [Optional[components.ResponseFormat]](../components/responseformat.md) | :heavy_minus_sign: | Response format configuration | {<br/>"type": "json_object"<br/>} |
|
||||
| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | Random seed for deterministic outputs | 42 |
|
||||
| `stop` | [OptionalNullable[components.Stop]](../components/stop.md) | :heavy_minus_sign: | Stop sequences (up to 4) | [<br/>""<br/>] |
|
||||
| `stream` | *Optional[bool]* | :heavy_minus_sign: | Enable streaming response | false |
|
||||
| `stream_options` | [OptionalNullable[components.ChatStreamOptions]](../components/chatstreamoptions.md) | :heavy_minus_sign: | Streaming configuration options | {<br/>"include_usage": true<br/>} |
|
||||
| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | Sampling temperature (0-2) | 0.7 |
|
||||
| `parallel_tool_calls` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | |
|
||||
| `tool_choice` | [Optional[components.ToolChoiceOption]](../components/toolchoiceoption.md) | :heavy_minus_sign: | Tool choice configuration | auto |
|
||||
| `tools` | List[[components.ToolDefinitionJSON](../components/tooldefinitionjson.md)] | :heavy_minus_sign: | Available tools for function calling | [<br/>{<br/>"type": "function",<br/>"function": {<br/>"name": "get_weather",<br/>"description": "Get weather"<br/>}<br/>}<br/>] |
|
||||
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | Nucleus sampling parameter (0-1) | 1 |
|
||||
| `debug` | [Optional[components.DebugOptions]](../components/debugoptions.md) | :heavy_minus_sign: | Debug options for inspecting request transformations (streaming only) | {<br/>"echo_upstream_body": true<br/>} |
|
||||
| `image_config` | Dict[str, [components.ChatGenerationParamsImageConfig](../components/chatgenerationparamsimageconfig.md)] | :heavy_minus_sign: | Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details. | {<br/>"aspect_ratio": "16:9"<br/>} |
|
||||
| `modalities` | List[[components.Modality](../components/modality.md)] | :heavy_minus_sign: | Output modalities for the response. Supported values are "text", "image", and "audio". | [<br/>"text",<br/>"image"<br/>] |
|
||||
| `cache_control` | [Optional[components.CacheControl]](../components/cachecontrol.md) | :heavy_minus_sign: | Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models. | |
|
||||
@@ -0,0 +1,13 @@
|
||||
# ChatGenerationParamsBy
|
||||
|
||||
The provider sorting strategy (price, throughput, latency)
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------ | ------------ |
|
||||
| `PRICE` | price |
|
||||
| `THROUGHPUT` | throughput |
|
||||
| `LATENCY` | latency |
|
||||
| `EXACTO` | exacto |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatGenerationParamsEngine
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| -------- | -------- |
|
||||
| `NATIVE` | native |
|
||||
| `EXA` | exa |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsIDAutoRouter
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------- | ------------- |
|
||||
| `AUTO_ROUTER` | auto-router |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsIDContextCompression
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| --------------------- | --------------------- |
|
||||
| `CONTEXT_COMPRESSION` | context-compression |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsIDFileParser
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------- | ------------- |
|
||||
| `FILE_PARSER` | file-parser |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsIDModeration
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------ | ------------ |
|
||||
| `MODERATION` | moderation |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsIDResponseHealing
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------------ | ------------------ |
|
||||
| `RESPONSE_HEALING` | response-healing |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsIDWeb
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ----- | ----- |
|
||||
| `WEB` | web |
|
||||
@@ -0,0 +1,17 @@
|
||||
# ChatGenerationParamsIgnore
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `components.ProviderName`
|
||||
|
||||
```python
|
||||
value: components.ProviderName = /* values here */
|
||||
```
|
||||
|
||||
### `str`
|
||||
|
||||
```python
|
||||
value: str = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# ChatGenerationParamsImageConfig
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `str`
|
||||
|
||||
```python
|
||||
value: str = /* values here */
|
||||
```
|
||||
|
||||
### `float`
|
||||
|
||||
```python
|
||||
value: float = /* values here */
|
||||
```
|
||||
|
||||
### `List[Nullable[Any]]`
|
||||
|
||||
```python
|
||||
value: List[Nullable[Any]] = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# ChatGenerationParamsMaxPrice
|
||||
|
||||
The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------- | ------------------------------- | ------------------------------- | ------------------------------- | ------------------------------- |
|
||||
| `prompt` | *Optional[str]* | :heavy_minus_sign: | Price per million prompt tokens | 1000 |
|
||||
| `completion` | *Optional[str]* | :heavy_minus_sign: | N/A | 1000 |
|
||||
| `image` | *Optional[str]* | :heavy_minus_sign: | N/A | 1000 |
|
||||
| `audio` | *Optional[str]* | :heavy_minus_sign: | N/A | 1000 |
|
||||
| `request` | *Optional[str]* | :heavy_minus_sign: | N/A | 1000 |
|
||||
@@ -0,0 +1,17 @@
|
||||
# ChatGenerationParamsOnly
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `components.ProviderName`
|
||||
|
||||
```python
|
||||
value: components.ProviderName = /* values here */
|
||||
```
|
||||
|
||||
### `str`
|
||||
|
||||
```python
|
||||
value: str = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# ChatGenerationParamsOrder
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `components.ProviderName`
|
||||
|
||||
```python
|
||||
value: components.ProviderName = /* values here */
|
||||
```
|
||||
|
||||
### `str`
|
||||
|
||||
```python
|
||||
value: str = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatGenerationParamsPartition
|
||||
|
||||
Partitioning strategy for sorting: "model" (default) groups endpoints by model before sorting (fallback models remain fallbacks), "none" sorts all endpoints together regardless of model.
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------- | ------- |
|
||||
| `MODEL` | model |
|
||||
| `NONE` | none |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsPdf
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
|
||||
| `engine` | [Optional[components.ChatGenerationParamsPdfEngine]](../components/chatgenerationparamspdfengine.md) | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,10 @@
|
||||
# ChatGenerationParamsPdfEngine
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------- | ------------- |
|
||||
| `MISTRAL_OCR` | mistral-ocr |
|
||||
| `PDF_TEXT` | pdf-text |
|
||||
| `NATIVE` | native |
|
||||
@@ -0,0 +1,10 @@
|
||||
# ChatGenerationParamsPluginAutoRouter
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `id` | [components.ChatGenerationParamsIDAutoRouter](../components/chatgenerationparamsidautorouter.md) | :heavy_check_mark: | N/A | |
|
||||
| `enabled` | *Optional[bool]* | :heavy_minus_sign: | Set to false to disable the auto-router plugin for this request. Defaults to true. | |
|
||||
| `allowed_models` | List[*str*] | :heavy_minus_sign: | List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., "anthropic/*" matches all Anthropic models). When not specified, uses the default supported models list. | [<br/>"anthropic/*",<br/>"openai/gpt-4o",<br/>"google/*"<br/>] |
|
||||
@@ -0,0 +1,10 @@
|
||||
# ChatGenerationParamsPluginContextCompression
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
||||
| `id` | [components.ChatGenerationParamsIDContextCompression](../components/chatgenerationparamsidcontextcompression.md) | :heavy_check_mark: | N/A |
|
||||
| `enabled` | *Optional[bool]* | :heavy_minus_sign: | Set to false to disable the context-compression plugin for this request. Defaults to true. |
|
||||
| `engine` | [Optional[components.ContextCompressionEngine]](../components/contextcompressionengine.md) | :heavy_minus_sign: | The compression engine to use. Defaults to "middle-out". |
|
||||
@@ -0,0 +1,10 @@
|
||||
# ChatGenerationParamsPluginFileParser
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
||||
| `id` | [components.ChatGenerationParamsIDFileParser](../components/chatgenerationparamsidfileparser.md) | :heavy_check_mark: | N/A |
|
||||
| `enabled` | *Optional[bool]* | :heavy_minus_sign: | Set to false to disable the file-parser plugin for this request. Defaults to true. |
|
||||
| `pdf` | [Optional[components.PDFParserOptions]](../components/pdfparseroptions.md) | :heavy_minus_sign: | Options for PDF parsing. |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsPluginModeration
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
||||
| `id` | [components.ChatGenerationParamsIDModeration](../components/chatgenerationparamsidmoderation.md) | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatGenerationParamsPluginResponseHealing
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| `id` | [components.ChatGenerationParamsIDResponseHealing](../components/chatgenerationparamsidresponsehealing.md) | :heavy_check_mark: | N/A |
|
||||
| `enabled` | *Optional[bool]* | :heavy_minus_sign: | Set to false to disable the response-healing plugin for this request. Defaults to true. |
|
||||
@@ -0,0 +1,41 @@
|
||||
# ChatGenerationParamsPluginUnion
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `components.ChatGenerationParamsPluginAutoRouter`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsPluginAutoRouter = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatGenerationParamsPluginModeration`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsPluginModeration = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatGenerationParamsPluginWeb`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsPluginWeb = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatGenerationParamsPluginFileParser`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsPluginFileParser = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatGenerationParamsPluginResponseHealing`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsPluginResponseHealing = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatGenerationParamsPluginContextCompression`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsPluginContextCompression = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# ChatGenerationParamsPluginWeb
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `id` | [components.ChatGenerationParamsIDWeb](../components/chatgenerationparamsidweb.md) | :heavy_check_mark: | N/A | |
|
||||
| `enabled` | *Optional[bool]* | :heavy_minus_sign: | Set to false to disable the web-search plugin for this request. Defaults to true. | |
|
||||
| `max_results` | *Optional[float]* | :heavy_minus_sign: | N/A | |
|
||||
| `search_prompt` | *Optional[str]* | :heavy_minus_sign: | N/A | |
|
||||
| `engine` | [Optional[components.WebSearchEngine]](../components/websearchengine.md) | :heavy_minus_sign: | The search engine to use for web search. | |
|
||||
| `include_domains` | List[*str*] | :heavy_minus_sign: | A list of domains to restrict web search results to. Supports wildcards (e.g. "*.substack.com") and path filtering (e.g. "openai.com/blog"). | [<br/>"example.com",<br/>"*.substack.com",<br/>"openai.com/blog"<br/>] |
|
||||
| `exclude_domains` | List[*str*] | :heavy_minus_sign: | A list of domains to exclude from web search results. Supports wildcards (e.g. "*.substack.com") and path filtering (e.g. "openai.com/blog"). | [<br/>"example.com",<br/>"*.substack.com",<br/>"openai.com/blog"<br/>] |
|
||||
@@ -0,0 +1,22 @@
|
||||
# ChatGenerationParamsProvider
|
||||
|
||||
When multiple model providers are available, optionally indicate your routing preference.
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `allow_fallbacks` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to allow backup providers to serve requests<br/>- true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider.<br/>- false: use only the primary/custom provider, and return the upstream error if it's unavailable.<br/> | |
|
||||
| `require_parameters` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest. | |
|
||||
| `data_collection` | [OptionalNullable[components.DataCollection]](../components/datacollection.md) | :heavy_minus_sign: | Data collection setting. If no available model provider meets the requirement, your request will return an error.<br/>- allow: (default) allow providers which store user data non-transiently and may train on it<br/><br/>- deny: use only providers which do not collect user data. | allow |
|
||||
| `zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used. | true |
|
||||
| `enforce_distillable_text` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used. | true |
|
||||
| `order` | List[[components.ChatGenerationParamsOrder](../components/chatgenerationparamsorder.md)] | :heavy_minus_sign: | An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message. | |
|
||||
| `only` | List[[components.ChatGenerationParamsOnly](../components/chatgenerationparamsonly.md)] | :heavy_minus_sign: | List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request. | |
|
||||
| `ignore` | List[[components.ChatGenerationParamsIgnore](../components/chatgenerationparamsignore.md)] | :heavy_minus_sign: | List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request. | |
|
||||
| `quantizations` | List[[components.Quantization](../components/quantization.md)] | :heavy_minus_sign: | A list of quantization levels to filter the provider by. | |
|
||||
| `sort` | [OptionalNullable[components.ChatGenerationParamsSortUnion]](../components/chatgenerationparamssortunion.md) | :heavy_minus_sign: | N/A | price |
|
||||
| `max_price` | [Optional[components.ChatGenerationParamsMaxPrice]](../components/chatgenerationparamsmaxprice.md) | :heavy_minus_sign: | The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. | |
|
||||
| `preferred_min_throughput` | [OptionalNullable[components.PreferredMinThroughput]](../components/preferredminthroughput.md) | :heavy_minus_sign: | Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold. | 100 |
|
||||
| `preferred_max_latency` | [OptionalNullable[components.PreferredMaxLatency]](../components/preferredmaxlatency.md) | :heavy_minus_sign: | Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold. | 5 |
|
||||
@@ -0,0 +1,13 @@
|
||||
# ChatGenerationParamsProviderSort
|
||||
|
||||
The provider sorting strategy (price, throughput, latency)
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------ | ------------ |
|
||||
| `PRICE` | price |
|
||||
| `THROUGHPUT` | throughput |
|
||||
| `LATENCY` | latency |
|
||||
| `EXACTO` | exacto |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatGenerationParamsProviderSortConfig
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `by` | [OptionalNullable[components.ChatGenerationParamsBy]](../components/chatgenerationparamsby.md) | :heavy_minus_sign: | The provider sorting strategy (price, throughput, latency) | price |
|
||||
| `partition` | [OptionalNullable[components.ChatGenerationParamsPartition]](../components/chatgenerationparamspartition.md) | :heavy_minus_sign: | Partitioning strategy for sorting: "model" (default) groups endpoints by model before sorting (fallback models remain fallbacks), "none" sorts all endpoints together regardless of model. | model |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatGenerationParamsProviderSortConfigEnum
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------ | ------------ |
|
||||
| `PRICE` | price |
|
||||
| `THROUGHPUT` | throughput |
|
||||
| `LATENCY` | latency |
|
||||
| `EXACTO` | exacto |
|
||||
@@ -0,0 +1,17 @@
|
||||
# ChatGenerationParamsProviderSortConfigUnion
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `components.ChatGenerationParamsProviderSortConfig`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsProviderSortConfig = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatGenerationParamsProviderSortConfigEnum`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsProviderSortConfigEnum = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatGenerationParamsRoute
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ---------- | ---------- |
|
||||
| `FALLBACK` | fallback |
|
||||
| `SORT` | sort |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatGenerationParamsSortEnum
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------ | ------------ |
|
||||
| `PRICE` | price |
|
||||
| `THROUGHPUT` | throughput |
|
||||
| `LATENCY` | latency |
|
||||
| `EXACTO` | exacto |
|
||||
@@ -0,0 +1,25 @@
|
||||
# ChatGenerationParamsSortUnion
|
||||
|
||||
The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed.
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `components.ChatGenerationParamsProviderSort`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsProviderSort = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatGenerationParamsProviderSortConfigUnion`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsProviderSortConfigUnion = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatGenerationParamsSortEnum`
|
||||
|
||||
```python
|
||||
value: components.ChatGenerationParamsSortEnum = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# ChatGenerationParamsTrace
|
||||
|
||||
Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------- | -------------------------- | -------------------------- | -------------------------- |
|
||||
| `trace_id` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
| `trace_name` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
| `span_name` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
| `generation_name` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
| `parent_span_id` | *Optional[str]* | :heavy_minus_sign: | N/A |
|
||||
| `__pydantic_extra__` | Dict[str, *Nullable[Any]*] | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatGenerationParamsTTL
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------- | ------- |
|
||||
| `FIVEM` | 5m |
|
||||
| `ONEH` | 1h |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatGenerationParamsType
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ----------- | ----------- |
|
||||
| `EPHEMERAL` | ephemeral |
|
||||
@@ -0,0 +1,14 @@
|
||||
# ChatGenerationTokenUsage
|
||||
|
||||
Token usage statistics
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
||||
| `completion_tokens` | *float* | :heavy_check_mark: | Number of tokens in the completion |
|
||||
| `prompt_tokens` | *float* | :heavy_check_mark: | Number of tokens in the prompt |
|
||||
| `total_tokens` | *float* | :heavy_check_mark: | Total number of tokens |
|
||||
| `completion_tokens_details` | [OptionalNullable[components.CompletionTokensDetails]](../components/completiontokensdetails.md) | :heavy_minus_sign: | Detailed completion token usage |
|
||||
| `prompt_tokens_details` | [OptionalNullable[components.PromptTokensDetails]](../components/prompttokensdetails.md) | :heavy_minus_sign: | Detailed prompt token usage |
|
||||
@@ -0,0 +1,37 @@
|
||||
# ChatMessageContentItem
|
||||
|
||||
Content part for chat completion messages
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `components.ChatMessageContentItemText`
|
||||
|
||||
```python
|
||||
value: components.ChatMessageContentItemText = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatMessageContentItemImage`
|
||||
|
||||
```python
|
||||
value: components.ChatMessageContentItemImage = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatMessageContentItemAudio`
|
||||
|
||||
```python
|
||||
value: components.ChatMessageContentItemAudio = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatMessageContentItem1`
|
||||
|
||||
```python
|
||||
value: components.ChatMessageContentItem1 = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatMessageContentItemFile`
|
||||
|
||||
```python
|
||||
value: components.ChatMessageContentItemFile = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# ChatMessageContentItem1
|
||||
|
||||
|
||||
## Supported Types
|
||||
|
||||
### `components.ChatMessageContentItemVideoLegacy`
|
||||
|
||||
```python
|
||||
value: components.ChatMessageContentItemVideoLegacy = /* values here */
|
||||
```
|
||||
|
||||
### `components.ChatMessageContentItemVideo`
|
||||
|
||||
```python
|
||||
value: components.ChatMessageContentItemVideo = /* values here */
|
||||
```
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatMessageContentItemAudio
|
||||
|
||||
Audio input content part. Supported audio formats vary by provider.
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| `type` | [components.ChatMessageContentItemAudioType](../components/chatmessagecontentitemaudiotype.md) | :heavy_check_mark: | N/A |
|
||||
| `input_audio` | [components.ChatMessageContentItemAudioInputAudio](../components/chatmessagecontentitemaudioinputaudio.md) | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatMessageContentItemAudioInputAudio
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
||||
| `data` | *str* | :heavy_check_mark: | Base64 encoded audio data |
|
||||
| `format_` | *str* | :heavy_check_mark: | Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider. |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatMessageContentItemAudioType
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------- | ------------- |
|
||||
| `INPUT_AUDIO` | input_audio |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatMessageContentItemCacheControl
|
||||
|
||||
Cache control for the content part
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
||||
| `type` | [components.ChatMessageContentItemCacheControlType](../components/chatmessagecontentitemcachecontroltype.md) | :heavy_check_mark: | N/A |
|
||||
| `ttl` | [Optional[components.ChatMessageContentItemCacheControlTTL]](../components/chatmessagecontentitemcachecontrolttl.md) | :heavy_minus_sign: | N/A |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatMessageContentItemCacheControlTTL
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------- | ------- |
|
||||
| `FIVEM` | 5m |
|
||||
| `ONEH` | 1h |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatMessageContentItemCacheControlType
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ----------- | ----------- |
|
||||
| `EPHEMERAL` | ephemeral |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatMessageContentItemFile
|
||||
|
||||
File content part for document processing
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| `type` | [components.ChatMessageContentItemFileType](../components/chatmessagecontentitemfiletype.md) | :heavy_check_mark: | N/A |
|
||||
| `file` | [components.File](../components/file.md) | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatMessageContentItemFileType
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------ | ------ |
|
||||
| `FILE` | file |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatMessageContentItemImage
|
||||
|
||||
Image content part for vision models
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
||||
| `type` | [components.ChatMessageContentItemImageType](../components/chatmessagecontentitemimagetype.md) | :heavy_check_mark: | N/A |
|
||||
| `image_url` | [components.ChatMessageContentItemImageImageURL](../components/chatmessagecontentitemimageimageurl.md) | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,12 @@
|
||||
# ChatMessageContentItemImageDetail
|
||||
|
||||
Image detail level for vision models
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------ | ------ |
|
||||
| `AUTO` | auto |
|
||||
| `LOW` | low |
|
||||
| `HIGH` | high |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatMessageContentItemImageImageURL
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ |
|
||||
| `url` | *str* | :heavy_check_mark: | URL of the image (data: URLs supported) |
|
||||
| `detail` | [Optional[components.ChatMessageContentItemImageDetail]](../components/chatmessagecontentitemimagedetail.md) | :heavy_minus_sign: | Image detail level for vision models |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatMessageContentItemImageType
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ----------- | ----------- |
|
||||
| `IMAGE_URL` | image_url |
|
||||
@@ -0,0 +1,12 @@
|
||||
# ChatMessageContentItemText
|
||||
|
||||
Text content part
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
||||
| `type` | [components.ChatMessageContentItemTextType](../components/chatmessagecontentitemtexttype.md) | :heavy_check_mark: | N/A | |
|
||||
| `text` | *str* | :heavy_check_mark: | N/A | |
|
||||
| `cache_control` | [Optional[components.ChatMessageContentItemCacheControl]](../components/chatmessagecontentitemcachecontrol.md) | :heavy_minus_sign: | Cache control for the content part | {<br/>"type": "ephemeral",<br/>"ttl": "5m"<br/>} |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatMessageContentItemTextType
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------ | ------ |
|
||||
| `TEXT` | text |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatMessageContentItemVideo
|
||||
|
||||
Video input content part
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| `type` | [components.ChatMessageContentItemVideoType](../components/chatmessagecontentitemvideotype.md) | :heavy_check_mark: | N/A |
|
||||
| `video_url` | [components.VideoInput](../components/videoinput.md) | :heavy_check_mark: | Video input object |
|
||||
@@ -0,0 +1,13 @@
|
||||
# ~~ChatMessageContentItemVideoLegacy~~
|
||||
|
||||
Video input content part (legacy format - deprecated)
|
||||
|
||||
> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible.
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| `type` | [components.ChatMessageContentItemVideoLegacyType](../components/chatmessagecontentitemvideolegacytype.md) | :heavy_check_mark: | N/A |
|
||||
| `video_url` | [components.VideoInput](../components/videoinput.md) | :heavy_check_mark: | Video input object |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatMessageContentItemVideoLegacyType
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ------------- | ------------- |
|
||||
| `INPUT_VIDEO` | input_video |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatMessageContentItemVideoType
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ----------- | ----------- |
|
||||
| `VIDEO_URL` | video_url |
|
||||
@@ -0,0 +1,13 @@
|
||||
# ChatMessageTokenLogprob
|
||||
|
||||
Token log probability information
|
||||
|
||||
|
||||
## 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[[components.ChatMessageTokenLogprobTopLogprob](../components/chatmessagetokenlogprobtoplogprob.md)] | :heavy_check_mark: | Top alternative tokens with probabilities |
|
||||
@@ -0,0 +1,11 @@
|
||||
# ChatMessageTokenLogprobs
|
||||
|
||||
Log probabilities for the completion
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
|
||||
| `content` | List[[components.ChatMessageTokenLogprob](../components/chatmessagetokenlogprob.md)] | :heavy_check_mark: | Log probabilities for content tokens |
|
||||
| `refusal` | List[[components.ChatMessageTokenLogprob](../components/chatmessagetokenlogprob.md)] | :heavy_minus_sign: | Log probabilities for refusal tokens |
|
||||
@@ -0,0 +1,10 @@
|
||||
# ChatMessageTokenLogprobTopLogprob
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ------------------ | ------------------ | ------------------ | ------------------ |
|
||||
| `token` | *str* | :heavy_check_mark: | N/A |
|
||||
| `logprob` | *float* | :heavy_check_mark: | N/A |
|
||||
| `bytes_` | List[*float*] | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,12 @@
|
||||
# ChatMessageToolCall
|
||||
|
||||
Tool call made by the assistant
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||||
| `id` | *str* | :heavy_check_mark: | Tool call identifier |
|
||||
| `type` | [components.ChatMessageToolCallType](../components/chatmessagetoolcalltype.md) | :heavy_check_mark: | N/A |
|
||||
| `function` | [components.ChatMessageToolCallFunction](../components/chatmessagetoolcallfunction.md) | :heavy_check_mark: | N/A |
|
||||
@@ -0,0 +1,9 @@
|
||||
# ChatMessageToolCallFunction
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| --------------------------------- | --------------------------------- | --------------------------------- | --------------------------------- |
|
||||
| `name` | *str* | :heavy_check_mark: | Function name to call |
|
||||
| `arguments` | *str* | :heavy_check_mark: | Function arguments as JSON string |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatMessageToolCallType
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ---------- | ---------- |
|
||||
| `FUNCTION` | function |
|
||||
@@ -0,0 +1,16 @@
|
||||
# ChatResponse
|
||||
|
||||
Chat completion response
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `id` | *str* | :heavy_check_mark: | Unique completion identifier | chatcmpl-123 |
|
||||
| `choices` | List[[components.ChatResponseChoice](../components/chatresponsechoice.md)] | :heavy_check_mark: | List of completion choices | |
|
||||
| `created` | *float* | :heavy_check_mark: | Unix timestamp of creation | 1677652288 |
|
||||
| `model` | *str* | :heavy_check_mark: | Model used for completion | openai/gpt-4 |
|
||||
| `object` | [components.ChatResponseObject](../components/chatresponseobject.md) | :heavy_check_mark: | N/A | |
|
||||
| `system_fingerprint` | *Nullable[str]* | :heavy_check_mark: | System fingerprint | fp_44709d6fcb |
|
||||
| `usage` | [Optional[components.ChatGenerationTokenUsage]](../components/chatgenerationtokenusage.md) | :heavy_minus_sign: | Token usage statistics | {<br/>"completion_tokens": 15,<br/>"prompt_tokens": 10,<br/>"total_tokens": 25,<br/>"completion_tokens_details": {<br/>"reasoning_tokens": 5<br/>},<br/>"prompt_tokens_details": {<br/>"cached_tokens": 2<br/>}<br/>} |
|
||||
@@ -0,0 +1,13 @@
|
||||
# ChatResponseChoice
|
||||
|
||||
Chat completion choice
|
||||
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
|
||||
| `finish_reason` | *Nullable[Any]* | :heavy_check_mark: | N/A | |
|
||||
| `index` | *float* | :heavy_check_mark: | Choice index | 0 |
|
||||
| `message` | [components.AssistantMessage](../components/assistantmessage.md) | :heavy_check_mark: | Assistant message for requests and responses | {<br/>"role": "user",<br/>"content": "What is the capital of France?"<br/>} |
|
||||
| `logprobs` | [OptionalNullable[components.ChatMessageTokenLogprobs]](../components/chatmessagetokenlogprobs.md) | :heavy_minus_sign: | Log probabilities for the completion | {<br/>"content": [<br/>{<br/>"token": " Hello",<br/>"logprob": -0.612345,<br/>"bytes": null,<br/>"top_logprobs": []<br/>}<br/>],<br/>"refusal": null<br/>} |
|
||||
@@ -0,0 +1,8 @@
|
||||
# ChatResponseObject
|
||||
|
||||
|
||||
## Values
|
||||
|
||||
| Name | Value |
|
||||
| ----------------- | ----------------- |
|
||||
| `CHAT_COMPLETION` | chat.completion |
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user