diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 1ade19bc1..018409721 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: 4d82e0bb28f8a6282dc30c8a4d83fca8 + docChecksum: 24bcc1c62d441e4d0bad468fe794bbe9 docVersion: 1.0.0 speakeasyVersion: 1.803.2 generationVersion: 2.950.13 - releaseVersion: 1.3.210 - configChecksum: f42f0088c32d2e902f3ea5cb772c09b3 + releaseVersion: 1.3.211 + configChecksum: 1d03c87037f0a61053584f4f1898d35f repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: 743616bd-d6bf-4c14-b9f8-7cfb67a1565e - pristine_commit_hash: 95e89e40d286461c627183111cc68fac71ced02b - pristine_tree_hash: 928468581347d154ebedc08fa47d5c1f558e0ec5 + generation_id: 776f0be6-18d0-4185-84c5-bf1b105d0ec7 + pristine_commit_hash: aa8ac54fca166dc10eff9de5be098cff7bb91bfa + pristine_tree_hash: bf19082dac7ae1ab6958d8625ed2e5b869b818e4 features: python: acceptHeaders: 3.0.0 @@ -7806,14 +7806,18 @@ trackedFiles: id: 3c69e8a7ccae last_write_checksum: sha1:6740787193a5ef2ca33b52109b388e3dfc61367e pristine_git_object: 7a781ae1ba333185a5fd94840aa26f84c2ac39f8 + docs/components/responsescontextmanagement.mdx: + id: 275482e81655 + last_write_checksum: sha1:b367e7b36270d251654bcfecd680bef346800bb8 + pristine_git_object: 32daf0711c10bc3bf8b5d25b2a0dd4935627188d docs/components/responsesinputtransformation.mdx: id: 77d67090691f last_write_checksum: sha1:70581e8d3b562237781babfef4c11c0983cfdda1 pristine_git_object: 5b83a005ce4c1dc70e6fa5984a83aa5bb5ce137e docs/components/responsesrequest.mdx: id: 0dbcef40a4b1 - last_write_checksum: sha1:5e2b69aa6866361fc1f9d1269bc85565af5fd3c2 - pristine_git_object: fba888a27d05a32874bedb6aaecbee22c19b9719 + last_write_checksum: sha1:be69eb30b010dadbef9b63230f396904ea367054 + pristine_git_object: 792ff894c62f518c5a2937f36b41ccdf915e6901 docs/components/responsesrequestaccessprograms.mdx: id: 5601238f0623 last_write_checksum: sha1:50c603ddf87595ee886e479ca39ee53aa4e6cf2b @@ -11728,8 +11732,8 @@ trackedFiles: pristine_git_object: cf7205ab21da2ead20d7e8ef594ccb0273b4c661 docs/sdks/betaresponses/README.mdx: id: 8a1e987c9840 - last_write_checksum: sha1:b6c877d4e4d77e6ea6ce093fbb4964b18e87fa48 - pristine_git_object: 9874b1be23d8dbf7fd2d2d913a5900ec717a2323 + last_write_checksum: sha1:ef45d7265c5a9cdf578567609ac76ef6538751cc + pristine_git_object: d9bc52fd3531312c1f9ee9ac58c82a36680b755a docs/sdks/byok/README.mdx: id: 17792f3b180d last_write_checksum: sha1:013102fa63e566eb650d3ab4151acd825f50bfb2 @@ -11812,8 +11816,8 @@ trackedFiles: pristine_git_object: 4762825df814e75d1f9c2c4067444270f4ec7b60 docs/sdks/presets/README.mdx: id: eeb505928d52 - last_write_checksum: sha1:45197a0baafd43d668d1b713eb1e17733282ea61 - pristine_git_object: bbae48172a2146cb8b3cef449501f0c009665f07 + last_write_checksum: sha1:ab5df86c3835d98f1152600d54841ac1ae45176c + pristine_git_object: 28c3e51a827054eb167e08eebd47ba6a3fd75f6b docs/sdks/privateendpoints/README.mdx: id: 54dee70b8cc7 last_write_checksum: sha1:2d1c2df07e7e74be533180cd856d939ad3fadba1 @@ -11832,8 +11836,8 @@ trackedFiles: pristine_git_object: 4e10c25ed694e617695e7fc6192b7b25302977d6 docs/sdks/responses/README.mdx: id: abab319e080e - last_write_checksum: sha1:05f69bace042c46e06427268f8579cf2096531ae - pristine_git_object: 65eb984d913d1196f223e1c2f8004891d1a53058 + last_write_checksum: sha1:86214a254fdc8dd80bef8cfca43bc0aaa369213a + pristine_git_object: 2713692f889d5d3fb5450060a18cdb28334ff745 docs/sdks/scim/README.mdx: id: fd6d8a91a053 last_write_checksum: sha1:b8fa2f34e39af30ae7fe4c4fc497d943bf57cae9 @@ -11872,8 +11876,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:8758f7b0b8afbdd36cd73c11a5c7752584fdad5b - pristine_git_object: 486641f0f09463a0e8ea06a1cb3fee6c03aa5030 + last_write_checksum: sha1:1de4ba02787035c67ff109539c32f06ad7e57432 + pristine_git_object: 19c1b1d51210c68a60fc1d53158ff3edc28e08b8 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -11900,8 +11904,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:853450c8ee202d21c299b5ddd7206f94e063856f - pristine_git_object: ebb29394c03857ec869024de232aa6c03feeaff4 + last_write_checksum: sha1:76aebfe8c5f05ec3ccebdde61c335b33160a9176 + pristine_git_object: ca833f10879206d1cc99014af06651fb0e48e593 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:80cc0f39649445431cc2247ed0e0765438467766 @@ -11932,8 +11936,8 @@ trackedFiles: pristine_git_object: aa95a65cf560fd7edb0c3c6f5fed707ca5015da3 src/openrouter/beta_responses.py: id: 001eaf848bf1 - last_write_checksum: sha1:aeb93517b3625f0de7f2f7d4303d9e923baad5b1 - pristine_git_object: 098495886511368599e696e6b5c4e86330b68ace + last_write_checksum: sha1:f6bea681c9783614484f4847ad94db8616263917 + pristine_git_object: b1a66598a16867cd7eda5df8ad4dfcc9f713006b src/openrouter/byok.py: id: bec352462ae1 last_write_checksum: sha1:b5d11e3667ec0ebf4a9eae261e32f804e55c9b85 @@ -11948,8 +11952,8 @@ trackedFiles: pristine_git_object: ad3d247954547814054c01989a2dff3d12b3e4e1 src/openrouter/components/__init__.py: id: 81754e97b3f4 - last_write_checksum: sha1:375acc709be3b3cb9d9f08464f9c5d2470e1ad9a - pristine_git_object: ac86ae50aade2f12c070b0f42bfaa13d4bd2fdcc + last_write_checksum: sha1:ab8db2549669891efccac529b1a1b4afde2d5115 + pristine_git_object: 3506483d96019516b205c361ad456293e7538af7 src/openrouter/components/aabenchmarkentry.py: id: e2e0f0b48c82 last_write_checksum: sha1:08125e1d60df82793e11e8aed6e3c9fdb7512ebb @@ -15102,14 +15106,18 @@ trackedFiles: id: 076f3c78aa58 last_write_checksum: sha1:c1f1208da12840aafa9c6f24d355862808e91e80 pristine_git_object: e3f4b083aca1fd072ef8655b14160b20b9b36105 + src/openrouter/components/responsescontextmanagement.py: + id: f31200b61263 + last_write_checksum: sha1:f60f7d19dc77dd38972bb02f4614f25a7031b197 + pristine_git_object: 85cdeab0288364be9f0ee96a953a87b5c2955494 src/openrouter/components/responsesinputtransformation.py: id: 9eaec7caea55 last_write_checksum: sha1:b98ef6372b2a7adfb3e6c5b2f32657833f8fff97 pristine_git_object: 4ce1bb3d5b4c7b38de27fb2f567dfefb4d997287 src/openrouter/components/responsesrequest.py: id: 8c850080ec5d - last_write_checksum: sha1:9d83b013b38cb11f441fd47c479290762910d303 - pristine_git_object: 1a99218bcd70834945b1857c2a0fe6a04da8d076 + last_write_checksum: sha1:3cbd930b8cfc913ab211c1ec1c450f1e9d50b2e7 + pristine_git_object: 6d62245631fe3601f186dbffc95075bb83562873 src/openrouter/components/responsesstreamingresponse.py: id: 142379f3bd90 last_write_checksum: sha1:a48d6f3610f5d15248ef4d25a0d88a0a4a1a9db7 @@ -16752,8 +16760,8 @@ trackedFiles: pristine_git_object: 228602282f43dd94fb7703bb47b45a570c1aa8d2 src/openrouter/presets.py: id: bd0c40379dcd - last_write_checksum: sha1:e43c29c2767a41140255cc9c3b18946ad6fb3831 - pristine_git_object: c40ca7d9e8bc5a3c89f76da4b2eb8c7b6f4d17e1 + last_write_checksum: sha1:8004285306daf7d986bcaeb9fa1037de509d6091 + pristine_git_object: 936058d4adcb7ce049c186bd93a938d7891e1b33 src/openrouter/private_endpoints.py: id: fdbce8846ed0 last_write_checksum: sha1:9ad3004604d7760fb231594fe29b42fb2bd74f87 @@ -16776,8 +16784,8 @@ trackedFiles: pristine_git_object: 9db3cc719bd343ee7be0183d0c87b50c29e5eb31 src/openrouter/responses.py: id: f2108fb635e1 - last_write_checksum: sha1:73d3705cb6a5e35e621e1541d2a89eaf2041d1e1 - pristine_git_object: 6583a0b59f3ede8c72897bb922c1f85de280e8e0 + last_write_checksum: sha1:7691816affedec657f1c8ef4055cfb6ad7a2bf68 + pristine_git_object: 9657171612cd81ca38c0dcdec14b49eb9adbb5f9 src/openrouter/scim.py: id: 351afd6b616e last_write_checksum: sha1:8d1dfe362ca7c5ab91c3a46e7cdf1ac16f4207fb @@ -22029,4 +22037,4 @@ examples: examplesVersion: 1.0.2 releaseNotes: | ## Python SDK Changes: - * `open_router.tts.create_speech()`: `request.output_delivery` **Added** + * `open_router.presets.create_presets_responses()`: `request.context_management` **Added** diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index e25b86880..09d763888 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.210 + version: 1.3.211 additionalDependencies: dev: pytest: '>=8.3' diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index e948906bf..76bc4a1de 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -33071,6 +33071,26 @@ components: - 'code' - 'message' type: 'object' + ResponsesContextManagement: + additionalProperties: {} + description: 'A server-side context management entry. With `compaction`, the provider compacts the conversation once input exceeds `compact_threshold` and returns a `compaction` output item; pass that item back in `input` on later turns.' + example: + compact_threshold: 200000 + type: 'compaction' + properties: + compact_threshold: + description: 'Input token count at which server-side compaction is triggered.' + example: 200000 + type: + - 'integer' + - 'null' + type: + description: 'The context management strategy. Currently only `compaction` is supported.' + example: 'compaction' + type: 'string' + required: + - 'type' + type: 'object' ResponsesErrorField: description: 'Error information returned from the API' example: @@ -33174,6 +33194,16 @@ components: - 'null' cache_control: $ref: '#/components/schemas/AnthropicCacheControlDirective' + context_management: + description: 'Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns.' + example: + - compact_threshold: 200000 + type: 'compaction' + items: + $ref: '#/components/schemas/ResponsesContextManagement' + type: + - 'array' + - 'null' debug: $ref: '#/components/schemas/ChatDebugOptions' deferred_tools: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index a99dff4ce..78807cf2b 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.803.2 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:ba90c495baff410bced3e769d29fd3956b00bd839027405dcad0628e383b7784 - sourceBlobDigest: sha256:b9088d65dab80454ae36699aeaa1191ee708097b84fc930fe5bb01da5f17b468 + sourceRevisionDigest: sha256:0ffb38c715c97b308afbdc76670c0a3e53c8558b7eecefb1682998a30b46d4f0 + sourceBlobDigest: sha256:4f19dac2c49b3f8a6c219dd305e8c1d6a0d995b7ee4b9b48b00c9d61b7e6e36a tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:ba90c495baff410bced3e769d29fd3956b00bd839027405dcad0628e383b7784 - sourceBlobDigest: sha256:b9088d65dab80454ae36699aeaa1191ee708097b84fc930fe5bb01da5f17b468 + sourceRevisionDigest: sha256:0ffb38c715c97b308afbdc76670c0a3e53c8558b7eecefb1682998a30b46d4f0 + sourceBlobDigest: sha256:4f19dac2c49b3f8a6c219dd305e8c1d6a0d995b7ee4b9b48b00c9d61b7e6e36a codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:a9ebf8b0ee0a7ae394735eed466c3ff5e30ee12f3123c59a5ed5375dfab2f09b + codeSamplesRevisionDigest: sha256:3433ed086fb16115dc0641cd720be47758f4a10056094a920587f7c552876a13 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.803.2 diff --git a/RELEASES.md b/RELEASES.md index 8d275cff6..e0699c78a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4869,4 +4869,14 @@ Based on: ### Generated - [python v1.3.210] . ### Releases -- [PyPI v1.3.210] https://pypi.org/project/openrouter/1.3.210 - . \ No newline at end of file +- [PyPI v1.3.210] https://pypi.org/project/openrouter/1.3.210 - . + +## 2026-11-24 16:25:03 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.803.2 (2.950.13) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.211] . +### Releases +- [PyPI v1.3.211] https://pypi.org/project/openrouter/1.3.211 - . \ No newline at end of file diff --git a/docs/components/responsescontextmanagement.mdx b/docs/components/responsescontextmanagement.mdx new file mode 100644 index 000000000..32daf0711 --- /dev/null +++ b/docs/components/responsescontextmanagement.mdx @@ -0,0 +1,14 @@ +--- +title: "ResponsesContextManagement" +--- + +A server-side context management entry. With `compaction`, the provider compacts the conversation once input exceeds `compact_threshold` and returns a `compaction` output item; pass that item back in `input` on later turns. + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `compact_threshold` | *OptionalNullable[int]* | ➖ | Input token count at which server-side compaction is triggered. | 200000 | +| `type` | *str* | ✔️ | The context management strategy. Currently only `compaction` is supported. | compaction | +| `__pydantic_extra__` | Dict[str, *Any*] | ➖ | N/A | \{
"compact_threshold": 200000,
"type": "compaction"
} | \ No newline at end of file diff --git a/docs/components/responsesrequest.mdx b/docs/components/responsesrequest.mdx index fba888a27..792ff894c 100644 --- a/docs/components/responsesrequest.mdx +++ b/docs/components/responsesrequest.mdx @@ -12,6 +12,7 @@ Request schema for Responses endpoint | `access_programs` | [Optional[components.ResponsesRequestAccessPrograms]](../components/responsesrequestaccessprograms.mdx) | ➖ | OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. | \{
"cyber": "standard"
} | | `background` | *OptionalNullable[bool]* | ➖ | N/A | | | `cache_control` | [Optional[components.AnthropicCacheControlDirective]](../components/anthropiccachecontroldirective.mdx) | ➖ | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. | \{
"type": "ephemeral"
} | +| `context_management` | List[[components.ResponsesContextManagement](../components/responsescontextmanagement.mdx)] | ➖ | Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. | [
\{
"compact_threshold": 200000,
"type": "compaction"
}
] | | `debug` | [Optional[components.ChatDebugOptions]](../components/chatdebugoptions.mdx) | ➖ | Debug options for inspecting request transformations (streaming only) | \{
"echo_upstream_body": true
} | | `deferred_tools` | [Optional[components.DeferredToolsControl]](../components/deferredtoolscontrol.mdx) | ➖ | Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. | \{
"profile": "portable",
"protocol": "v1",
"search": \{
"max_results": 5,
"type": "bm25"
},
"validation": "runtime"
} | | `frequency_penalty` | *OptionalNullable[float]* | ➖ | N/A | | diff --git a/docs/sdks/betaresponses/README.mdx b/docs/sdks/betaresponses/README.mdx index 9874b1be2..d9bc52fd3 100644 --- a/docs/sdks/betaresponses/README.mdx +++ b/docs/sdks/betaresponses/README.mdx @@ -115,6 +115,7 @@ with OpenRouter( | `access_programs` | [Optional[components.ResponsesRequestAccessPrograms]](../../components/responsesrequestaccessprograms.mdx) | ➖ | OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. | \{
"cyber": "standard"
} | | `background` | *OptionalNullable[bool]* | ➖ | N/A | | | `cache_control` | [Optional[components.AnthropicCacheControlDirective]](../../components/anthropiccachecontroldirective.mdx) | ➖ | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. | \{
"type": "ephemeral"
} | +| `context_management` | List[[components.ResponsesContextManagement](../../components/responsescontextmanagement.mdx)] | ➖ | Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. | [
\{
"compact_threshold": 200000,
"type": "compaction"
}
] | | `debug` | [Optional[components.ChatDebugOptions]](../../components/chatdebugoptions.mdx) | ➖ | Debug options for inspecting request transformations (streaming only) | \{
"echo_upstream_body": true
} | | `deferred_tools` | [Optional[components.DeferredToolsControl]](../../components/deferredtoolscontrol.mdx) | ➖ | Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. | \{
"profile": "portable",
"protocol": "v1",
"search": \{
"max_results": 5,
"type": "bm25"
},
"validation": "runtime"
} | | `frequency_penalty` | *OptionalNullable[float]* | ➖ | N/A | | diff --git a/docs/sdks/presets/README.mdx b/docs/sdks/presets/README.mdx index bbae48172..28c3e51a8 100644 --- a/docs/sdks/presets/README.mdx +++ b/docs/sdks/presets/README.mdx @@ -403,6 +403,7 @@ with OpenRouter( | `access_programs` | [Optional[components.ResponsesRequestAccessPrograms]](../../components/responsesrequestaccessprograms.mdx) | ➖ | OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. | \{
"cyber": "standard"
} | | `background` | *OptionalNullable[bool]* | ➖ | N/A | | | `cache_control` | [Optional[components.AnthropicCacheControlDirective]](../../components/anthropiccachecontroldirective.mdx) | ➖ | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. | \{
"type": "ephemeral"
} | +| `context_management` | List[[components.ResponsesContextManagement](../../components/responsescontextmanagement.mdx)] | ➖ | Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. | [
\{
"compact_threshold": 200000,
"type": "compaction"
}
] | | `debug` | [Optional[components.ChatDebugOptions]](../../components/chatdebugoptions.mdx) | ➖ | Debug options for inspecting request transformations (streaming only) | \{
"echo_upstream_body": true
} | | `deferred_tools` | [Optional[components.DeferredToolsControl]](../../components/deferredtoolscontrol.mdx) | ➖ | Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. | \{
"profile": "portable",
"protocol": "v1",
"search": \{
"max_results": 5,
"type": "bm25"
},
"validation": "runtime"
} | | `frequency_penalty` | *OptionalNullable[float]* | ➖ | N/A | | diff --git a/docs/sdks/responses/README.mdx b/docs/sdks/responses/README.mdx index 65eb984d9..2713692f8 100644 --- a/docs/sdks/responses/README.mdx +++ b/docs/sdks/responses/README.mdx @@ -115,6 +115,7 @@ with OpenRouter( | `access_programs` | [Optional[components.ResponsesRequestAccessPrograms]](../../components/responsesrequestaccessprograms.mdx) | ➖ | OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. | \{
"cyber": "standard"
} | | `background` | *OptionalNullable[bool]* | ➖ | N/A | | | `cache_control` | [Optional[components.AnthropicCacheControlDirective]](../../components/anthropiccachecontroldirective.mdx) | ➖ | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. | \{
"type": "ephemeral"
} | +| `context_management` | List[[components.ResponsesContextManagement](../../components/responsescontextmanagement.mdx)] | ➖ | Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. | [
\{
"compact_threshold": 200000,
"type": "compaction"
}
] | | `debug` | [Optional[components.ChatDebugOptions]](../../components/chatdebugoptions.mdx) | ➖ | Debug options for inspecting request transformations (streaming only) | \{
"echo_upstream_body": true
} | | `deferred_tools` | [Optional[components.DeferredToolsControl]](../../components/deferredtoolscontrol.mdx) | ➖ | Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. | \{
"profile": "portable",
"protocol": "v1",
"search": \{
"max_results": 5,
"type": "bm25"
},
"validation": "runtime"
} | | `frequency_penalty` | *OptionalNullable[float]* | ➖ | N/A | | diff --git a/pyproject.toml b/pyproject.toml index 486641f0f..19c1b1d51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.210" +version = "1.3.211" 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 ebb29394c..ca833f108 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.210" +__version__: str = "1.3.211" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.950.13" -__user_agent__: str = "speakeasy-sdk/python 1.3.210 2.950.13 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.211 2.950.13 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/beta_responses.py b/src/openrouter/beta_responses.py index 098495886..b1a66598a 100644 --- a/src/openrouter/beta_responses.py +++ b/src/openrouter/beta_responses.py @@ -43,6 +43,12 @@ def send( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -157,6 +163,7 @@ def send( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -222,6 +229,12 @@ def send( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -336,6 +349,7 @@ def send( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -401,6 +415,12 @@ def send( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -518,6 +538,7 @@ def send( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -582,6 +603,12 @@ def send( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -699,6 +726,7 @@ def send( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -765,6 +793,10 @@ def send( cache_control=utils.get_pydantic_model( cache_control, Optional[components.AnthropicCacheControlDirective] ), + context_management=utils.get_pydantic_model( + context_management, + OptionalNullable[List[components.ResponsesContextManagement]], + ), debug=utils.get_pydantic_model( debug, Optional[components.ChatDebugOptions] ), @@ -1057,6 +1089,12 @@ async def send_async( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -1171,6 +1209,7 @@ async def send_async( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -1236,6 +1275,12 @@ async def send_async( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -1350,6 +1395,7 @@ async def send_async( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -1415,6 +1461,12 @@ async def send_async( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -1532,6 +1584,7 @@ async def send_async( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -1596,6 +1649,12 @@ async def send_async( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -1713,6 +1772,7 @@ async def send_async( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -1779,6 +1839,10 @@ async def send_async( cache_control=utils.get_pydantic_model( cache_control, Optional[components.AnthropicCacheControlDirective] ), + context_management=utils.get_pydantic_model( + context_management, + OptionalNullable[List[components.ResponsesContextManagement]], + ), debug=utils.get_pydantic_model( debug, Optional[components.ChatDebugOptions] ), diff --git a/src/openrouter/components/__init__.py b/src/openrouter/components/__init__.py index ac86ae50a..3506483d9 100644 --- a/src/openrouter/components/__init__.py +++ b/src/openrouter/components/__init__.py @@ -4363,6 +4363,10 @@ ResponsesBadRequestResponseErrorData, ResponsesBadRequestResponseErrorDataTypedDict, ) + from .responsescontextmanagement import ( + ResponsesContextManagement, + ResponsesContextManagementTypedDict, + ) from .responsesinputtransformation import ( ResponsesInputTransformation, ResponsesInputTransformationTypedDict, @@ -8281,6 +8285,8 @@ "ResponseOutputTextTypedDict", "ResponsesBadRequestResponseErrorData", "ResponsesBadRequestResponseErrorDataTypedDict", + "ResponsesContextManagement", + "ResponsesContextManagementTypedDict", "ResponsesInputTransformation", "ResponsesInputTransformationTypedDict", "ResponsesRequest", @@ -12230,6 +12236,8 @@ "CodeTypedDict": ".responsesbadrequestresponseerrordata", "ResponsesBadRequestResponseErrorData": ".responsesbadrequestresponseerrordata", "ResponsesBadRequestResponseErrorDataTypedDict": ".responsesbadrequestresponseerrordata", + "ResponsesContextManagement": ".responsescontextmanagement", + "ResponsesContextManagementTypedDict": ".responsescontextmanagement", "ResponsesInputTransformation": ".responsesinputtransformation", "ResponsesInputTransformationTypedDict": ".responsesinputtransformation", "ReasoningConfig": ".responsesrequest", diff --git a/src/openrouter/components/responsescontextmanagement.py b/src/openrouter/components/responsescontextmanagement.py new file mode 100644 index 000000000..85cdeab02 --- /dev/null +++ b/src/openrouter/components/responsescontextmanagement.py @@ -0,0 +1,74 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +import pydantic +from pydantic import ConfigDict, model_serializer +from typing import Any, Dict +from typing_extensions import NotRequired, TypedDict + + +class ResponsesContextManagementTypedDict(TypedDict): + r"""A server-side context management entry. With `compaction`, the provider compacts the conversation once input exceeds `compact_threshold` and returns a `compaction` output item; pass that item back in `input` on later turns.""" + + type: str + r"""The context management strategy. Currently only `compaction` is supported.""" + compact_threshold: NotRequired[Nullable[int]] + r"""Input token count at which server-side compaction is triggered.""" + + +class ResponsesContextManagement(BaseModel): + r"""A server-side context management entry. With `compaction`, the provider compacts the conversation once input exceeds `compact_threshold` and returns a `compaction` output item; pass that item back in `input` on later turns.""" + + model_config = ConfigDict( + populate_by_name=True, arbitrary_types_allowed=True, extra="allow" + ) + __pydantic_extra__: Dict[str, Any] = pydantic.Field(init=False) + + type: str + r"""The context management strategy. Currently only `compaction` is supported.""" + + compact_threshold: OptionalNullable[int] = UNSET + r"""Input token count at which server-side compaction is triggered.""" + + @property + def additional_properties(self): + return self.__pydantic_extra__ + + @additional_properties.setter + def additional_properties(self, value): + self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride] + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["compact_threshold"]) + nullable_fields = set(["compact_threshold"]) + 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)) + serialized.pop(k, serialized.pop(n, None)) + is_nullable_and_explicitly_set = ( + k in nullable_fields + and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member + ) + + if val != UNSET_SENTINEL: + if ( + val is not None + or k not in optional_fields + or is_nullable_and_explicitly_set + ): + m[k] = val + for k, v in serialized.items(): + m[k] = v + + return m diff --git a/src/openrouter/components/responsesrequest.py b/src/openrouter/components/responsesrequest.py index 1a99218bc..6d6224563 100644 --- a/src/openrouter/components/responsesrequest.py +++ b/src/openrouter/components/responsesrequest.py @@ -86,6 +86,10 @@ from .reasoningsummaryverbosity import ReasoningSummaryVerbosity from .responsehealingplugin import ResponseHealingPlugin, ResponseHealingPluginTypedDict from .responseincludesenum import ResponseIncludesEnum +from .responsescontextmanagement import ( + ResponsesContextManagement, + ResponsesContextManagementTypedDict, +) from .searchmodelsservertool_openrouter import ( SearchModelsServerToolOpenRouter, SearchModelsServerToolOpenRouterTypedDict, @@ -471,6 +475,8 @@ class ResponsesRequestTypedDict(TypedDict): background: NotRequired[Nullable[bool]] cache_control: NotRequired[AnthropicCacheControlDirectiveTypedDict] r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format.""" + context_management: NotRequired[Nullable[List[ResponsesContextManagementTypedDict]]] + r"""Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns.""" debug: NotRequired[ChatDebugOptionsTypedDict] r"""Debug options for inspecting request transformations (streaming only)""" deferred_tools: NotRequired[DeferredToolsControlTypedDict] @@ -543,6 +549,9 @@ class ResponsesRequest(BaseModel): cache_control: Optional[AnthropicCacheControlDirective] = None r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format.""" + context_management: OptionalNullable[List[ResponsesContextManagement]] = UNSET + r"""Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns.""" + debug: Optional[ChatDebugOptions] = None r"""Debug options for inspecting request transformations (streaming only)""" @@ -651,6 +660,7 @@ def serialize_model(self, handler): "access_programs", "background", "cache_control", + "context_management", "debug", "deferred_tools", "frequency_penalty", @@ -695,6 +705,7 @@ def serialize_model(self, handler): nullable_fields = set( [ "background", + "context_management", "frequency_penalty", "include", "instructions", diff --git a/src/openrouter/presets.py b/src/openrouter/presets.py index c40ca7d9e..936058d4a 100644 --- a/src/openrouter/presets.py +++ b/src/openrouter/presets.py @@ -2433,6 +2433,12 @@ def create_presets_responses( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -2550,6 +2556,7 @@ def create_presets_responses( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -2617,6 +2624,10 @@ def create_presets_responses( cache_control=utils.get_pydantic_model( cache_control, Optional[components.AnthropicCacheControlDirective] ), + context_management=utils.get_pydantic_model( + context_management, + OptionalNullable[List[components.ResponsesContextManagement]], + ), debug=utils.get_pydantic_model( debug, Optional[components.ChatDebugOptions] ), @@ -2818,6 +2829,12 @@ async def create_presets_responses_async( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -2935,6 +2952,7 @@ async def create_presets_responses_async( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -3002,6 +3020,10 @@ async def create_presets_responses_async( cache_control=utils.get_pydantic_model( cache_control, Optional[components.AnthropicCacheControlDirective] ), + context_management=utils.get_pydantic_model( + context_management, + OptionalNullable[List[components.ResponsesContextManagement]], + ), debug=utils.get_pydantic_model( debug, Optional[components.ChatDebugOptions] ), diff --git a/src/openrouter/responses.py b/src/openrouter/responses.py index 6583a0b59..965717161 100644 --- a/src/openrouter/responses.py +++ b/src/openrouter/responses.py @@ -43,6 +43,12 @@ def send( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -157,6 +163,7 @@ def send( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -222,6 +229,12 @@ def send( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -336,6 +349,7 @@ def send( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -401,6 +415,12 @@ def send( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -518,6 +538,7 @@ def send( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -582,6 +603,12 @@ def send( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -699,6 +726,7 @@ def send( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -765,6 +793,10 @@ def send( cache_control=utils.get_pydantic_model( cache_control, Optional[components.AnthropicCacheControlDirective] ), + context_management=utils.get_pydantic_model( + context_management, + OptionalNullable[List[components.ResponsesContextManagement]], + ), debug=utils.get_pydantic_model( debug, Optional[components.ChatDebugOptions] ), @@ -1057,6 +1089,12 @@ async def send_async( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -1171,6 +1209,7 @@ async def send_async( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -1236,6 +1275,12 @@ async def send_async( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -1350,6 +1395,7 @@ async def send_async( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -1415,6 +1461,12 @@ async def send_async( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -1532,6 +1584,7 @@ async def send_async( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -1596,6 +1649,12 @@ async def send_async( components.AnthropicCacheControlDirectiveTypedDict, ] ] = None, + context_management: OptionalNullable[ + Union[ + Iterable[components.ResponsesContextManagement], + Iterable[components.ResponsesContextManagementTypedDict], + ] + ] = UNSET, debug: Optional[ Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict] ] = None, @@ -1713,6 +1772,7 @@ async def send_async( :param access_programs: OpenAI access programs for this request. `cyber` selects the Cyber access program: `standard`, `daybreak_blue`, or `daybreak_red`. A program other than `standard` is supported only on BYOK requests that run on your own OpenAI key enrolled in that program; any other endpoint, including OpenRouter's own OpenAI credentials, rejects it with a 400 error. Requests on OpenRouter's OpenAI credentials always run `standard`. Omit the field unless your key is enrolled in a Daybreak program. :param background: :param cache_control: Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + :param context_management: Server-side context management (compaction). Supported for OpenAI models served by OpenAI or Azure, which return `compaction` output items. Providers translated to another API format drop it. Replay returned `compaction` items in `input` on later turns. :param debug: Debug options for inspecting request transformations (streaming only) :param deferred_tools: Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. :param frequency_penalty: @@ -1779,6 +1839,10 @@ async def send_async( cache_control=utils.get_pydantic_model( cache_control, Optional[components.AnthropicCacheControlDirective] ), + context_management=utils.get_pydantic_model( + context_management, + OptionalNullable[List[components.ResponsesContextManagement]], + ), debug=utils.get_pydantic_model( debug, Optional[components.ChatDebugOptions] ), diff --git a/uv.lock b/uv.lock index f038ecbfb..d57765f94 100644 --- a/uv.lock +++ b/uv.lock @@ -231,7 +231,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.210" +version = "1.3.211" source = { editable = "." } dependencies = [ { name = "httpcore" },