diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 6b8dd0faf..d1730bffa 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: 83a66c1e4d3d049101bba8c81f0e17f7 + docChecksum: f222167ea1741b94fa09abf2fdcfc21e docVersion: 1.0.0 speakeasyVersion: 1.803.2 generationVersion: 2.950.13 - releaseVersion: 1.3.164 - configChecksum: e851fa826eba158e743ab6a9a1cba756 + releaseVersion: 1.3.165 + configChecksum: 0daa315b2ea3b683b78a6419e4d12afd repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: d3a158e1-f4db-4d9b-ae2d-bb6c74594de1 - pristine_commit_hash: 5b3481d65b3820d405dabe5c47dfed688dc50434 - pristine_tree_hash: 03c4263565a0fdd0a04d1d768d16202728dab411 + generation_id: c98d4ad5-9f2a-487f-a5cd-969aec31f4d1 + pristine_commit_hash: 50305a324f8f6c7805373f404842c59776793b94 + pristine_tree_hash: a6da0c3336ec0d2203dbbb08abf9925a63e3d1e9 features: python: acceptHeaders: 3.0.0 @@ -1560,8 +1560,8 @@ trackedFiles: pristine_git_object: e2fc9fd2368fefc0ba33224fdb58809596869d06 docs/components/batchobjectdata.mdx: id: ffbd6c621d43 - last_write_checksum: sha1:0659f1c81fefec3470ae18e6db5306b3b4f15ed7 - pristine_git_object: 8b57214c75be22f45b5bd4374ceb67a7432e648b + last_write_checksum: sha1:4d365b46d6ab0a8a73e5950ac116af941886fe0c + pristine_git_object: 53afc1a47c0f5b46d6cd3d2bf9474a8ebb4e3756 docs/components/batchobjectdebug.mdx: id: d1b46e566034 last_write_checksum: sha1:187f310c8a97e1bcd65dcdd0e9a29234d2d68845 @@ -9696,8 +9696,8 @@ trackedFiles: pristine_git_object: 488b8b57dcdb92e59281fe415e8015a616679970 docs/operations/createembeddingsdata.mdx: id: 1bb218f30173 - last_write_checksum: sha1:fe497c0dbfff2bcd81b4e06d75aba5fb1278bd4f - pristine_git_object: c07ff90afee4e6b3d47a697b00706a1b1cc78118 + last_write_checksum: sha1:d69468aca84eaf4d19f3a7ff3f9bfadeb58903e0 + pristine_git_object: 792ea2847c482c5e38955c1c55b31ca47d596b3c docs/operations/createembeddingsglobals.mdx: id: 11cf622f54b6 last_write_checksum: sha1:2f3d75c5f99fecb94602754e2e1e06af156db070 @@ -9708,8 +9708,8 @@ trackedFiles: pristine_git_object: d2cd66cd4a4713e0aaf51023d6315e3b4cb6b7b8 docs/operations/createembeddingsrequestbody.mdx: id: ce68e3b84ec3 - last_write_checksum: sha1:d3b6672f5b1139958d292c32a305e5914b67e28d - pristine_git_object: 769a9579eba5e3b533a30ae19fe5e0331552641f + last_write_checksum: sha1:ed20f2152bd2e87ccc721f9a127502ac2ae2884b + pristine_git_object: 5e94783fd8990b7488df2baacf6e24895569fb5f docs/operations/createembeddingsresponse.mdx: id: 4db044e7c8a7 last_write_checksum: sha1:9b1ed48afb937e503da99a9d9f6c26ee036d84be @@ -10592,8 +10592,8 @@ trackedFiles: pristine_git_object: 62255da5a1c53bf3b10d6a12e078e3589ca34197 docs/operations/inputunion.mdx: id: fa09ca81a05c - last_write_checksum: sha1:6126fc355e98574f157b9b485ac850a0ec6f2a5e - pristine_git_object: 2394952123e253a775bb81426d6ee2d49911e97b + last_write_checksum: sha1:b592168e16977b71ea976de9aaa32e5bc7eebc66 + pristine_git_object: dace01413ab3778f0612d9a5651b5455454661ba docs/operations/keepmembers.mdx: id: 2794baf69c28 last_write_checksum: sha1:aaeb714170a62787f1821383b6136d1753f14722 @@ -11508,8 +11508,8 @@ trackedFiles: pristine_git_object: ccfdf4d46e8b2d6fd98c965c290ca2307a13a0bb docs/sdks/embeddings/README.mdx: id: cd71581df291 - last_write_checksum: sha1:67640eac4a149bf213063aae2252b66ead195452 - pristine_git_object: c9cd08e0c5ddc58ceffd85ee9ac7bf99e6f7180b + last_write_checksum: sha1:0c135485dc12628ef6717f2aab76b4b5a442d6d5 + pristine_git_object: c5fccc03dd202034eb2d447f7236e9d468215b2c docs/sdks/endpoints/README.mdx: id: 62dfac9f7b71 last_write_checksum: sha1:3cf3ac86ba33ebc2c82d1d2d54ba779b1fc7ce33 @@ -11620,8 +11620,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:bdd5cc34f3f0a8af450afed5a3da30544cd15e2b - pristine_git_object: 32cd0d3b1f3f9056c0f834e655bd51be4b9aa47d + last_write_checksum: sha1:1e9e16d9c9f52cd4abee9b324aa837c5081615d2 + pristine_git_object: 011e09cdba79353a9e6dcb89967803a3f7c31c3b scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -11648,8 +11648,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:e1cf3fe0a23400c7514ffab6dcbcf99f1f5b7950 - pristine_git_object: be5ca24775c1c3a974a9a639bae411fce7e01761 + last_write_checksum: sha1:62a07b676d07f7010d1ee398af6930a0a3b4180b + pristine_git_object: f7739434513906a1842da676937cf0b2432de219 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:80cc0f39649445431cc2247ed0e0765438467766 @@ -12368,8 +12368,8 @@ trackedFiles: pristine_git_object: 8650957337063ba3aef94341108448ec19bd2945 src/openrouter/components/batchobject.py: id: caf1ef2414a3 - last_write_checksum: sha1:7d72a640b1d4b592b455cacdea31f86cc856ad33 - pristine_git_object: 7987968f47d7d9713237f1a90231fd7c78a617c3 + last_write_checksum: sha1:5d342f4f271ed7d5f04ba184ef1cf263a876ab12 + pristine_git_object: aef368a29570342346022dcc706ac59db00fa6f2 src/openrouter/components/batchpaymentrequiredresponse_error.py: id: 29d3620e8858 last_write_checksum: sha1:c797fbfd8a88561c101aca8a4d556352213b8096 @@ -15520,8 +15520,8 @@ trackedFiles: pristine_git_object: 86c90d5988c391d0f0d52d29f8f01139eb4d26ae src/openrouter/embeddings.py: id: 0374ace39067 - last_write_checksum: sha1:3c45cacab1080f90f0a01e4923fd3bc5c8e9c281 - pristine_git_object: 71d905b15e0a7b3c140823ddb45fb34b239fe021 + last_write_checksum: sha1:76c14bf1233a2e4c06582791a89976bbf2f0f579 + pristine_git_object: 2263922e5b202354a7a6979f4b0d6445c5900522 src/openrouter/endpoints.py: id: 465bbf2b7939 last_write_checksum: sha1:0632be9f0f9b0bc8a282a5840a759d7a2833c645 @@ -15780,8 +15780,8 @@ trackedFiles: pristine_git_object: d96c756e911994eaf6ef695a059f7575d69ff63c src/openrouter/operations/createembeddings.py: id: fe1160a960e9 - last_write_checksum: sha1:c1e7ac31c6ed358390feeef03d91e5917e57d5de - pristine_git_object: 480596964d35ec389350b19b2bf56ac1877960ce + last_write_checksum: sha1:5d214462d03b94720ed4243cb0ee0b966a8e529a + pristine_git_object: d3c58f701fa7b39ee9d2adf92909062b2ca72ed7 src/openrouter/operations/createexternaluser.py: id: 6bb4aa63cf35 last_write_checksum: sha1:d114e83b15d1b4eefb6e0d948b59124379813101 @@ -21609,4 +21609,4 @@ examples: "500": application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 -releaseNotes: "## Python SDK Changes:\n* `open_router.batch.create_batches()`: \n * `request.endpoint.enum(/v1/audio/speech)` **Added**\n * `response.results[].response.body.union(class (4))` **Added** (Breaking ⚠️)\n* `open_router.batch.get_batches()`: `response.results[].response.body.union(class (4))` **Added** (Breaking ⚠️)\n" +releaseNotes: "## Python SDK Changes:\n* `open_router.batch.create_batches()`: `response.results[].response.body.union(class (3)).data[].document_index` **Added**\n* `open_router.batch.get_batches()`: `response.results[].response.body.union(class (3)).data[].document_index` **Added**\n* `open_router.embeddings.generate()`: \n * `request.input.union(Array>)` **Added**\n * `response.data[].document_index` **Added**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 3bf89b026..2fa94b64f 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.164 + version: 1.3.165 additionalDependencies: dev: pytest: '>=8.3' diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 69303e296..a15745aa9 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -6207,6 +6207,10 @@ components: index: 0 object: 'embedding' properties: + document_index: + description: 'Index of the source document when `input` was a list of documents (contextual embeddings). Absent otherwise.' + example: 0 + type: 'integer' embedding: anyOf: - items: @@ -44088,6 +44092,19 @@ paths: minLength: 1 type: 'string' type: 'array' + - description: 'Documents to embed with document-level context: each item is an ordered list of chunk strings. One embedding is returned per chunk, in document order, with `document_index` set on each. Only models that support contextual embeddings accept this shape.' + example: + - - 'Paris is the capital of France.' + - 'It sits on the Seine.' + - - 'Berlin is the capital of Germany.' + items: + items: + minLength: 1 + type: 'string' + minItems: 1 + type: 'array' + minItems: 1 + type: 'array' - items: type: 'number' type: 'array' @@ -44141,7 +44158,7 @@ paths: description: 'Text, token, or multimodal input(s) to embed' example: 'The quick brown fox jumps over the lazy dog' input_type: - description: 'The type of input (e.g. search_query, search_document)' + description: 'The type of input (e.g. search_query, search_document). Document-chunk input (`string[][]`) is only valid with a document input type.' example: 'search_query' type: 'string' model: @@ -44207,6 +44224,10 @@ paths: index: 0 object: 'embedding' properties: + document_index: + description: 'Index of the source document when `input` was a list of documents (contextual embeddings). Absent otherwise.' + example: 0 + type: 'integer' embedding: anyOf: - items: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 1e6b11a30..bfcb9626d 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:bc44f0142393e2fcddd93b174e23993e9381679bc2d1e7a7d342d8a4bb7515c9 - sourceBlobDigest: sha256:100cf0bccc73a1774aae0b97327033104d08856cd30630a1264ebb0ac88bf863 + sourceRevisionDigest: sha256:535d9a7476c560df30f2f6e3503b0933212d5b613ea696d67a45ff8023b7ddba + sourceBlobDigest: sha256:72e1a7e0e1cf5209c61f3d75ffe2fa4f69eb74b026703e1fa8fe46e473aa1ed1 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:bc44f0142393e2fcddd93b174e23993e9381679bc2d1e7a7d342d8a4bb7515c9 - sourceBlobDigest: sha256:100cf0bccc73a1774aae0b97327033104d08856cd30630a1264ebb0ac88bf863 + sourceRevisionDigest: sha256:535d9a7476c560df30f2f6e3503b0933212d5b613ea696d67a45ff8023b7ddba + sourceBlobDigest: sha256:72e1a7e0e1cf5209c61f3d75ffe2fa4f69eb74b026703e1fa8fe46e473aa1ed1 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:19e05057ce93aa0a9c83f8508484a345be2ff3d4a6dca71942bbe600bb8a9409 + codeSamplesRevisionDigest: sha256:fc4e277f20fea75d4a54b1fd66eeea24274542c5aa4075f48aff55fe9ab10f40 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.803.2 diff --git a/RELEASES.md b/RELEASES.md index 4c20b483f..95566fcc3 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4409,4 +4409,14 @@ Based on: ### Generated - [python v1.3.164] . ### Releases -- [PyPI v1.3.164] https://pypi.org/project/openrouter/1.3.164 - . \ No newline at end of file +- [PyPI v1.3.164] https://pypi.org/project/openrouter/1.3.164 - . + +## 2026-11-11 23:39:07 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.803.2 (2.950.13) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.165] . +### Releases +- [PyPI v1.3.165] https://pypi.org/project/openrouter/1.3.165 - . \ No newline at end of file diff --git a/docs/components/batchobjectdata.mdx b/docs/components/batchobjectdata.mdx index 8b57214c7..53afc1a47 100644 --- a/docs/components/batchobjectdata.mdx +++ b/docs/components/batchobjectdata.mdx @@ -7,8 +7,9 @@ A single embedding object ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -| `embedding` | [components.Embedding](../components/embedding.mdx) | ✔️ | Embedding vector as an array of floats or a base64 string | [
0.0023064255,
-0.009327292,
0.015797347
] | -| `index` | *Optional[int]* | ➖ | Index of the embedding in the input list | 0 | -| `object` | [components.ObjectEmbedding](../components/objectembedding.mdx) | ✔️ | N/A | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `document_index` | *Optional[int]* | ➖ | Index of the source document when `input` was a list of documents (contextual embeddings). Absent otherwise. | 0 | +| `embedding` | [components.Embedding](../components/embedding.mdx) | ✔️ | Embedding vector as an array of floats or a base64 string | [
0.0023064255,
-0.009327292,
0.015797347
] | +| `index` | *Optional[int]* | ➖ | Index of the embedding in the input list | 0 | +| `object` | [components.ObjectEmbedding](../components/objectembedding.mdx) | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/operations/createembeddingsdata.mdx b/docs/operations/createembeddingsdata.mdx index c07ff90af..792ea2847 100644 --- a/docs/operations/createembeddingsdata.mdx +++ b/docs/operations/createembeddingsdata.mdx @@ -7,8 +7,9 @@ A single embedding object ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -| `embedding` | [operations.Embedding](../operations/embedding.mdx) | ✔️ | Embedding vector as an array of floats or a base64 string | [
0.0023064255,
-0.009327292,
0.015797347
] | -| `index` | *Optional[int]* | ➖ | Index of the embedding in the input list | 0 | -| `object` | [operations.ObjectEmbedding](../operations/objectembedding.mdx) | ✔️ | N/A | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `document_index` | *Optional[int]* | ➖ | Index of the source document when `input` was a list of documents (contextual embeddings). Absent otherwise. | 0 | +| `embedding` | [operations.Embedding](../operations/embedding.mdx) | ✔️ | Embedding vector as an array of floats or a base64 string | [
0.0023064255,
-0.009327292,
0.015797347
] | +| `index` | *Optional[int]* | ➖ | Index of the embedding in the input list | 0 | +| `object` | [operations.ObjectEmbedding](../operations/objectembedding.mdx) | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/operations/createembeddingsrequestbody.mdx b/docs/operations/createembeddingsrequestbody.mdx index 769a9579e..5e94783fd 100644 --- a/docs/operations/createembeddingsrequestbody.mdx +++ b/docs/operations/createembeddingsrequestbody.mdx @@ -12,7 +12,7 @@ Embeddings request input | `dimensions` | *Optional[int]* | ➖ | The number of dimensions for the output embeddings | 1536 | | `encoding_format` | [Optional[operations.EncodingFormat]](../operations/encodingformat.mdx) | ➖ | The format of the output embeddings | float | | `input` | [operations.InputUnion](../operations/inputunion.mdx) | ✔️ | Text, token, or multimodal input(s) to embed | The quick brown fox jumps over the lazy dog | -| `input_type` | *Optional[str]* | ➖ | The type of input (e.g. search_query, search_document) | search_query | +| `input_type` | *Optional[str]* | ➖ | The type of input (e.g. search_query, search_document). Document-chunk input (`string[][]`) is only valid with a document input type. | search_query | | `model` | *str* | ✔️ | The model to use for embeddings | openai/text-embedding-3-small | | `provider` | [OptionalNullable[components.ProviderPreferences]](../components/providerpreferences.mdx) | ➖ | N/A | \{
"allow_fallbacks": true
} | | `session_id` | *Optional[str]* | ➖ | A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. | session-1234 | diff --git a/docs/operations/inputunion.mdx b/docs/operations/inputunion.mdx index 239495212..dace01413 100644 --- a/docs/operations/inputunion.mdx +++ b/docs/operations/inputunion.mdx @@ -19,6 +19,12 @@ value: str = /* values here */ value: List[str] = /* values here */ ``` +### `List[List[str]]` + +```python +value: List[List[str]] = /* values here */ +``` + ### `List[float]` ```python diff --git a/docs/sdks/embeddings/README.mdx b/docs/sdks/embeddings/README.mdx index c9cd08e0c..c5fccc03d 100644 --- a/docs/sdks/embeddings/README.mdx +++ b/docs/sdks/embeddings/README.mdx @@ -48,7 +48,7 @@ with OpenRouter( | `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | | `dimensions` | *Optional[int]* | ➖ | The number of dimensions for the output embeddings | 1536 | | `encoding_format` | [Optional[operations.EncodingFormat]](../../operations/encodingformat.mdx) | ➖ | The format of the output embeddings | float | -| `input_type` | *Optional[str]* | ➖ | The type of input (e.g. search_query, search_document) | search_query | +| `input_type` | *Optional[str]* | ➖ | The type of input (e.g. search_query, search_document). Document-chunk input (`string[][]`) is only valid with a document input type. | search_query | | `provider` | [OptionalNullable[components.ProviderPreferences]](../../components/providerpreferences.mdx) | ➖ | N/A | \{
"allow_fallbacks": true
} | | `session_id` | *Optional[str]* | ➖ | A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. | session-1234 | | `trace` | [Optional[components.TraceConfig]](../../components/traceconfig.mdx) | ➖ | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | \{
"trace_id": "trace-abc123",
"trace_name": "my-app-trace"
} | diff --git a/pyproject.toml b/pyproject.toml index 32cd0d3b1..011e09cdb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.164" +version = "1.3.165" 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 be5ca2477..f77394345 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.164" +__version__: str = "1.3.165" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.950.13" -__user_agent__: str = "speakeasy-sdk/python 1.3.164 2.950.13 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.165 2.950.13 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/components/batchobject.py b/src/openrouter/components/batchobject.py index 7987968f4..aef368a29 100644 --- a/src/openrouter/components/batchobject.py +++ b/src/openrouter/components/batchobject.py @@ -252,6 +252,8 @@ class BatchObjectDataTypedDict(TypedDict): embedding: EmbeddingTypedDict r"""Embedding vector as an array of floats or a base64 string""" object: ObjectEmbedding + document_index: NotRequired[int] + r"""Index of the source document when `input` was a list of documents (contextual embeddings). Absent otherwise.""" index: NotRequired[int] r"""Index of the embedding in the input list""" @@ -264,12 +266,15 @@ class BatchObjectData(BaseModel): object: ObjectEmbedding + document_index: Optional[int] = None + r"""Index of the source document when `input` was a list of documents (contextual embeddings). Absent otherwise.""" + index: Optional[int] = None r"""Index of the embedding in the input list""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["index"]) + optional_fields = set(["document_index", "index"]) serialized = handler(self) m = {} diff --git a/src/openrouter/embeddings.py b/src/openrouter/embeddings.py index 71d905b15..2263922e5 100644 --- a/src/openrouter/embeddings.py +++ b/src/openrouter/embeddings.py @@ -61,7 +61,7 @@ def generate( :param dimensions: The number of dimensions for the output embeddings :param encoding_format: The format of the output embeddings - :param input_type: The type of input (e.g. search_query, search_document) + :param input_type: The type of input (e.g. search_query, search_document). Document-chunk input (`string[][]`) is only valid with a document input type. :param provider: :param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. :param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. @@ -298,7 +298,7 @@ async def generate_async( :param dimensions: The number of dimensions for the output embeddings :param encoding_format: The format of the output embeddings - :param input_type: The type of input (e.g. search_query, search_document) + :param input_type: The type of input (e.g. search_query, search_document). Document-chunk input (`string[][]`) is only valid with a document input type. :param provider: :param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. :param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. diff --git a/src/openrouter/operations/createembeddings.py b/src/openrouter/operations/createembeddings.py index 480596964..d3c58f701 100644 --- a/src/openrouter/operations/createembeddings.py +++ b/src/openrouter/operations/createembeddings.py @@ -179,13 +179,21 @@ class Input(BaseModel): InputUnionTypedDict = TypeAliasType( "InputUnionTypedDict", - Union[str, List[str], List[float], List[List[float]], List[InputTypedDict]], + Union[ + str, + List[str], + List[List[str]], + List[float], + List[List[float]], + List[InputTypedDict], + ], ) r"""Text, token, or multimodal input(s) to embed""" InputUnion = TypeAliasType( - "InputUnion", Union[str, List[str], List[float], List[List[float]], List[Input]] + "InputUnion", + Union[str, List[str], List[List[str]], List[float], List[List[float]], List[Input]], ) r"""Text, token, or multimodal input(s) to embed""" @@ -202,7 +210,7 @@ class CreateEmbeddingsRequestBodyTypedDict(TypedDict): encoding_format: NotRequired[EncodingFormat] r"""The format of the output embeddings""" input_type: NotRequired[str] - r"""The type of input (e.g. search_query, search_document)""" + r"""The type of input (e.g. search_query, search_document). Document-chunk input (`string[][]`) is only valid with a document input type.""" provider: NotRequired[ Nullable[components_providerpreferences.ProviderPreferencesTypedDict] ] @@ -230,7 +238,7 @@ class CreateEmbeddingsRequestBody(BaseModel): r"""The format of the output embeddings""" input_type: Optional[str] = None - r"""The type of input (e.g. search_query, search_document)""" + r"""The type of input (e.g. search_query, search_document). Document-chunk input (`string[][]`) is only valid with a document input type.""" provider: OptionalNullable[components_providerpreferences.ProviderPreferences] = ( UNSET @@ -368,6 +376,8 @@ class CreateEmbeddingsDataTypedDict(TypedDict): embedding: EmbeddingTypedDict r"""Embedding vector as an array of floats or a base64 string""" object: ObjectEmbedding + document_index: NotRequired[int] + r"""Index of the source document when `input` was a list of documents (contextual embeddings). Absent otherwise.""" index: NotRequired[int] r"""Index of the embedding in the input list""" @@ -380,12 +390,15 @@ class CreateEmbeddingsData(BaseModel): object: ObjectEmbedding + document_index: Optional[int] = None + r"""Index of the source document when `input` was a list of documents (contextual embeddings). Absent otherwise.""" + index: Optional[int] = None r"""Index of the embedding in the input list""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["index"]) + optional_fields = set(["document_index", "index"]) serialized = handler(self) m = {} diff --git a/uv.lock b/uv.lock index 54baaeafa..1e56dead6 100644 --- a/uv.lock +++ b/uv.lock @@ -231,7 +231,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.164" +version = "1.3.165" source = { editable = "." } dependencies = [ { name = "httpcore" },