From 32b33a46f25e1f7e1e749fe80fcc6860a20cf8f7 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Thu, 1 Oct 2026 15:29:00 +0000 Subject: [PATCH 1/2] ## Python SDK Changes: * `open_router.analytics.get_user_activity()`: `response.data[].cached_tokens` **Added** --- .speakeasy/gen.lock | 33 +++++++++++------------ .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 8 ++++++ .speakeasy/workflow.lock | 10 +++---- RELEASES.md | 12 ++++++++- docs/components/activityitem.mdx | 29 ++++++++++---------- pyproject.toml | 2 +- src/openrouter/_version.py | 4 +-- src/openrouter/components/activityitem.py | 5 ++++ uv.lock | 2 +- 10 files changed, 65 insertions(+), 42 deletions(-) diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 0d4c5e86..51dd9071 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,19 @@ lockVersion: 2.0.0 id: c48cf606-fb42-4a45-9c23-8f0555307828 management: - docChecksum: db5d16fc32dae841671e0c284a3e74b4 + docChecksum: 8418d8ac8a0816998245098e8945e4da docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 1.3.16 - configChecksum: 8c445214e70cd25ef7c941d59d5d5269 + releaseVersion: 1.3.17 + configChecksum: 37d2b4d00364742d875703d9ffcdd68d repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: 7e9fbdb9-c775-4bc8-8565-739609edbb94 - pristine_commit_hash: a664b930e07a08cb7d45bc35df0d7e1c96078ae9 - pristine_tree_hash: 2d585312bc84caf58e056ce8ea2c23f807ca82fb + generation_id: 51b6d41c-8e74-47a2-b89c-bd8f474c2de4 + pristine_commit_hash: 291e2569c4ff1314e7c4df3131966ee300220782 + pristine_tree_hash: 8251c7f52db4337ed4fd35bc7ab9da1b86f80cdb features: python: acceptHeaders: 3.0.0 @@ -88,8 +88,8 @@ trackedFiles: pristine_git_object: 9bed0a58221b443b943524232117bdc43e6c4014 docs/components/activityitem.mdx: id: 20be851aee8a - last_write_checksum: sha1:4aef3633b891fc44c92cb8307adb8d3ce3e7cecd - pristine_git_object: 595c3f1bcc1bb17e920c06fb11df7dae95b6b858 + last_write_checksum: sha1:9faa9e2c8b059ddff8d3ad1bb2320574c732d2a8 + pristine_git_object: c18a6d10bc6c91827223b4c7464c9e7ac68c7e05 docs/components/activityresponse.mdx: id: 5886155bc810 last_write_checksum: sha1:64acd6c3d2db5593d8359474c4e2e31e4db62453 @@ -9948,8 +9948,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:a7f8282814d3a962587a530ebfd6cb5f8a994f21 - pristine_git_object: da03951c817d1f9bc2c89224110466660b263ffd + last_write_checksum: sha1:0175860b3f1b2c4fe0ecd29ce9c2117cd55bd351 + pristine_git_object: b71a3038fdf38463d61c72a645fb977a3234420e scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -9976,8 +9976,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:b88ba320acfa6e84395801080f1845a445b8573a - pristine_git_object: 04c07c48d8aafb0e60a892bde66c111fcf0ed5b3 + last_write_checksum: sha1:360148d6fcae9949a9054166185b7d8cf5ba88c2 + pristine_git_object: cb8eed80311c01eefa335ad2ce99e29a4c693f10 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:30f55a360f41376ab194b9ea725fe4e001a5ae1a @@ -10032,8 +10032,8 @@ trackedFiles: pristine_git_object: ad39bd9765938465f06b5422706fc867db11e468 src/openrouter/components/activityitem.py: id: 3bbe7d35f459 - last_write_checksum: sha1:96430ac2c3aab411c5a05f50ee31ad25eea0790f - pristine_git_object: 3fecf83b2b307a1a9ef7714d5111ab724abba6a6 + last_write_checksum: sha1:ad3ecdeb41d51f3e1698f0828df6cf2eca94d72d + pristine_git_object: f46f04b35d85a73e61fa1e06b8b6a8f4e802a7e7 src/openrouter/components/activityresponse.py: id: 0bd8d79c3144 last_write_checksum: sha1:db8e3247cf9eb2c235d32949d36f7ae95870e8ed @@ -14378,7 +14378,7 @@ examples: speakeasy-default-get-user-activity: responses: "200": - application/json: {"data": [{"byok_usage_inference": 0.012, "completion_tokens": 125, "date": "2025-08-24", "endpoint_id": "550e8400-e29b-41d4-a716-446655440000", "model": "openai/gpt-4.1", "model_permaslug": "openai/gpt-4.1-2025-04-14", "prompt_tokens": 50, "provider_name": "OpenAI", "reasoning_tokens": 25, "requests": 5, "usage": 0.015}]} + application/json: {"data": [{"byok_usage_inference": 0.012, "cached_tokens": 10, "completion_tokens": 125, "date": "2025-08-24", "endpoint_id": "550e8400-e29b-41d4-a716-446655440000", "model": "openai/gpt-4.1", "model_permaslug": "openai/gpt-4.1-2025-04-14", "prompt_tokens": 50, "provider_name": "OpenAI", "reasoning_tokens": 25, "requests": 5, "usage": 0.015}]} "400": application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} "401": @@ -18226,5 +18226,4 @@ examples: examplesVersion: 1.0.2 releaseNotes: | ## Python SDK Changes: - * `open_router.generations.get_generation()`: `error.status[400]` **Added** - * `open_router.generations.list_generation_content()`: `error.status[400]` **Added** + * `open_router.analytics.get_user_activity()`: `response.data[].cached_tokens` **Added** diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 6cab0c63..70d42b2f 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -36,7 +36,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.16 + version: 1.3.17 additionalDependencies: dev: {} main: {} diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 59d2276e..181f0635 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -59,6 +59,7 @@ components: ActivityItem: example: byok_usage_inference: 0.012 + cached_tokens: 10 completion_tokens: 125 date: '2025-08-24' endpoint_id: '550e8400-e29b-41d4-a716-446655440000' @@ -75,6 +76,10 @@ components: example: 0.012 format: 'double' type: 'number' + cached_tokens: + description: 'Total prompt tokens read from the provider prompt cache (cache hits). Generally a subset of `prompt_tokens`; for replayed response-cache hits the provider may report the two counters over disjoint token sets, so `cached_tokens` can exceed `prompt_tokens`.' + example: 10 + type: 'integer' completion_tokens: description: 'Total completion tokens generated' example: 125 @@ -132,11 +137,13 @@ components: - 'prompt_tokens' - 'completion_tokens' - 'reasoning_tokens' + - 'cached_tokens' type: 'object' ActivityResponse: example: data: - byok_usage_inference: 0.012 + cached_tokens: 10 completion_tokens: 125 date: '2025-08-24' endpoint_id: '550e8400-e29b-41d4-a716-446655440000' @@ -33272,6 +33279,7 @@ paths: example: data: - byok_usage_inference: 0.012 + cached_tokens: 10 completion_tokens: 125 date: '2025-08-24' endpoint_id: '550e8400-e29b-41d4-a716-446655440000' diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 4a47e8cc..c0c606bf 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.787.0 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:ce23790edfaffc0a537784d8535152708f0d3c5fc9789e7b173cc6a6525094ce - sourceBlobDigest: sha256:f0cdcda8afd64f749176ada8505daea308dc590d5441fc1a8cd72aa3e37d054a + sourceRevisionDigest: sha256:075c5db7b965cedf544f79f7fd4ecd5baa33cad4ea653cbc6fd871f869aeddab + sourceBlobDigest: sha256:9781f963a634a11eb740145be6e1d262af486605ee98e5fc0448d37b3e94a488 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:ce23790edfaffc0a537784d8535152708f0d3c5fc9789e7b173cc6a6525094ce - sourceBlobDigest: sha256:f0cdcda8afd64f749176ada8505daea308dc590d5441fc1a8cd72aa3e37d054a + sourceRevisionDigest: sha256:075c5db7b965cedf544f79f7fd4ecd5baa33cad4ea653cbc6fd871f869aeddab + sourceBlobDigest: sha256:9781f963a634a11eb740145be6e1d262af486605ee98e5fc0448d37b3e94a488 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:7478c6f034a1e48bf1a0829fdf24b40c068e4a192db9d38a424bb962fcc38d38 + codeSamplesRevisionDigest: sha256:f8277ef7e169f7b54df9d968058ef59f4ec9081aa938a564b6e96a5bef900774 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/RELEASES.md b/RELEASES.md index a8ae21af..2c98c1ab 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2929,4 +2929,14 @@ Based on: ### Generated - [python v1.3.16] . ### Releases -- [PyPI v1.3.16] https://pypi.org/project/openrouter/1.3.16 - . \ No newline at end of file +- [PyPI v1.3.16] https://pypi.org/project/openrouter/1.3.16 - . + +## 2026-10-01 15:26:20 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.17] . +### Releases +- [PyPI v1.3.17] https://pypi.org/project/openrouter/1.3.17 - . \ No newline at end of file diff --git a/docs/components/activityitem.mdx b/docs/components/activityitem.mdx index 595c3f1b..c18a6d10 100644 --- a/docs/components/activityitem.mdx +++ b/docs/components/activityitem.mdx @@ -4,17 +4,18 @@ title: "ActivityItem" ## Fields -| 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 | -| `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 | -| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | ID of the workspace this activity is attributed to. Only present when `group_by=workspace` is passed; the response is then split per workspace. Activity recorded before workspace resolution existed is attributed to the account default workspace. | 550e8400-e29b-41d4-a716-446655440000 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `byok_usage_inference` | *float* | :heavy_check_mark: | BYOK inference cost in USD (external credits spent) | 0.012 | +| `cached_tokens` | *int* | :heavy_check_mark: | Total prompt tokens read from the provider prompt cache (cache hits). Generally a subset of `prompt_tokens`; for replayed response-cache hits the provider may report the two counters over disjoint token sets, so `cached_tokens` can exceed `prompt_tokens`. | 10 | +| `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 | +| `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 | +| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | ID of the workspace this activity is attributed to. Only present when `group_by=workspace` is passed; the response is then split per workspace. Activity recorded before workspace resolution existed is attributed to the account default workspace. | 550e8400-e29b-41d4-a716-446655440000 | \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index da03951c..b71a3038 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.16" +version = "1.3.17" description = "Official Python Client SDK for OpenRouter." authors = [{ name = "OpenRouter" },] readme = "README-PYPI.md" diff --git a/src/openrouter/_version.py b/src/openrouter/_version.py index 04c07c48..cb8eed80 100644 --- a/src/openrouter/_version.py +++ b/src/openrouter/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "openrouter" -__version__: str = "1.3.16" +__version__: str = "1.3.17" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.914.0" -__user_agent__: str = "speakeasy-sdk/python 1.3.16 2.914.0 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.17 2.914.0 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/components/activityitem.py b/src/openrouter/components/activityitem.py index 3fecf83b..f46f04b3 100644 --- a/src/openrouter/components/activityitem.py +++ b/src/openrouter/components/activityitem.py @@ -11,6 +11,8 @@ class ActivityItemTypedDict(TypedDict): byok_usage_inference: float r"""BYOK inference cost in USD (external credits spent)""" + cached_tokens: int + r"""Total prompt tokens read from the provider prompt cache (cache hits). Generally a subset of `prompt_tokens`; for replayed response-cache hits the provider may report the two counters over disjoint token sets, so `cached_tokens` can exceed `prompt_tokens`.""" completion_tokens: int r"""Total completion tokens generated""" date_: str @@ -39,6 +41,9 @@ class ActivityItem(BaseModel): byok_usage_inference: float r"""BYOK inference cost in USD (external credits spent)""" + cached_tokens: int + r"""Total prompt tokens read from the provider prompt cache (cache hits). Generally a subset of `prompt_tokens`; for replayed response-cache hits the provider may report the two counters over disjoint token sets, so `cached_tokens` can exceed `prompt_tokens`.""" + completion_tokens: int r"""Total completion tokens generated""" diff --git a/uv.lock b/uv.lock index 8a7a8f5b..6ded7fda 100644 --- a/uv.lock +++ b/uv.lock @@ -213,7 +213,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.16" +version = "1.3.17" source = { editable = "." } dependencies = [ { name = "httpcore" }, From 7db5f05a1d490dac8981c069f88b8d8041a4b11d Mon Sep 17 00:00:00 2001 From: "speakeasy-github[bot]" <128539517+speakeasy-github[bot]@users.noreply.github.com> Date: Thu, 1 Oct 2026 15:29:08 +0000 Subject: [PATCH 2/2] empty commit to trigger [run-tests] workflow