From a5b2bd6ed6e8a5fb8a8f51fd3059a174a38a8840 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Mon, 30 Nov 2026 21:25:10 +0000 Subject: [PATCH] =?UTF-8?q?##=20Python=20SDK=20Changes:=20*=20`open=5Frout?= =?UTF-8?q?er.batch.create=5Fbatches()`:=20=20=20*=20=20`request.endpoint.?= =?UTF-8?q?enum(/v1/images/generations)`=20**Added**=20=20=20*=20=20`respo?= =?UTF-8?q?nse.results[].response.body.union(BatchImageGenerationResponse)?= =?UTF-8?q?`=20**Added**=20(Breaking=20=E2=9A=A0=EF=B8=8F)=20*=20`open=5Fr?= =?UTF-8?q?outer.batch.get=5Fbatches()`:=20=20`response.results[].response?= =?UTF-8?q?.body.union(BatchImageGenerationResponse)`=20**Added**=20(Break?= =?UTF-8?q?ing=20=E2=9A=A0=EF=B8=8F)=20*=20`open=5Frouter.batch.get=5Fresu?= =?UTF-8?q?lts()`:=20=20`response.data[].response.body.union(BatchImageGen?= =?UTF-8?q?erationResponse)`=20**Added**=20(Breaking=20=E2=9A=A0=EF=B8=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .speakeasy/gen.lock | 65 ++++++++++++------- .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 41 +++++++++++- .speakeasy/workflow.lock | 10 +-- RELEASES.md | 12 +++- docs/components/batchimagegenerationimage.mdx | 14 ++++ .../batchimagegenerationresponse.mdx | 15 +++++ docs/components/body.mdx | 6 ++ docs/components/endpoint.mdx | 1 + docs/sdks/batch/README.mdx | 2 +- pyproject.toml | 2 +- src/openrouter/_version.py | 4 +- src/openrouter/batch.py | 4 +- src/openrouter/components/__init__.py | 16 +++++ .../components/batchimagegenerationimage.py | 46 +++++++++++++ .../batchimagegenerationresponse.py | 55 ++++++++++++++++ src/openrouter/components/batchresult.py | 12 +++- src/openrouter/components/batchsubmitbody.py | 1 + uv.lock | 2 +- 19 files changed, 270 insertions(+), 40 deletions(-) create mode 100644 docs/components/batchimagegenerationimage.mdx create mode 100644 docs/components/batchimagegenerationresponse.mdx create mode 100644 src/openrouter/components/batchimagegenerationimage.py create mode 100644 src/openrouter/components/batchimagegenerationresponse.py diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index f45d985c5..0364242b7 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: d9d0dfdeb2220074e7e8c4be5bb41f14 + docChecksum: 7b6446f8c6e2e79ebb1bc7007ef04652 docVersion: 1.0.0 speakeasyVersion: 1.803.2 generationVersion: 2.950.13 - releaseVersion: 1.3.215 - configChecksum: 76ef3d7352acc406e158196714dac1f7 + releaseVersion: 1.3.216 + configChecksum: 090f2266475ce885760e5a5843003ffa repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: b0c63c8b-d0b0-4a1e-9fd8-e9d5195b4afb - pristine_commit_hash: 74222b04c38df3f066fc72da3ae27f0833d7b626 - pristine_tree_hash: c230951cc77663588a321c8abc2b1280fd5a2f7c + generation_id: 56477e00-aff2-4711-b532-50caf993c3eb + pristine_commit_hash: 94fc42bb62f87e6a19355767b2660bf0adaf6835 + pristine_tree_hash: 077cf055bd772ffd088153edb993ff5a00da3502 features: python: acceptHeaders: 3.0.0 @@ -1470,6 +1470,14 @@ trackedFiles: id: 2f458adb351e last_write_checksum: sha1:610064187d560203fccfb7e65a9ff7e7350bbb81 pristine_git_object: bdaf4ed396310a47770724e89d190f3166aa428e + docs/components/batchimagegenerationimage.mdx: + id: ecfe0c4de02d + last_write_checksum: sha1:9b7f38cdcfb2b4897e311f54ad09f77f590f986c + pristine_git_object: d7cd749451dea7b5545eae5f039e368cfc825d7d + docs/components/batchimagegenerationresponse.mdx: + id: 0dec69d57d65 + last_write_checksum: sha1:6bc8e08bb727c0b4fdd0f514b423170be422134d + pristine_git_object: 3d527fb1cefb71789ee3fe0d42442feda3b7a3db docs/components/batchinputreference.mdx: id: 5720c0dc0b92 last_write_checksum: sha1:5be09cf46a022cd7f3074189b096d486b271fac9 @@ -1736,8 +1744,8 @@ trackedFiles: pristine_git_object: a907902b407eac76aae4cbd5ce4814b36168123d docs/components/body.mdx: id: fc4484e326cb - last_write_checksum: sha1:c41e92b10ff076c3c7fed6c37405ad37d4828fcb - pristine_git_object: bbbf166d9fd2738e14622e0f8d07a719931e8ade + last_write_checksum: sha1:11c8b51c859473b83beb88d8a90e57b492670d77 + pristine_git_object: 07d5158e34d4eea886235749e18513cecc4c17a1 docs/components/bodyaudiospeech.mdx: id: 887ed62d2933 last_write_checksum: sha1:5035cb850dd2cbddd2e77491a0e799400cf211e6 @@ -3372,8 +3380,8 @@ trackedFiles: pristine_git_object: 5b155412cf75006c71e148911d0df802c4861c91 docs/components/endpoint.mdx: id: bab712ee633d - last_write_checksum: sha1:7bf3794a20d7fd8753034354ebd8c006c1e85153 - pristine_git_object: 5a3fda8f8a93d34f6cf9dfc3b43d197fcaacb4a2 + last_write_checksum: sha1:37ef09040eb8a66cf924c237189de7778cfcfcb2 + pristine_git_object: a767869c19776b9d2417479307d5cdbaa7987383 docs/components/endpointinfo.mdx: id: 6dcdfc7379a9 last_write_checksum: sha1:9d74487fce60c77fa0477eb32e7b647edd01ea6b @@ -11760,8 +11768,8 @@ trackedFiles: pristine_git_object: e1c261779c6ccbc2b6cf70738af9bf5b5a9925aa docs/sdks/batch/README.mdx: id: e367aa4f4295 - last_write_checksum: sha1:451cb8ea8a6aea041d2b85a44af34e880fe27313 - pristine_git_object: e37a1c680657805f1bb53f84b42fd9b8745b27b3 + last_write_checksum: sha1:3b4b5a6cc9875a34e7aef2b5a458a35739ef6f41 + pristine_git_object: 6d828a2f0c8e25e0a46fb4f0a99bea0f126fc9e4 docs/sdks/benchmarks/README.mdx: id: 5b483a6770ba last_write_checksum: sha1:10a8edbf3bc300bab53ce72c3a37c974971b74bd @@ -11912,8 +11920,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:7982d06fc322f3c122d5f5853fc73bc9857fdfcb - pristine_git_object: b91887b336e9549e89fa4334d62e74f52bae93da + last_write_checksum: sha1:26019a4c5aecf7f59fd22e0a2fa1f281719460bc + pristine_git_object: 8a0f7d923a1cc0de01aab7e6fc85b2e4efd298d0 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -11940,8 +11948,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:44e65ab1b62db8f24c6e7bc3bb871ac15f98433b - pristine_git_object: 69ee14861804b332da5b172ad94b67aeb2a7a9d2 + last_write_checksum: sha1:6a457dcd12041059a4922514b57a11a3748bb891 + pristine_git_object: e33123b1d16c259eeb0677fcb21c46f6e0864744 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:80cc0f39649445431cc2247ed0e0765438467766 @@ -11960,8 +11968,8 @@ trackedFiles: pristine_git_object: 7a562e21c7e66c9db666ead83748b73adefe4278 src/openrouter/batch.py: id: 148f61e34d5b - last_write_checksum: sha1:74cf10dfd6e8b7776845108727740f230ed946fb - pristine_git_object: 4c1c1c81d393b0ed261c29cfd6c35871359d450e + last_write_checksum: sha1:29652e72df1414686e65cd8f4df75eb871cb2881 + pristine_git_object: f71c1f3f98d9b886fa5cf0c46b1dbc46db279735 src/openrouter/benchmarks.py: id: 178d2ad8d706 last_write_checksum: sha1:be86f24d07ba86e9585f7d2bc2c384dba5185727 @@ -11988,8 +11996,8 @@ trackedFiles: pristine_git_object: ad3d247954547814054c01989a2dff3d12b3e4e1 src/openrouter/components/__init__.py: id: 81754e97b3f4 - last_write_checksum: sha1:8f1ba82a54201f48d03eea3f4483a69f3c595fef - pristine_git_object: 085716e02c2361b5200234471bde441fc9569e63 + last_write_checksum: sha1:e490bbb94959f712a2d419ee027007150e4b731b + pristine_git_object: 2c11595a5ea403cd858e54dac826f3d92291552a src/openrouter/components/aabenchmarkentry.py: id: e2e0f0b48c82 last_write_checksum: sha1:08125e1d60df82793e11e8aed6e3c9fdb7512ebb @@ -12646,6 +12654,14 @@ trackedFiles: id: 393c248e7a90 last_write_checksum: sha1:fbe6541534d864016398625646c046fa2e5e21df pristine_git_object: 8c105d9beae361eba8dc0775f17eec450fe35888 + src/openrouter/components/batchimagegenerationimage.py: + id: f596a7395b9a + last_write_checksum: sha1:2177ce2bc8df7d8acab39136274291927556b39b + pristine_git_object: 4791493c1ca478484b7e16a95344debb37c0253d + src/openrouter/components/batchimagegenerationresponse.py: + id: 29fdb428112a + last_write_checksum: sha1:b3c7ec9edc2a01159b00bb14466fe1384cf93e42 + pristine_git_object: 65abbf7dfcd1e89864a07ddb457b849600aecd66 src/openrouter/components/batchinputreference.py: id: 95f4d52590ef last_write_checksum: sha1:f0a971cd8e47bab2190e7a5abe235f443b6faf0b @@ -12680,16 +12696,16 @@ trackedFiles: pristine_git_object: b2bbac635f94d6fe9f4eba2eded41b1990a9d5da src/openrouter/components/batchresult.py: id: 8a496db31329 - last_write_checksum: sha1:a08e1731bddab1ce01019d7a8304ed808670bd42 - pristine_git_object: 3b9106092b5af50837e3666b1061c788aefca239 + last_write_checksum: sha1:36a094eb53ab7a72fdbf57c0bb3896211289d3dc + pristine_git_object: 737b0c426e7befdd31db6e100467f0241a2c92d5 src/openrouter/components/batchresultspageresponse.py: id: 9a03420787ed last_write_checksum: sha1:580bf4a6ff3f1df739c880358abc0d6172b5fd9e pristine_git_object: 8bb91f751e531fba8b3026431fb13e4d38254ac1 src/openrouter/components/batchsubmitbody.py: id: 26e5100bce4e - last_write_checksum: sha1:ffe7a603d28009916fb1235a7f61abe14a79e27d - pristine_git_object: d8018f23471352bf8ce9c82931ab392b64ffb1df + last_write_checksum: sha1:ceec05e7fdfa0795cb94ad968b5fdfc9e60f1d94 + pristine_git_object: c7dd4c87e01e67841e0db8b53dd24521a4b56294 src/openrouter/components/booleancapability.py: id: 6009fd660c03 last_write_checksum: sha1:2615f4f9eecdf753ece20adc9897553404c71cc1 @@ -22117,3 +22133,4 @@ examples: "500": application/json: {"error": {"code": 400, "message": "custom_id is required on requests[0]."}} examplesVersion: 1.0.2 +releaseNotes: "## Python SDK Changes:\n* `open_router.batch.create_batches()`: \n * `request.endpoint.enum(/v1/images/generations)` **Added**\n * `response.results[].response.body.union(BatchImageGenerationResponse)` **Added** (Breaking ⚠️)\n* `open_router.batch.get_batches()`: `response.results[].response.body.union(BatchImageGenerationResponse)` **Added** (Breaking ⚠️)\n* `open_router.batch.get_results()`: `response.data[].response.body.union(BatchImageGenerationResponse)` **Added** (Breaking ⚠️)\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index cc1a4b732..557b42e33 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.215 + version: 1.3.216 additionalDependencies: dev: pytest: '>=8.3' diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 00712c3a7..d99bbb1a3 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -5381,6 +5381,43 @@ components: required: - 'error' type: 'object' + BatchImageGenerationImage: + description: 'A generated image, as a link to its stored copy' + properties: + layer: + $ref: '#/components/schemas/ImageGenerationLayer' + media_type: + description: 'Media type (MIME type) of the image, e.g. `image/png`, `image/jpeg`, `image/webp`, `image/svg+xml`. May be omitted if the format could not be determined.' + example: 'image/png' + type: 'string' + url: + format: 'uri' + type: 'string' + required: + - 'url' + type: 'object' + BatchImageGenerationResponse: + description: 'Image generation result of a batch request: image links and when they expire' + properties: + created: + description: 'Unix timestamp (seconds) when the image was generated' + example: 1748372400 + type: 'integer' + data: + items: + $ref: '#/components/schemas/BatchImageGenerationImage' + type: 'array' + expires_at: + description: 'Unix timestamp (seconds) when the image URLs in `data` stop working. Download the images before then.' + example: 1748458800 + type: 'integer' + usage: + $ref: '#/components/schemas/ImageGenerationUsage' + required: + - 'created' + - 'expires_at' + - 'data' + type: 'object' BatchInputReference: additionalProperties: false description: 'A batch input file or table in your own storage, named in place of `requests`. Available to allowlisted callers on Google Vertex BYOK endpoints only.' @@ -6796,6 +6833,7 @@ components: - 'audio' - 'usage' type: 'object' + - $ref: '#/components/schemas/BatchImageGenerationResponse' request_id: type: - 'string' @@ -6862,6 +6900,7 @@ components: - '/v1/messages' - '/v1/embeddings' - '/v1/audio/speech' + - '/v1/images/generations' type: 'string' x-speakeasy-unknown-values: allow input: @@ -42883,7 +42922,7 @@ paths: results: '$.data' type: 'cursor' post: - description: 'Creates a batch of requests that run asynchronously against a single endpoint (`/v1/chat/completions`, `/v1/responses`, `/v1/messages`, `/v1/embeddings`, `/v1/audio/speech`). Returns `202` with `status: "validating"`. Poll `GET /batches/{id}` for progress and results. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart).' + description: 'Creates a batch of requests that run asynchronously against a single endpoint (`/v1/chat/completions`, `/v1/responses`, `/v1/messages`, `/v1/embeddings`, `/v1/audio/speech`, `/v1/images/generations`). Returns `202` with `status: "validating"`. Poll `GET /batches/{id}` for progress and results. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart).' operationId: 'createBatches' requestBody: content: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index f1fc48b0d..8ba089d4e 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:cb19c616241be26028fa262da9f5caa822508b1ec2e6f175a0be1bc1aa847c24 - sourceBlobDigest: sha256:486f7455a1c9959734afee85c72a366410d955ee63bcc61262d9fce1de34f162 + sourceRevisionDigest: sha256:0ecd9e283bdee550f0cdb18c5f780da150a1569d408de2aa97303c6eb77fb3fb + sourceBlobDigest: sha256:b9cd38333d99b28f261692b00d44caeaa8d05750afdbb2e32f8a14ac7d7d0401 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:cb19c616241be26028fa262da9f5caa822508b1ec2e6f175a0be1bc1aa847c24 - sourceBlobDigest: sha256:486f7455a1c9959734afee85c72a366410d955ee63bcc61262d9fce1de34f162 + sourceRevisionDigest: sha256:0ecd9e283bdee550f0cdb18c5f780da150a1569d408de2aa97303c6eb77fb3fb + sourceBlobDigest: sha256:b9cd38333d99b28f261692b00d44caeaa8d05750afdbb2e32f8a14ac7d7d0401 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:6f878ade358e4adb2db43c5708de4f76e432a0b50ab5cbbf5754b925281ed82f + codeSamplesRevisionDigest: sha256:35794a6c0c9e8989643db4d05ba25dccce719d5d57224bd8c342abc824549bd3 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.803.2 diff --git a/RELEASES.md b/RELEASES.md index e94b5ad65..6e5cb6e9e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4919,4 +4919,14 @@ Based on: ### Generated - [python v1.3.215] . ### Releases -- [PyPI v1.3.215] https://pypi.org/project/openrouter/1.3.215 - . \ No newline at end of file +- [PyPI v1.3.215] https://pypi.org/project/openrouter/1.3.215 - . + +## 2026-11-30 21:22:30 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.803.2 (2.950.13) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.216] . +### Releases +- [PyPI v1.3.216] https://pypi.org/project/openrouter/1.3.216 - . \ No newline at end of file diff --git a/docs/components/batchimagegenerationimage.mdx b/docs/components/batchimagegenerationimage.mdx new file mode 100644 index 000000000..d7cd74945 --- /dev/null +++ b/docs/components/batchimagegenerationimage.mdx @@ -0,0 +1,14 @@ +--- +title: "BatchImageGenerationImage" +--- + +A generated image, as a link to its stored copy + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `layer` | [Optional[components.ImageGenerationLayer]](../components/imagegenerationlayer.mdx) | ➖ | Layer metadata, present when the request asked the provider to split the image into layers (Seedream: `provider.options.seed.layer_decomposition: true` with the required `layer_decomposition_options.max_images`, 2 to 16). Decomposition requires `n` to be 1 or omitted; the response returns up to `max_images` images (the base image plus its layers). | \{
"background": "transparent",
"bounding_box": \{
"absolute": [
238,
124,
786,
673
],
"normalized": [
232,
121,
768,
657
]
},
"description": "A solid red circle",
"name": "Red circle",
"z_index": 1
} | +| `media_type` | *Optional[str]* | ➖ | Media type (MIME type) of the image, e.g. `image/png`, `image/jpeg`, `image/webp`, `image/svg+xml`. May be omitted if the format could not be determined. | image/png | +| `url` | *str* | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/components/batchimagegenerationresponse.mdx b/docs/components/batchimagegenerationresponse.mdx new file mode 100644 index 000000000..3d527fb1c --- /dev/null +++ b/docs/components/batchimagegenerationresponse.mdx @@ -0,0 +1,15 @@ +--- +title: "BatchImageGenerationResponse" +--- + +Image generation result of a batch request: image links and when they expire + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| `created` | *int* | ✔️ | Unix timestamp (seconds) when the image was generated | 1748372400 | +| `data` | List[[components.BatchImageGenerationImage](../components/batchimagegenerationimage.mdx)] | ✔️ | N/A | | +| `expires_at` | *int* | ✔️ | Unix timestamp (seconds) when the image URLs in `data` stop working. Download the images before then. | 1748458800 | +| `usage` | [Optional[components.ImageGenerationUsage]](../components/imagegenerationusage.mdx) | ➖ | Token and cost usage for the image generation request, when available | \{
"completion_tokens": 4175,
"cost": 0.04,
"prompt_tokens": 0,
"total_tokens": 4175
} | \ No newline at end of file diff --git a/docs/components/body.mdx b/docs/components/body.mdx index bbbf166d9..07d5158e3 100644 --- a/docs/components/body.mdx +++ b/docs/components/body.mdx @@ -34,3 +34,9 @@ value: components.BodyList = /* values here */ value: components.BodyAudioSpeech = /* values here */ ``` +### `components.BatchImageGenerationResponse` + +```python +value: components.BatchImageGenerationResponse = /* values here */ +``` + diff --git a/docs/components/endpoint.mdx b/docs/components/endpoint.mdx index 5a3fda8f8..a767869c1 100644 --- a/docs/components/endpoint.mdx +++ b/docs/components/endpoint.mdx @@ -21,3 +21,4 @@ This is an open enum. Unrecognized values will not fail type checks. - `"/v1/messages"` - `"/v1/embeddings"` - `"/v1/audio/speech"` +- `"/v1/images/generations"` diff --git a/docs/sdks/batch/README.mdx b/docs/sdks/batch/README.mdx index e37a1c680..6d828a2f0 100644 --- a/docs/sdks/batch/README.mdx +++ b/docs/sdks/batch/README.mdx @@ -70,7 +70,7 @@ with OpenRouter( ## create_batches -Creates a batch of requests that run asynchronously against a single endpoint (`/v1/chat/completions`, `/v1/responses`, `/v1/messages`, `/v1/embeddings`, `/v1/audio/speech`). Returns `202` with `status: "validating"`. Poll `GET /batches/{id}` for progress and results. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart). +Creates a batch of requests that run asynchronously against a single endpoint (`/v1/chat/completions`, `/v1/responses`, `/v1/messages`, `/v1/embeddings`, `/v1/audio/speech`, `/v1/images/generations`). Returns `202` with `status: "validating"`. Poll `GET /batches/{id}` for progress and results. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart). ### Example Usage: chatCompletions diff --git a/pyproject.toml b/pyproject.toml index b91887b33..8a0f7d923 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.215" +version = "1.3.216" 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 69ee14861..e33123b1d 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.215" +__version__: str = "1.3.216" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.950.13" -__user_agent__: str = "speakeasy-sdk/python 1.3.215 2.950.13 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.216 2.950.13 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/batch.py b/src/openrouter/batch.py index 4c1c1c81d..f71c1f3f9 100644 --- a/src/openrouter/batch.py +++ b/src/openrouter/batch.py @@ -383,7 +383,7 @@ def create_batches( ) -> components.BatchObject: r"""Create a batch - Creates a batch of requests that run asynchronously against a single endpoint (`/v1/chat/completions`, `/v1/responses`, `/v1/messages`, `/v1/embeddings`, `/v1/audio/speech`). Returns `202` with `status: \"validating\"`. Poll `GET /batches/{id}` for progress and results. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart). + Creates a batch of requests that run asynchronously against a single endpoint (`/v1/chat/completions`, `/v1/responses`, `/v1/messages`, `/v1/embeddings`, `/v1/audio/speech`, `/v1/images/generations`). Returns `202` with `status: \"validating\"`. Poll `GET /batches/{id}` for progress and results. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart). :param endpoint: :param model: @@ -554,7 +554,7 @@ async def create_batches_async( ) -> components.BatchObject: r"""Create a batch - Creates a batch of requests that run asynchronously against a single endpoint (`/v1/chat/completions`, `/v1/responses`, `/v1/messages`, `/v1/embeddings`, `/v1/audio/speech`). Returns `202` with `status: \"validating\"`. Poll `GET /batches/{id}` for progress and results. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart). + Creates a batch of requests that run asynchronously against a single endpoint (`/v1/chat/completions`, `/v1/responses`, `/v1/messages`, `/v1/embeddings`, `/v1/audio/speech`, `/v1/images/generations`). Returns `202` with `status: \"validating\"`. Poll `GET /batches/{id}` for progress and results. See the [Batch API Quickstart](https://openrouter.ai/docs/batch-quickstart). :param endpoint: :param model: diff --git a/src/openrouter/components/__init__.py b/src/openrouter/components/__init__.py index 085716e02..2c11595a5 100644 --- a/src/openrouter/components/__init__.py +++ b/src/openrouter/components/__init__.py @@ -822,6 +822,14 @@ BatchErrorResponseError, BatchErrorResponseErrorTypedDict, ) + from .batchimagegenerationimage import ( + BatchImageGenerationImage, + BatchImageGenerationImageTypedDict, + ) + from .batchimagegenerationresponse import ( + BatchImageGenerationResponse, + BatchImageGenerationResponseTypedDict, + ) from .batchinputreference import BatchInputReference, BatchInputReferenceTypedDict from .batchlistitem import ( BatchListItem, @@ -5786,6 +5794,10 @@ "BatchDeletionTargetsTypedDict", "BatchErrorResponseError", "BatchErrorResponseErrorTypedDict", + "BatchImageGenerationImage", + "BatchImageGenerationImageTypedDict", + "BatchImageGenerationResponse", + "BatchImageGenerationResponseTypedDict", "BatchInputReference", "BatchInputReferenceTypedDict", "BatchListItem", @@ -9639,6 +9651,10 @@ "UpstreamTypedDict": ".batchdeletiontargets", "BatchErrorResponseError": ".batcherrorresponse", "BatchErrorResponseErrorTypedDict": ".batcherrorresponse", + "BatchImageGenerationImage": ".batchimagegenerationimage", + "BatchImageGenerationImageTypedDict": ".batchimagegenerationimage", + "BatchImageGenerationResponse": ".batchimagegenerationresponse", + "BatchImageGenerationResponseTypedDict": ".batchimagegenerationresponse", "BatchInputReference": ".batchinputreference", "BatchInputReferenceTypedDict": ".batchinputreference", "BatchListItem": ".batchlistitem", diff --git a/src/openrouter/components/batchimagegenerationimage.py b/src/openrouter/components/batchimagegenerationimage.py new file mode 100644 index 000000000..4791493c1 --- /dev/null +++ b/src/openrouter/components/batchimagegenerationimage.py @@ -0,0 +1,46 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .imagegenerationlayer import ImageGenerationLayer, ImageGenerationLayerTypedDict +from openrouter.types import BaseModel, UNSET_SENTINEL +from pydantic import model_serializer +from typing import Optional +from typing_extensions import NotRequired, TypedDict + + +class BatchImageGenerationImageTypedDict(TypedDict): + r"""A generated image, as a link to its stored copy""" + + url: str + layer: NotRequired[ImageGenerationLayerTypedDict] + r"""Layer metadata, present when the request asked the provider to split the image into layers (Seedream: `provider.options.seed.layer_decomposition: true` with the required `layer_decomposition_options.max_images`, 2 to 16). Decomposition requires `n` to be 1 or omitted; the response returns up to `max_images` images (the base image plus its layers).""" + media_type: NotRequired[str] + r"""Media type (MIME type) of the image, e.g. `image/png`, `image/jpeg`, `image/webp`, `image/svg+xml`. May be omitted if the format could not be determined.""" + + +class BatchImageGenerationImage(BaseModel): + r"""A generated image, as a link to its stored copy""" + + url: str + + layer: Optional[ImageGenerationLayer] = None + r"""Layer metadata, present when the request asked the provider to split the image into layers (Seedream: `provider.options.seed.layer_decomposition: true` with the required `layer_decomposition_options.max_images`, 2 to 16). Decomposition requires `n` to be 1 or omitted; the response returns up to `max_images` images (the base image plus its layers).""" + + media_type: Optional[str] = None + r"""Media type (MIME type) of the image, e.g. `image/png`, `image/jpeg`, `image/webp`, `image/svg+xml`. May be omitted if the format could not be determined.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["layer", "media_type"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/components/batchimagegenerationresponse.py b/src/openrouter/components/batchimagegenerationresponse.py new file mode 100644 index 000000000..65abbf7df --- /dev/null +++ b/src/openrouter/components/batchimagegenerationresponse.py @@ -0,0 +1,55 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .batchimagegenerationimage import ( + BatchImageGenerationImage, + BatchImageGenerationImageTypedDict, +) +from .imagegenerationusage import ImageGenerationUsage, ImageGenerationUsageTypedDict +from openrouter.types import BaseModel, UNSET_SENTINEL +from pydantic import model_serializer +from typing import List, Optional +from typing_extensions import NotRequired, TypedDict + + +class BatchImageGenerationResponseTypedDict(TypedDict): + r"""Image generation result of a batch request: image links and when they expire""" + + created: int + r"""Unix timestamp (seconds) when the image was generated""" + data: List[BatchImageGenerationImageTypedDict] + expires_at: int + r"""Unix timestamp (seconds) when the image URLs in `data` stop working. Download the images before then.""" + usage: NotRequired[ImageGenerationUsageTypedDict] + r"""Token and cost usage for the image generation request, when available""" + + +class BatchImageGenerationResponse(BaseModel): + r"""Image generation result of a batch request: image links and when they expire""" + + created: int + r"""Unix timestamp (seconds) when the image was generated""" + + data: List[BatchImageGenerationImage] + + expires_at: int + r"""Unix timestamp (seconds) when the image URLs in `data` stop working. Download the images before then.""" + + usage: Optional[ImageGenerationUsage] = None + r"""Token and cost usage for the image generation request, when available""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["usage"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/components/batchresult.py b/src/openrouter/components/batchresult.py index 3b9106092..737b0c426 100644 --- a/src/openrouter/components/batchresult.py +++ b/src/openrouter/components/batchresult.py @@ -31,6 +31,10 @@ ) from .apierrortype import APIErrorType from .armorsafeguardresult import ArmorSafeguardResult, ArmorSafeguardResultTypedDict +from .batchimagegenerationresponse import ( + BatchImageGenerationResponse, + BatchImageGenerationResponseTypedDict, +) from .chatannotation import ChatAnnotation, ChatAnnotationTypedDict from .costdetails import CostDetails, CostDetailsTypedDict from .finishreason import FinishReason @@ -1413,6 +1417,7 @@ def serialize_model(self, handler): "BodyTypedDict", Union[ BodyAudioSpeechTypedDict, + BatchImageGenerationResponseTypedDict, BodyListTypedDict, BodyMessageTypedDict, BodyChatCompletionTypedDict, @@ -1424,7 +1429,12 @@ def serialize_model(self, handler): Body = TypeAliasType( "Body", Union[ - BodyAudioSpeech, BodyList, BodyMessage, BodyChatCompletion, OpenResponsesResult + BodyAudioSpeech, + BatchImageGenerationResponse, + BodyList, + BodyMessage, + BodyChatCompletion, + OpenResponsesResult, ], ) diff --git a/src/openrouter/components/batchsubmitbody.py b/src/openrouter/components/batchsubmitbody.py index d8018f234..c7dd4c87e 100644 --- a/src/openrouter/components/batchsubmitbody.py +++ b/src/openrouter/components/batchsubmitbody.py @@ -29,6 +29,7 @@ "/v1/messages", "/v1/embeddings", "/v1/audio/speech", + "/v1/images/generations", ], UnrecognizedStr, ] diff --git a/uv.lock b/uv.lock index 8ee76f0a9..1b01d4f77 100644 --- a/uv.lock +++ b/uv.lock @@ -231,7 +231,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.215" +version = "1.3.216" source = { editable = "." } dependencies = [ { name = "httpcore" },