diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index c07bef74..0fbeb559 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: 4e6e233fd4bd81eb1457720250167048 + docChecksum: 51317d2756ce999339fd2d538c1db6be docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 1.1.128 - configChecksum: 659b58f40aa3a5a62924f0ea281890e4 + releaseVersion: 1.1.129 + configChecksum: 8d293c073227241bd7c2a45858e9fca8 repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: c0c5fc1c-b80c-4670-b4e7-8e51d018632e - pristine_commit_hash: 61f2510e8a6efdd8ed1d90a7dd5d6ccf98809299 - pristine_tree_hash: db81211734187c8d5f86f5d6a71207d68da131c1 + generation_id: e59c67e2-c33b-4b95-89e5-9e15cff5be39 + pristine_commit_hash: f9ec0ed017057f7913142675293362b6a2634014 + pristine_tree_hash: b091f1520f1d0d33c606b09a2c09dd53099204b1 features: python: acceptHeaders: 3.0.0 @@ -966,8 +966,12 @@ trackedFiles: pristine_git_object: eee9489fd2c3f15a7cc6525688a5b0cd12839e10 docs/components/chatdevelopermessage.mdx: id: 36556ee902ee - last_write_checksum: sha1:3ad4e33a7aa81ff3174df9bc4416a706dfa2221b - pristine_git_object: 05d422366ab8123f4488df014cc733df83366adf + last_write_checksum: sha1:ea18be20bcb2210f450165c0791725485bfaa924 + pristine_git_object: 3db8a03b39f47e61b924319f2aeb2cbec522d7ea + docs/components/chatdevelopermessageconfigurationupdate.mdx: + id: d9f8b151accf + last_write_checksum: sha1:fd0f3db2afacb6414e356244691b3408d9dd3282 + pristine_git_object: f4dfd91b7aad64da9fe2196b3e1dc341b6757f01 docs/components/chatdevelopermessagecontent.mdx: id: 0f36d5e7c6ff last_write_checksum: sha1:fe6c792d0d0f647b8894543c23df0d59a34f3c54 @@ -1154,8 +1158,12 @@ trackedFiles: pristine_git_object: 602231cf40fe0c66347bd13dd158bd75741c0759 docs/components/chatsystemmessage.mdx: id: fd74aa853b84 - last_write_checksum: sha1:05d7836f4113a8d872c73bcf67d510f2bf3aa788 - pristine_git_object: d6912ab69f634bc043cebb4b2d68ff57d1dbfce9 + last_write_checksum: sha1:b09948ed9a49c74cef962b379da78d3b71b86efb + pristine_git_object: d904f59d23eac44202b78b5a722bf8de0f0c7de6 + docs/components/chatsystemmessageconfigurationupdate.mdx: + id: f1296b6e2ca4 + last_write_checksum: sha1:9b6d014e6fda8b399db9265c856bf108a57921e7 + pristine_git_object: 31dd268a4edfa81004b2f81c576d0164acd81623 docs/components/chatsystemmessagecontent.mdx: id: a26e029e8e60 last_write_checksum: sha1:475985246731f53936fe0e0b4d6557c54f201ed1 @@ -1364,10 +1372,6 @@ trackedFiles: id: e4aadaca19bc last_write_checksum: sha1:d7024f63ad66f7701809f41907d35f4b08e21c2b pristine_git_object: 37199a7b510c1e9fcb61566fb1ca2dc3d6a5428b - docs/components/configurationupdate.mdx: - id: c5bb9102459b - last_write_checksum: sha1:31bbeedc9f90e2e2f60048d8b0d93389b0518709 - pristine_git_object: 33b78a13beb924d8fa0efdf6fe1cfe5e369aff3f docs/components/configurationupdateitem.mdx: id: c118c80819dc last_write_checksum: sha1:3a492618aab7f070429ce0b06d27ef33814c3fd1 @@ -7650,8 +7654,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:6f5f6c0a068a39167fabc6dc73f6ec65c9423dd1 - pristine_git_object: f8d669d161a383787e29f10cd90e98c12ebf664d + last_write_checksum: sha1:66b44b692d06091eb187caa6e31059c198395fe4 + pristine_git_object: 92be9eccaf1845a1a8a82ae10d59e590b833833c scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -7678,8 +7682,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:c1cc25629f7765963fa89fa24aa2d82f2a749926 - pristine_git_object: 611d81426fb720a86447fdfb37cd0f391bdb24e7 + last_write_checksum: sha1:1a83901600daf488fb6535c60e0727a4d3b31384 + pristine_git_object: 2b55e384f9439dc2dbcb574f150d0e7501396b88 src/openrouter/analytics.py: id: cb406b5aaabb last_write_checksum: sha1:1e0004d8d1d5d797e2b54cd1cabeb7f9489d08e9 @@ -7718,8 +7722,8 @@ trackedFiles: pristine_git_object: ad3d247954547814054c01989a2dff3d12b3e4e1 src/openrouter/components/__init__.py: id: 81754e97b3f4 - last_write_checksum: sha1:95c4495d8c046a9fc18dd1bf84be26231d589fab - pristine_git_object: 7e1f6f57e52a3c6defb09d972362c67b326b6225 + last_write_checksum: sha1:fb2fb93ccd5b1789d5e2fe360732d2544f25066a + pristine_git_object: 99b7ee07700944ac33248a340355e6fd73ed54ea src/openrouter/components/aabenchmarkentry.py: id: e2e0f0b48c82 last_write_checksum: sha1:fab4d9a24d2cea937bb749d46c5f83941e99d65c @@ -8154,8 +8158,8 @@ trackedFiles: pristine_git_object: 309df1015b07e05ad2d692ed73ef1224535e8582 src/openrouter/components/chatdevelopermessage.py: id: bcba94e8d19a - last_write_checksum: sha1:2b4737de643f073848fc04d15a53d55f9dec9855 - pristine_git_object: 56dcbb97ee27d5cbb79616e6d039bee74b8d2e47 + last_write_checksum: sha1:f45ebe02bdd4169102a49a3365f1067d9f936d8d + pristine_git_object: 59d993da3b8e9d67cd9d9378a189f9a27b9b79dd src/openrouter/components/chatfinishreasonenum.py: id: "331394791883" last_write_checksum: sha1:98f6b15af15986f5b3e9ac60c29bf9e5a70eeb5f @@ -8190,8 +8194,8 @@ trackedFiles: pristine_git_object: b3953ee5aec2abda9ca0db2e9e4e010b29a22392 src/openrouter/components/chatmessages.py: id: 3425ec393ea1 - last_write_checksum: sha1:5841b1d1a3528442d04663e46e925fcab23ea2bd - pristine_git_object: 0bfc0241736533dcf58da34fc415fecf88a2f2cf + last_write_checksum: sha1:c3b7a82748d710c88feb6d36b6697cf3b44ee238 + pristine_git_object: 737cec3d47f6125ae5a2ef600273c8b07bde4409 src/openrouter/components/chatnamedtoolchoice.py: id: 8dec655ada92 last_write_checksum: sha1:282eb40a8c8f08d41f7559bed7e34ed631a79741 @@ -8242,8 +8246,8 @@ trackedFiles: pristine_git_object: 936fefc210c5b6b9e94ea708035b085b59aed2f4 src/openrouter/components/chatsystemmessage.py: id: 72524b9ccaed - last_write_checksum: sha1:2af21833061cb19fb72a6ea3e0fbbe692da202da - pristine_git_object: b2675c61793a010b9ff5d9eb70fdb86bab26b041 + last_write_checksum: sha1:110e3e706bba5d21b4722ec9b13f8024aff1470e + pristine_git_object: 61a1b8eb15b56f372562c0a8f923a9a082e11957 src/openrouter/components/chattokenlogprob.py: id: 6ddf9cf44f5a last_write_checksum: sha1:75641fdaddc42fea10d46e9974c051f3393ff94c @@ -12886,3 +12890,4 @@ examples: "500": application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 +releaseNotes: "## Python SDK Changes:\n* `open_router.chat.send()`: \n * `request.messages[].union(developer).configuration_update` **Added**\n* `open_router.presets.create_presets_chat_completions()`: \n * `request.messages[].union(developer).configuration_update` **Added**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 7bdf7652..c49cd0df 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -36,7 +36,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.1.128 + version: 1.1.129 additionalDependencies: dev: {} main: {} diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 0d218c78..d551e908 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -5078,6 +5078,20 @@ components: content: 'This is a message from the developer.' role: 'developer' properties: + configuration_update: + additionalProperties: false + description: 'OpenRouter extension. Same as the system message `configuration_update`: changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns.' + example: + reasoning: + effort: 'low' + properties: + reasoning: + $ref: '#/components/schemas/ConfigurationUpdateReasoning' + required: + - 'reasoning' + type: + - 'object' + - 'null' content: anyOf: - type: 'string' diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index ac2462d1..065c9b62 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:d06ad82cf1f51f6f70dd5a83315258678fd7e3b1784b9cb760820ed39b03d939 - sourceBlobDigest: sha256:89c69de82a6ae94c2f7431d4cd056dff20a851765efbeabac62bc24be07048fb + sourceRevisionDigest: sha256:9db5e05ed4848a20fd8987cee486fcdfe1acd368d310f639da6037ce96d69d59 + sourceBlobDigest: sha256:f1762809ed137577f30a052de14e0956d80b24e83aed70decaeb33b2a3807d35 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:d06ad82cf1f51f6f70dd5a83315258678fd7e3b1784b9cb760820ed39b03d939 - sourceBlobDigest: sha256:89c69de82a6ae94c2f7431d4cd056dff20a851765efbeabac62bc24be07048fb + sourceRevisionDigest: sha256:9db5e05ed4848a20fd8987cee486fcdfe1acd368d310f639da6037ce96d69d59 + sourceBlobDigest: sha256:f1762809ed137577f30a052de14e0956d80b24e83aed70decaeb33b2a3807d35 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:414cb983021c9d1c65cfb46d8816966e1bd7e8a300e01c791be0cec7667a626d + codeSamplesRevisionDigest: sha256:3e8664557224a8582118d35af373f2d58378188425b2cc6dddf7f249d2645087 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/RELEASES.md b/RELEASES.md index 08186d78..ba70ca3a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2069,4 +2069,14 @@ Based on: ### Generated - [python v1.1.128] . ### Releases -- [PyPI v1.1.128] https://pypi.org/project/openrouter/1.1.128 - . \ No newline at end of file +- [PyPI v1.1.128] https://pypi.org/project/openrouter/1.1.128 - . + +## 2026-09-08 15:29:20 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.1.129] . +### Releases +- [PyPI v1.1.129] https://pypi.org/project/openrouter/1.1.129 - . \ No newline at end of file diff --git a/docs/components/chatdevelopermessage.mdx b/docs/components/chatdevelopermessage.mdx index 05d42236..3db8a03b 100644 --- a/docs/components/chatdevelopermessage.mdx +++ b/docs/components/chatdevelopermessage.mdx @@ -7,8 +7,9 @@ Developer message ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -| `content` | [components.ChatDeveloperMessageContent](../components/chatdevelopermessagecontent.mdx) | :heavy_check_mark: | Developer message content | This is a message from the developer. | -| `name` | *Optional[str]* | :heavy_minus_sign: | Optional name for the developer message | Developer | -| `role` | [components.ChatDeveloperMessageRole](../components/chatdevelopermessagerole.mdx) | :heavy_check_mark: | N/A | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `configuration_update` | [OptionalNullable[components.ChatDeveloperMessageConfigurationUpdate]](../components/chatdevelopermessageconfigurationupdate.mdx) | :heavy_minus_sign: | OpenRouter extension. Same as the system message `configuration_update`: changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns. | \{
"reasoning": \{
"effort": "low"
}
} | +| `content` | [components.ChatDeveloperMessageContent](../components/chatdevelopermessagecontent.mdx) | :heavy_check_mark: | Developer message content | This is a message from the developer. | +| `name` | *Optional[str]* | :heavy_minus_sign: | Optional name for the developer message | Developer | +| `role` | [components.ChatDeveloperMessageRole](../components/chatdevelopermessagerole.mdx) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/docs/components/chatdevelopermessageconfigurationupdate.mdx b/docs/components/chatdevelopermessageconfigurationupdate.mdx new file mode 100644 index 00000000..f4dfd91b --- /dev/null +++ b/docs/components/chatdevelopermessageconfigurationupdate.mdx @@ -0,0 +1,12 @@ +--- +title: "ChatDeveloperMessageConfigurationUpdate" +--- + +OpenRouter extension. Same as the system message `configuration_update`: changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns. + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `reasoning` | [components.ConfigurationUpdateReasoning](../components/configurationupdatereasoning.mdx) | :heavy_check_mark: | Reasoning settings applied from this point in the conversation onward | \{
"effort": "low"
} | \ No newline at end of file diff --git a/docs/components/chatsystemmessage.mdx b/docs/components/chatsystemmessage.mdx index d6912ab6..d904f59d 100644 --- a/docs/components/chatsystemmessage.mdx +++ b/docs/components/chatsystemmessage.mdx @@ -9,7 +9,7 @@ System message for setting behavior | Field | Type | Required | Description | Example | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `configuration_update` | [OptionalNullable[components.ConfigurationUpdate]](../components/configurationupdate.mdx) | :heavy_minus_sign: | OpenRouter extension. Changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns. Place it on a content-less system message (`content: ""`) directly before the user message it should apply to, and keep it at that position in later requests. Equivalent to the OpenAI Responses `configuration_update` input item and the Anthropic Messages per-message `output_config.effort`. | \{
"reasoning": \{
"effort": "low"
}
} | +| `configuration_update` | [OptionalNullable[components.ChatSystemMessageConfigurationUpdate]](../components/chatsystemmessageconfigurationupdate.mdx) | :heavy_minus_sign: | OpenRouter extension. Changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns. Place it on a content-less system message (`content: ""`) directly before the user message it should apply to, and keep it at that position in later requests. Equivalent to the OpenAI Responses `configuration_update` input item and the Anthropic Messages per-message `output_config.effort`. | \{
"reasoning": \{
"effort": "low"
}
} | | `content` | [components.ChatSystemMessageContent](../components/chatsystemmessagecontent.mdx) | :heavy_check_mark: | System message content | You are a helpful assistant. | | `name` | *Optional[str]* | :heavy_minus_sign: | Optional name for the system message | Assistant Config | | `role` | [components.ChatSystemMessageRole](../components/chatsystemmessagerole.mdx) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/docs/components/configurationupdate.mdx b/docs/components/chatsystemmessageconfigurationupdate.mdx similarity index 97% rename from docs/components/configurationupdate.mdx rename to docs/components/chatsystemmessageconfigurationupdate.mdx index 33b78a13..31dd268a 100644 --- a/docs/components/configurationupdate.mdx +++ b/docs/components/chatsystemmessageconfigurationupdate.mdx @@ -1,5 +1,5 @@ --- -title: "ConfigurationUpdate" +title: "ChatSystemMessageConfigurationUpdate" --- OpenRouter extension. Changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns. Place it on a content-less system message (`content: ""`) directly before the user message it should apply to, and keep it at that position in later requests. Equivalent to the OpenAI Responses `configuration_update` input item and the Anthropic Messages per-message `output_config.effort`. diff --git a/pyproject.toml b/pyproject.toml index f8d669d1..92be9ecc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.1.128" +version = "1.1.129" 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 611d8142..2b55e384 100644 --- a/src/openrouter/_version.py +++ b/src/openrouter/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "openrouter" -__version__: str = "1.1.128" +__version__: str = "1.1.129" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.914.0" -__user_agent__: str = "speakeasy-sdk/python 1.1.128 2.914.0 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.1.129 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 7e1f6f57..99b7ee07 100644 --- a/src/openrouter/components/__init__.py +++ b/src/openrouter/components/__init__.py @@ -510,6 +510,8 @@ from .chatdebugoptions import ChatDebugOptions, ChatDebugOptionsTypedDict from .chatdevelopermessage import ( ChatDeveloperMessage, + ChatDeveloperMessageConfigurationUpdate, + ChatDeveloperMessageConfigurationUpdateTypedDict, ChatDeveloperMessageContent, ChatDeveloperMessageContentTypedDict, ChatDeveloperMessageRole, @@ -618,12 +620,12 @@ ) from .chatsystemmessage import ( ChatSystemMessage, + ChatSystemMessageConfigurationUpdate, + ChatSystemMessageConfigurationUpdateTypedDict, ChatSystemMessageContent, ChatSystemMessageContentTypedDict, ChatSystemMessageRole, ChatSystemMessageTypedDict, - ConfigurationUpdate, - ConfigurationUpdateTypedDict, ) from .chattokenlogprob import ( ChatTokenLogprob, @@ -3615,6 +3617,8 @@ "ChatDebugOptions", "ChatDebugOptionsTypedDict", "ChatDeveloperMessage", + "ChatDeveloperMessageConfigurationUpdate", + "ChatDeveloperMessageConfigurationUpdateTypedDict", "ChatDeveloperMessageContent", "ChatDeveloperMessageContentTypedDict", "ChatDeveloperMessageRole", @@ -3691,6 +3695,8 @@ "ChatStreamingResponse", "ChatStreamingResponseTypedDict", "ChatSystemMessage", + "ChatSystemMessageConfigurationUpdate", + "ChatSystemMessageConfigurationUpdateTypedDict", "ChatSystemMessageContent", "ChatSystemMessageContentTypedDict", "ChatSystemMessageRole", @@ -3774,14 +3780,12 @@ "ComputerUseServerTool", "ComputerUseServerToolType", "ComputerUseServerToolTypedDict", - "ConfigurationUpdate", "ConfigurationUpdateItem", "ConfigurationUpdateItemType", "ConfigurationUpdateItemTypedDict", "ConfigurationUpdateReasoning", "ConfigurationUpdateReasoningEffort", "ConfigurationUpdateReasoningTypedDict", - "ConfigurationUpdateTypedDict", "ConflictResponseErrorData", "ConflictResponseErrorDataTypedDict", "ConnectorID", @@ -5992,6 +5996,8 @@ "ChatDebugOptions": ".chatdebugoptions", "ChatDebugOptionsTypedDict": ".chatdebugoptions", "ChatDeveloperMessage": ".chatdevelopermessage", + "ChatDeveloperMessageConfigurationUpdate": ".chatdevelopermessage", + "ChatDeveloperMessageConfigurationUpdateTypedDict": ".chatdevelopermessage", "ChatDeveloperMessageContent": ".chatdevelopermessage", "ChatDeveloperMessageContentTypedDict": ".chatdevelopermessage", "ChatDeveloperMessageRole": ".chatdevelopermessage", @@ -6073,12 +6079,12 @@ "ChatStreamToolCallType": ".chatstreamtoolcall", "ChatStreamToolCallTypedDict": ".chatstreamtoolcall", "ChatSystemMessage": ".chatsystemmessage", + "ChatSystemMessageConfigurationUpdate": ".chatsystemmessage", + "ChatSystemMessageConfigurationUpdateTypedDict": ".chatsystemmessage", "ChatSystemMessageContent": ".chatsystemmessage", "ChatSystemMessageContentTypedDict": ".chatsystemmessage", "ChatSystemMessageRole": ".chatsystemmessage", "ChatSystemMessageTypedDict": ".chatsystemmessage", - "ConfigurationUpdate": ".chatsystemmessage", - "ConfigurationUpdateTypedDict": ".chatsystemmessage", "ChatTokenLogprob": ".chattokenlogprob", "ChatTokenLogprobTopLogprob": ".chattokenlogprob", "ChatTokenLogprobTopLogprobTypedDict": ".chattokenlogprob", diff --git a/src/openrouter/components/chatdevelopermessage.py b/src/openrouter/components/chatdevelopermessage.py index 56dcbb97..59d993da 100644 --- a/src/openrouter/components/chatdevelopermessage.py +++ b/src/openrouter/components/chatdevelopermessage.py @@ -2,12 +2,36 @@ from __future__ import annotations from .chatcontenttext import ChatContentText, ChatContentTextTypedDict -from openrouter.types import BaseModel, UNSET_SENTINEL +from .configurationupdatereasoning import ( + ConfigurationUpdateReasoning, + ConfigurationUpdateReasoningTypedDict, +) +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) from pydantic import model_serializer from typing import List, Literal, Optional, Union from typing_extensions import NotRequired, TypeAliasType, TypedDict +class ChatDeveloperMessageConfigurationUpdateTypedDict(TypedDict): + r"""OpenRouter extension. Same as the system message `configuration_update`: changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns.""" + + reasoning: ConfigurationUpdateReasoningTypedDict + r"""Reasoning settings applied from this point in the conversation onward""" + + +class ChatDeveloperMessageConfigurationUpdate(BaseModel): + r"""OpenRouter extension. Same as the system message `configuration_update`: changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns.""" + + reasoning: ConfigurationUpdateReasoning + r"""Reasoning settings applied from this point in the conversation onward""" + + ChatDeveloperMessageContentTypedDict = TypeAliasType( "ChatDeveloperMessageContentTypedDict", Union[str, List[ChatContentTextTypedDict]] ) @@ -29,6 +53,10 @@ class ChatDeveloperMessageTypedDict(TypedDict): content: ChatDeveloperMessageContentTypedDict r"""Developer message content""" role: ChatDeveloperMessageRole + configuration_update: NotRequired[ + Nullable[ChatDeveloperMessageConfigurationUpdateTypedDict] + ] + r"""OpenRouter extension. Same as the system message `configuration_update`: changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns.""" name: NotRequired[str] r"""Optional name for the developer message""" @@ -41,21 +69,35 @@ class ChatDeveloperMessage(BaseModel): role: ChatDeveloperMessageRole + configuration_update: OptionalNullable[ChatDeveloperMessageConfigurationUpdate] = ( + UNSET + ) + r"""OpenRouter extension. Same as the system message `configuration_update`: changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns.""" + name: Optional[str] = None r"""Optional name for the developer message""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["name"]) + optional_fields = set(["configuration_update", "name"]) + nullable_fields = set(["configuration_update"]) 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)) + 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: + if ( + val is not None + or k not in optional_fields + or is_nullable_and_explicitly_set + ): m[k] = val return m diff --git a/src/openrouter/components/chatmessages.py b/src/openrouter/components/chatmessages.py index 0bfc0241..737cec3d 100644 --- a/src/openrouter/components/chatmessages.py +++ b/src/openrouter/components/chatmessages.py @@ -16,9 +16,9 @@ "ChatMessagesTypedDict", Union[ ChatUserMessageTypedDict, - ChatDeveloperMessageTypedDict, ChatToolMessageTypedDict, ChatSystemMessageTypedDict, + ChatDeveloperMessageTypedDict, ChatAssistantMessageTypedDict, ], ) diff --git a/src/openrouter/components/chatsystemmessage.py b/src/openrouter/components/chatsystemmessage.py index b2675c61..61a1b8eb 100644 --- a/src/openrouter/components/chatsystemmessage.py +++ b/src/openrouter/components/chatsystemmessage.py @@ -18,14 +18,14 @@ from typing_extensions import NotRequired, TypeAliasType, TypedDict -class ConfigurationUpdateTypedDict(TypedDict): +class ChatSystemMessageConfigurationUpdateTypedDict(TypedDict): r"""OpenRouter extension. Changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns. Place it on a content-less system message (`content: \"\"`) directly before the user message it should apply to, and keep it at that position in later requests. Equivalent to the OpenAI Responses `configuration_update` input item and the Anthropic Messages per-message `output_config.effort`.""" reasoning: ConfigurationUpdateReasoningTypedDict r"""Reasoning settings applied from this point in the conversation onward""" -class ConfigurationUpdate(BaseModel): +class ChatSystemMessageConfigurationUpdate(BaseModel): r"""OpenRouter extension. Changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns. Place it on a content-less system message (`content: \"\"`) directly before the user message it should apply to, and keep it at that position in later requests. Equivalent to the OpenAI Responses `configuration_update` input item and the Anthropic Messages per-message `output_config.effort`.""" reasoning: ConfigurationUpdateReasoning @@ -53,7 +53,9 @@ class ChatSystemMessageTypedDict(TypedDict): content: ChatSystemMessageContentTypedDict r"""System message content""" role: ChatSystemMessageRole - configuration_update: NotRequired[Nullable[ConfigurationUpdateTypedDict]] + configuration_update: NotRequired[ + Nullable[ChatSystemMessageConfigurationUpdateTypedDict] + ] r"""OpenRouter extension. Changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns. Place it on a content-less system message (`content: \"\"`) directly before the user message it should apply to, and keep it at that position in later requests. Equivalent to the OpenAI Responses `configuration_update` input item and the Anthropic Messages per-message `output_config.effort`.""" name: NotRequired[str] r"""Optional name for the system message""" @@ -67,7 +69,7 @@ class ChatSystemMessage(BaseModel): role: ChatSystemMessageRole - configuration_update: OptionalNullable[ConfigurationUpdate] = UNSET + configuration_update: OptionalNullable[ChatSystemMessageConfigurationUpdate] = UNSET r"""OpenRouter extension. Changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns. Place it on a content-less system message (`content: \"\"`) directly before the user message it should apply to, and keep it at that position in later requests. Equivalent to the OpenAI Responses `configuration_update` input item and the Anthropic Messages per-message `output_config.effort`.""" name: Optional[str] = None diff --git a/uv.lock b/uv.lock index d23511ce..03f442f5 100644 --- a/uv.lock +++ b/uv.lock @@ -213,7 +213,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.1.128" +version = "1.1.129" source = { editable = "." } dependencies = [ { name = "httpcore" },