diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 1fdb3f1..aa027bc 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: a444511ee53d41b62d62b2d23ddd3b64 + docChecksum: 7263f7a45045933c0fa87b21e7e6fd9b docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 0.11.25 - configChecksum: b10f43281932fd64b0c43f8577a40816 + releaseVersion: 0.11.26 + configChecksum: 2a949e81cf5d40ef993b72355e7e75eb repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: 554b7889-8ccd-4aef-a14b-c347df957007 - pristine_commit_hash: 95be3ea8a18d40e9df231449f23161356fdfd5ff - pristine_tree_hash: e9b22615b85a97ffd1078604414fc174d55b227f + generation_id: 7695231f-3e30-4c88-921a-f9175c463593 + pristine_commit_hash: 5ccb0c48efa3160204f8671518dd705cc930a0a7 + pristine_tree_hash: 111ea5b13d73fd98a6d6c24a7a46a513a3104a9c features: python: acceptHeaders: 3.0.0 @@ -3886,8 +3886,12 @@ trackedFiles: pristine_git_object: 3d340325d192b54a5d039336cce2bd35d12445ac docs/components/pricing.mdx: id: 6816d700f8b1 - last_write_checksum: sha1:ac5c56af4e56eb98da5686e33a224950dfbb8207 - pristine_git_object: 78ac34b5053103dc4261c2fbeb9833f97ef109db + last_write_checksum: sha1:c9f49a270c1ddcaf2b354b2c0f7ceb277ca5eff4 + pristine_git_object: 0ca9bdf9bf2b1909a4a78e99b58fde78b311becd + docs/components/pricingoverride.mdx: + id: 74675f38c1c6 + last_write_checksum: sha1:5e64e9edbb013f04ee3741fe7c5dbd2fa54b544b + pristine_git_object: f8291256ac4a4aeed8bf79f1bad1e3b45cbaa354 docs/components/promptcachebreakpoint.mdx: id: c135956dc623 last_write_checksum: sha1:1b0c9884eb9b6fe1d4fdf822c75cb566ead67e07 @@ -3966,8 +3970,8 @@ trackedFiles: pristine_git_object: 4498d08fd82f26a210eeed2b9659e6a0b321f9ef docs/components/publicpricing.mdx: id: 61fb18b7ff94 - last_write_checksum: sha1:41c3b03c9eb4883d41e128e1b2d549ddb608c317 - pristine_git_object: 0d8f6cf2cca158ec93dd8afdc29c0cb377053fbd + last_write_checksum: sha1:53550f414931189b91a148ca9039aefb5899a7ee + pristine_git_object: 4a17b2b3dd05ea85ea9847689c13692540007f07 docs/components/quantization.mdx: id: 9d062e4ee362 last_write_checksum: sha1:4cb3588933fe1ca8592669f8ec1bef1cf0986e28 @@ -6658,8 +6662,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:ecba4ec7fe5c538617fb6e42582204ae5711d106 - pristine_git_object: 6804383f389474f6b72740ce0a281ba45ed8251d + last_write_checksum: sha1:a62f150fb014bd2f019526c2847cab9afcd90648 + pristine_git_object: bcd7637f7dd41ea5aa8e3374fbafe096f1d44c11 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -6686,8 +6690,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:a776602f2cf82d2f44e51bbbd69dfeee7a7f46f3 - pristine_git_object: d272f6c0b2f426b678e025f6181287b08ea995ed + last_write_checksum: sha1:806eecfbfbd9862cf0fb64efad4b401f93c78e3e + pristine_git_object: b634472cdb3fe62a8422bdd27d30a770bdf652a2 src/openrouter/analytics.py: id: cb406b5aaabb last_write_checksum: sha1:9e709b71dd0611056dc0cec6150b578defe32841 @@ -6726,8 +6730,8 @@ trackedFiles: pristine_git_object: ad3d247954547814054c01989a2dff3d12b3e4e1 src/openrouter/components/__init__.py: id: 81754e97b3f4 - last_write_checksum: sha1:045cf74eb4e03399ac8521ff3db0a2ed9f33b002 - pristine_git_object: 43900430f099cab065756d44e23f9c4118c99180 + last_write_checksum: sha1:5208f1af2c3420c74d0a23810dcf68807b95a130 + pristine_git_object: 92d0e11add040db79f1848e7f697605a0b2e129c src/openrouter/components/aabenchmarkentry.py: id: e2e0f0b48c82 last_write_checksum: sha1:fab4d9a24d2cea937bb749d46c5f83941e99d65c @@ -8344,6 +8348,10 @@ trackedFiles: id: 40414eada27a last_write_checksum: sha1:0e241830bf9014e8ea814465c573711d8a7caa2c pristine_git_object: 90bdb267893360608210843a5da0d5d68e80d41e + src/openrouter/components/pricingoverride.py: + id: 8984e4cc7422 + last_write_checksum: sha1:0e2c06a0d510bb2fcf64b03f74c693f26c9825ad + pristine_git_object: 21c25933126937fe7c1d10898a42bbe711cf7b9f src/openrouter/components/promptcachebreakpoint.py: id: f1e589a13300 last_write_checksum: sha1:458ef5170c7c9ea1367dcfb090b1b28333aff73d @@ -8386,12 +8394,12 @@ trackedFiles: pristine_git_object: 1798ae9dd8c2e4b629bb99cc5c643827895e8231 src/openrouter/components/publicendpoint.py: id: 848aa2ef9129 - last_write_checksum: sha1:d8788cb95c89974e6339ecaccc6202dfae871225 - pristine_git_object: 270a46db728bbf80ab3c89fde25d71c61f93434e + last_write_checksum: sha1:a94a8a30e3656955780285fa004a2b7e5d162c57 + pristine_git_object: b647b5f88242565b228e6d0bf11d151e6650f6f8 src/openrouter/components/publicpricing.py: id: 96d115d83cc5 - last_write_checksum: sha1:41f834b27573c1f621c99883d27e231a1384c846 - pristine_git_object: fc3f2cdb028345dbeda1c0a6a1493647286f1cc9 + last_write_checksum: sha1:a3733ee6d92eda73562ea1fa2bc834e3a14ac6db + pristine_git_object: 037f4b4e9aa72510a4021e695fe39516eb88d1f3 src/openrouter/components/quantization.py: id: bde317b3d703 last_write_checksum: sha1:96b042899bfb818f20d282be76ad37fc948a599d @@ -11131,4 +11139,9 @@ examples: examplesVersion: 1.0.2 releaseNotes: | ## Python SDK Changes: - * `open_router.images.generate()`: `request.provider` **Changed** + * `open_router.embeddings.list_models()`: `response.data[].pricing.overrides` **Added** + * `open_router.endpoints.list_zdr_endpoints()`: `response.data[].pricing.overrides` **Added** + * `open_router.endpoints.list()`: `response.data.endpoints[].pricing.overrides` **Added** + * `open_router.models.get()`: `response.data.pricing.overrides` **Added** + * `open_router.models.list()`: `response.data[].pricing.overrides` **Added** + * `open_router.models.list_for_user()`: `response.data[].pricing.overrides` **Added** diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 46c1783..465bed5 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -36,7 +36,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 0.11.25 + version: 0.11.26 additionalDependencies: dev: {} main: {} diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index e340148..dd88871 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -18289,6 +18289,41 @@ components: required: - type type: object + PricingOverride: + description: >- + A conditional override of the base pricing. An entry applies only when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per price key; price keys absent from an entry inherit the base price. + example: + completion: '0.00002' + min_prompt_tokens: 200000 + prompt: '0.000005' + properties: + audio: + description: Overridden price in USD per audio input token + type: string + completion: + description: Overridden price in USD per token for completion (output) generation + type: string + input_audio_cache: + description: Overridden price in USD per cached audio input token + type: string + input_cache_read: + description: Overridden price in USD per cached input token (read) + type: string + input_cache_write: + description: Overridden price in USD per cache-write token + type: string + input_cache_write_1h: + description: Overridden price in USD per 1-hour cache-write token + type: string + min_prompt_tokens: + description: >- + Condition: the entry applies when the total prompt tokens of a request are strictly greater than this threshold + format: double + type: number + prompt: + description: Overridden price in USD per token for prompt (input) processing + type: string + type: object PromptCacheBreakpoint: description: >- Marks an explicit prompt-cache boundary on this content block. Everything through the block carrying this marker is part of the candidate cached prefix. Only supported by OpenAI GPT-5.6 and newer. @@ -19397,6 +19432,12 @@ components: internal_reasoning: description: Price in USD per internal reasoning token type: string + overrides: + description: >- + Conditional overrides of the base pricing (e.g. long-context pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions. + items: + $ref: '#/components/schemas/PricingOverride' + type: array prompt: description: Price in USD per token for prompt (input) processing type: string @@ -19514,6 +19555,12 @@ components: internal_reasoning: description: Price in USD per internal reasoning token type: string + overrides: + description: >- + Conditional overrides of the base pricing (e.g. long-context pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions. + items: + $ref: '#/components/schemas/PricingOverride' + type: array prompt: description: Price in USD per token for prompt (input) processing type: string diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 650819f..a710c77 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:c4b604e524d65fc80cad85d0620c391b70d087ed384bbb1ed03166267524ec3d - sourceBlobDigest: sha256:59fc42341a3b4ae0f2344e88df306b70fb85b526e84e1c274c006afb7d99153b + sourceRevisionDigest: sha256:9f8353c6af76d729784ad0e73d4c232043cf6f308a01acd3975ec748a1751559 + sourceBlobDigest: sha256:d2e958ad60806d999cd37686274fff162f0dd4e52954a1edb49f19e037eeda6e tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:c4b604e524d65fc80cad85d0620c391b70d087ed384bbb1ed03166267524ec3d - sourceBlobDigest: sha256:59fc42341a3b4ae0f2344e88df306b70fb85b526e84e1c274c006afb7d99153b + sourceRevisionDigest: sha256:9f8353c6af76d729784ad0e73d4c232043cf6f308a01acd3975ec748a1751559 + sourceBlobDigest: sha256:d2e958ad60806d999cd37686274fff162f0dd4e52954a1edb49f19e037eeda6e codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:b959c03fc95af18ab71b3e8edc54d3a74d06d0a3f0d786576f3ab1a1c049cdd0 + codeSamplesRevisionDigest: sha256:f68472bc77963d676f750b164b9991d49fc9b394fb05f7aba9907616cdaa54b1 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/RELEASES.md b/RELEASES.md index ab81e86..630044f 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -358,4 +358,14 @@ Based on: ### Generated - [python v0.11.25] . ### Releases -- [PyPI v0.11.25] https://pypi.org/project/openrouter/0.11.25 - . \ No newline at end of file +- [PyPI v0.11.25] https://pypi.org/project/openrouter/0.11.25 - . + +## 2026-07-13 19:27:34 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.11.26] . +### Releases +- [PyPI v0.11.26] https://pypi.org/project/openrouter/0.11.26 - . \ No newline at end of file diff --git a/docs/components/pricing.mdx b/docs/components/pricing.mdx index 78ac34b..0ca9bdf 100644 --- a/docs/components/pricing.mdx +++ b/docs/components/pricing.mdx @@ -4,20 +4,21 @@ title: "Pricing" ## Fields -| Field | Type | Required | Description | -| --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `audio` | *Optional[str]* | :heavy_minus_sign: | Price in USD per audio input token | -| `audio_output` | *Optional[str]* | :heavy_minus_sign: | Price in USD per audio output token | -| `completion` | *str* | :heavy_check_mark: | Price in USD per token for completion (output) generation | -| `discount` | *Optional[float]* | :heavy_minus_sign: | Fractional discount applied to this endpoint's pricing; the price is multiplied by (1 - discount) (0 = no discount, 1 = free) | -| `image` | *Optional[str]* | :heavy_minus_sign: | Price in USD per input image | -| `image_output` | *Optional[str]* | :heavy_minus_sign: | Price in USD per output image | -| `image_token` | *Optional[str]* | :heavy_minus_sign: | Price in USD per image token | -| `input_audio_cache` | *Optional[str]* | :heavy_minus_sign: | Price in USD per cached audio input token | -| `input_cache_read` | *Optional[str]* | :heavy_minus_sign: | Price in USD per cached input token (read) | -| `input_cache_write` | *Optional[str]* | :heavy_minus_sign: | Price per cache-write token, in USD per token. For providers with multiple cache TTLs (e.g. Anthropic), this is the default (5-minute) cache-write rate. | -| `input_cache_write_1h` | *Optional[str]* | :heavy_minus_sign: | Price per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic. | -| `internal_reasoning` | *Optional[str]* | :heavy_minus_sign: | Price in USD per internal reasoning token | -| `prompt` | *str* | :heavy_check_mark: | Price in USD per token for prompt (input) processing | -| `request` | *Optional[str]* | :heavy_minus_sign: | Price in USD per request | -| `web_search` | *Optional[str]* | :heavy_minus_sign: | Price in USD per web search | \ No newline at end of file +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `audio` | *Optional[str]* | :heavy_minus_sign: | Price in USD per audio input token | +| `audio_output` | *Optional[str]* | :heavy_minus_sign: | Price in USD per audio output token | +| `completion` | *str* | :heavy_check_mark: | Price in USD per token for completion (output) generation | +| `discount` | *Optional[float]* | :heavy_minus_sign: | Fractional discount applied to this endpoint's pricing; the price is multiplied by (1 - discount) (0 = no discount, 1 = free) | +| `image` | *Optional[str]* | :heavy_minus_sign: | Price in USD per input image | +| `image_output` | *Optional[str]* | :heavy_minus_sign: | Price in USD per output image | +| `image_token` | *Optional[str]* | :heavy_minus_sign: | Price in USD per image token | +| `input_audio_cache` | *Optional[str]* | :heavy_minus_sign: | Price in USD per cached audio input token | +| `input_cache_read` | *Optional[str]* | :heavy_minus_sign: | Price in USD per cached input token (read) | +| `input_cache_write` | *Optional[str]* | :heavy_minus_sign: | Price per cache-write token, in USD per token. For providers with multiple cache TTLs (e.g. Anthropic), this is the default (5-minute) cache-write rate. | +| `input_cache_write_1h` | *Optional[str]* | :heavy_minus_sign: | Price per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic. | +| `internal_reasoning` | *Optional[str]* | :heavy_minus_sign: | Price in USD per internal reasoning token | +| `overrides` | List[[components.PricingOverride](../components/pricingoverride.mdx)] | :heavy_minus_sign: | Conditional overrides of the base pricing (e.g. long-context pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions. | +| `prompt` | *str* | :heavy_check_mark: | Price in USD per token for prompt (input) processing | +| `request` | *Optional[str]* | :heavy_minus_sign: | Price in USD per request | +| `web_search` | *Optional[str]* | :heavy_minus_sign: | Price in USD per web search | \ No newline at end of file diff --git a/docs/components/pricingoverride.mdx b/docs/components/pricingoverride.mdx new file mode 100644 index 0000000..f829125 --- /dev/null +++ b/docs/components/pricingoverride.mdx @@ -0,0 +1,19 @@ +--- +title: "PricingOverride" +--- + +A conditional override of the base pricing. An entry applies only when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per price key; price keys absent from an entry inherit the base price. + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | +| `audio` | *Optional[str]* | :heavy_minus_sign: | Overridden price in USD per audio input token | +| `completion` | *Optional[str]* | :heavy_minus_sign: | Overridden price in USD per token for completion (output) generation | +| `input_audio_cache` | *Optional[str]* | :heavy_minus_sign: | Overridden price in USD per cached audio input token | +| `input_cache_read` | *Optional[str]* | :heavy_minus_sign: | Overridden price in USD per cached input token (read) | +| `input_cache_write` | *Optional[str]* | :heavy_minus_sign: | Overridden price in USD per cache-write token | +| `input_cache_write_1h` | *Optional[str]* | :heavy_minus_sign: | Overridden price in USD per 1-hour cache-write token | +| `min_prompt_tokens` | *Optional[float]* | :heavy_minus_sign: | Condition: the entry applies when the total prompt tokens of a request are strictly greater than this threshold | +| `prompt` | *Optional[str]* | :heavy_minus_sign: | Overridden price in USD per token for prompt (input) processing | \ No newline at end of file diff --git a/docs/components/publicpricing.mdx b/docs/components/publicpricing.mdx index 0d8f6cf..4a17b2b 100644 --- a/docs/components/publicpricing.mdx +++ b/docs/components/publicpricing.mdx @@ -7,20 +7,21 @@ Pricing information for the model ## Fields -| Field | Type | Required | Description | -| --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `audio` | *Optional[str]* | :heavy_minus_sign: | Price in USD per audio input token | -| `audio_output` | *Optional[str]* | :heavy_minus_sign: | Price in USD per audio output token | -| `completion` | *str* | :heavy_check_mark: | Price in USD per token for completion (output) generation | -| `discount` | *Optional[float]* | :heavy_minus_sign: | Fractional discount applied to this endpoint's pricing; the price is multiplied by (1 - discount) (0 = no discount, 1 = free) | -| `image` | *Optional[str]* | :heavy_minus_sign: | Price in USD per input image | -| `image_output` | *Optional[str]* | :heavy_minus_sign: | Price in USD per output image | -| `image_token` | *Optional[str]* | :heavy_minus_sign: | Price in USD per image token | -| `input_audio_cache` | *Optional[str]* | :heavy_minus_sign: | Price in USD per cached audio input token | -| `input_cache_read` | *Optional[str]* | :heavy_minus_sign: | Price in USD per cached input token (read) | -| `input_cache_write` | *Optional[str]* | :heavy_minus_sign: | Price per cache-write token, in USD per token. For providers with multiple cache TTLs (e.g. Anthropic), this is the default (5-minute) cache-write rate. | -| `input_cache_write_1h` | *Optional[str]* | :heavy_minus_sign: | Price per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic. | -| `internal_reasoning` | *Optional[str]* | :heavy_minus_sign: | Price in USD per internal reasoning token | -| `prompt` | *str* | :heavy_check_mark: | Price in USD per token for prompt (input) processing | -| `request` | *Optional[str]* | :heavy_minus_sign: | Price in USD per request | -| `web_search` | *Optional[str]* | :heavy_minus_sign: | Price in USD per web search | \ No newline at end of file +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `audio` | *Optional[str]* | :heavy_minus_sign: | Price in USD per audio input token | +| `audio_output` | *Optional[str]* | :heavy_minus_sign: | Price in USD per audio output token | +| `completion` | *str* | :heavy_check_mark: | Price in USD per token for completion (output) generation | +| `discount` | *Optional[float]* | :heavy_minus_sign: | Fractional discount applied to this endpoint's pricing; the price is multiplied by (1 - discount) (0 = no discount, 1 = free) | +| `image` | *Optional[str]* | :heavy_minus_sign: | Price in USD per input image | +| `image_output` | *Optional[str]* | :heavy_minus_sign: | Price in USD per output image | +| `image_token` | *Optional[str]* | :heavy_minus_sign: | Price in USD per image token | +| `input_audio_cache` | *Optional[str]* | :heavy_minus_sign: | Price in USD per cached audio input token | +| `input_cache_read` | *Optional[str]* | :heavy_minus_sign: | Price in USD per cached input token (read) | +| `input_cache_write` | *Optional[str]* | :heavy_minus_sign: | Price per cache-write token, in USD per token. For providers with multiple cache TTLs (e.g. Anthropic), this is the default (5-minute) cache-write rate. | +| `input_cache_write_1h` | *Optional[str]* | :heavy_minus_sign: | Price per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic. | +| `internal_reasoning` | *Optional[str]* | :heavy_minus_sign: | Price in USD per internal reasoning token | +| `overrides` | List[[components.PricingOverride](../components/pricingoverride.mdx)] | :heavy_minus_sign: | Conditional overrides of the base pricing (e.g. long-context pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions. | +| `prompt` | *str* | :heavy_check_mark: | Price in USD per token for prompt (input) processing | +| `request` | *Optional[str]* | :heavy_minus_sign: | Price in USD per request | +| `web_search` | *Optional[str]* | :heavy_minus_sign: | Price in USD per web search | \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 6804383..bcd7637 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "0.11.25" +version = "0.11.26" 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 d272f6c..b634472 100644 --- a/src/openrouter/_version.py +++ b/src/openrouter/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "openrouter" -__version__: str = "0.11.25" +__version__: str = "0.11.26" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.914.0" -__user_agent__: str = "speakeasy-sdk/python 0.11.25 2.914.0 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 0.11.26 2.914.0 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/components/__init__.py b/src/openrouter/components/__init__.py index 4390043..92d0e11 100644 --- a/src/openrouter/components/__init__.py +++ b/src/openrouter/components/__init__.py @@ -2203,6 +2203,7 @@ PreviewWebSearchUserLocationType, PreviewWebSearchUserLocationTypedDict, ) + from .pricingoverride import PricingOverride, PricingOverrideTypedDict from .promptcachebreakpoint import ( PromptCacheBreakpoint, PromptCacheBreakpointMode, @@ -4346,6 +4347,8 @@ "PreviewWebSearchUserLocationTypedDict", "PriceSource", "Pricing", + "PricingOverride", + "PricingOverrideTypedDict", "PricingTypedDict", "PromptCacheBreakpoint", "PromptCacheBreakpointMode", @@ -6542,6 +6545,8 @@ "PreviewWebSearchUserLocation": ".preview_websearchuserlocation", "PreviewWebSearchUserLocationType": ".preview_websearchuserlocation", "PreviewWebSearchUserLocationTypedDict": ".preview_websearchuserlocation", + "PricingOverride": ".pricingoverride", + "PricingOverrideTypedDict": ".pricingoverride", "PromptCacheBreakpoint": ".promptcachebreakpoint", "PromptCacheBreakpointMode": ".promptcachebreakpoint", "PromptCacheBreakpointTypedDict": ".promptcachebreakpoint", diff --git a/src/openrouter/components/pricingoverride.py b/src/openrouter/components/pricingoverride.py new file mode 100644 index 0000000..21c2593 --- /dev/null +++ b/src/openrouter/components/pricingoverride.py @@ -0,0 +1,83 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel, UNSET_SENTINEL +from pydantic import model_serializer +from typing import Optional +from typing_extensions import NotRequired, TypedDict + + +class PricingOverrideTypedDict(TypedDict): + r"""A conditional override of the base pricing. An entry applies only when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per price key; price keys absent from an entry inherit the base price.""" + + audio: NotRequired[str] + r"""Overridden price in USD per audio input token""" + completion: NotRequired[str] + r"""Overridden price in USD per token for completion (output) generation""" + input_audio_cache: NotRequired[str] + r"""Overridden price in USD per cached audio input token""" + input_cache_read: NotRequired[str] + r"""Overridden price in USD per cached input token (read)""" + input_cache_write: NotRequired[str] + r"""Overridden price in USD per cache-write token""" + input_cache_write_1h: NotRequired[str] + r"""Overridden price in USD per 1-hour cache-write token""" + min_prompt_tokens: NotRequired[float] + r"""Condition: the entry applies when the total prompt tokens of a request are strictly greater than this threshold""" + prompt: NotRequired[str] + r"""Overridden price in USD per token for prompt (input) processing""" + + +class PricingOverride(BaseModel): + r"""A conditional override of the base pricing. An entry applies only when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per price key; price keys absent from an entry inherit the base price.""" + + audio: Optional[str] = None + r"""Overridden price in USD per audio input token""" + + completion: Optional[str] = None + r"""Overridden price in USD per token for completion (output) generation""" + + input_audio_cache: Optional[str] = None + r"""Overridden price in USD per cached audio input token""" + + input_cache_read: Optional[str] = None + r"""Overridden price in USD per cached input token (read)""" + + input_cache_write: Optional[str] = None + r"""Overridden price in USD per cache-write token""" + + input_cache_write_1h: Optional[str] = None + r"""Overridden price in USD per 1-hour cache-write token""" + + min_prompt_tokens: Optional[float] = None + r"""Condition: the entry applies when the total prompt tokens of a request are strictly greater than this threshold""" + + prompt: Optional[str] = None + r"""Overridden price in USD per token for prompt (input) processing""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + [ + "audio", + "completion", + "input_audio_cache", + "input_cache_read", + "input_cache_write", + "input_cache_write_1h", + "min_prompt_tokens", + "prompt", + ] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/components/publicendpoint.py b/src/openrouter/components/publicendpoint.py index 270a46d..b647b5f 100644 --- a/src/openrouter/components/publicendpoint.py +++ b/src/openrouter/components/publicendpoint.py @@ -4,6 +4,7 @@ from .endpointstatus import EndpointStatus from .parameter import Parameter from .percentilestats import PercentileStats, PercentileStatsTypedDict +from .pricingoverride import PricingOverride, PricingOverrideTypedDict from .providername import ProviderName from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr from pydantic import model_serializer @@ -38,6 +39,8 @@ class PricingTypedDict(TypedDict): r"""Price per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic.""" internal_reasoning: NotRequired[str] r"""Price in USD per internal reasoning token""" + overrides: NotRequired[List[PricingOverrideTypedDict]] + r"""Conditional overrides of the base pricing (e.g. long-context pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions.""" request: NotRequired[str] r"""Price in USD per request""" web_search: NotRequired[str] @@ -84,6 +87,9 @@ class Pricing(BaseModel): internal_reasoning: Optional[str] = None r"""Price in USD per internal reasoning token""" + overrides: Optional[List[PricingOverride]] = None + r"""Conditional overrides of the base pricing (e.g. long-context pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions.""" + request: Optional[str] = None r"""Price in USD per request""" @@ -105,6 +111,7 @@ def serialize_model(self, handler): "input_cache_write", "input_cache_write_1h", "internal_reasoning", + "overrides", "request", "web_search", ] diff --git a/src/openrouter/components/publicpricing.py b/src/openrouter/components/publicpricing.py index fc3f2cd..037f4b4 100644 --- a/src/openrouter/components/publicpricing.py +++ b/src/openrouter/components/publicpricing.py @@ -1,9 +1,10 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations +from .pricingoverride import PricingOverride, PricingOverrideTypedDict from openrouter.types import BaseModel, UNSET_SENTINEL from pydantic import model_serializer -from typing import Optional +from typing import List, Optional from typing_extensions import NotRequired, TypedDict @@ -36,6 +37,8 @@ class PublicPricingTypedDict(TypedDict): r"""Price per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic.""" internal_reasoning: NotRequired[str] r"""Price in USD per internal reasoning token""" + overrides: NotRequired[List[PricingOverrideTypedDict]] + r"""Conditional overrides of the base pricing (e.g. long-context pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions.""" request: NotRequired[str] r"""Price in USD per request""" web_search: NotRequired[str] @@ -84,6 +87,9 @@ class PublicPricing(BaseModel): internal_reasoning: Optional[str] = None r"""Price in USD per internal reasoning token""" + overrides: Optional[List[PricingOverride]] = None + r"""Conditional overrides of the base pricing (e.g. long-context pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions.""" + request: Optional[str] = None r"""Price in USD per request""" @@ -105,6 +111,7 @@ def serialize_model(self, handler): "input_cache_write", "input_cache_write_1h", "internal_reasoning", + "overrides", "request", "web_search", ] diff --git a/uv.lock b/uv.lock index 07279f2..948a29c 100644 --- a/uv.lock +++ b/uv.lock @@ -213,7 +213,7 @@ wheels = [ [[package]] name = "openrouter" -version = "0.11.25" +version = "0.11.26" source = { editable = "." } dependencies = [ { name = "httpcore" },