From d3ffefb10da63d06556a55ab028279726b07e38c Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Tue, 6 Oct 2026 13:47:28 +0000 Subject: [PATCH 1/2] ## Python SDK Changes: * `open_router.byok.list()`: `response.data[].declared_region` **Added** * `open_router.byok.create()`: * `request.declared_region` **Added** * `response.data.declared_region` **Added** * `open_router.byok.get()`: `response.data.declared_region` **Added** * `open_router.byok.update()`: * `request.declared_region` **Added** * `response.data.declared_region` **Added** * `error.status[409]` **Added** --- .speakeasy/gen.lock | 96 +++++++++++-------- .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 56 +++++++++++ .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 ++- docs/components/byokkey.mdx | 35 +++---- docs/components/byokkeydeclaredregion.mdx | 23 +++++ docs/components/createbyokkeyrequest.mdx | 29 +++--- .../createbyokkeyrequestdeclaredregion.mdx | 23 +++++ docs/components/createbyokkeyresponse.mdx | 6 +- docs/components/getbyokkeyresponse.mdx | 6 +- docs/components/updatebyokkeyrequest.mdx | 25 ++--- .../updatebyokkeyrequestdeclaredregion.mdx | 23 +++++ docs/components/updatebyokkeyresponse.mdx | 6 +- docs/operations/listbyokkeysresponse.mdx | 6 +- docs/sdks/byok/README.mdx | 73 +++++++------- pyproject.toml | 2 +- src/openrouter/_version.py | 4 +- src/openrouter/byok.py | 30 ++++++ src/openrouter/components/__init__.py | 10 +- src/openrouter/components/byokkey.py | 20 +++- .../components/createbyokkeyrequest.py | 21 +++- .../components/updatebyokkeyrequest.py | 21 +++- uv.lock | 2 +- 24 files changed, 395 insertions(+), 146 deletions(-) create mode 100644 docs/components/byokkeydeclaredregion.mdx create mode 100644 docs/components/createbyokkeyrequestdeclaredregion.mdx create mode 100644 docs/components/updatebyokkeyrequestdeclaredregion.mdx diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index a342e75f..28345699 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: 75f708312ea880379c9ddaf2d144c955 + docChecksum: b7492c8532e08af2f18fd897dafdf6c1 docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 1.3.23 - configChecksum: 1da4f880ffb62a54f395e6a73eb5b6a3 + releaseVersion: 1.3.24 + configChecksum: aa63ea38dd7b83ed76e7143a59ca5d16 repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: 6502350d-6a12-47e3-8a78-cdd6240c0b24 - pristine_commit_hash: 6b1dbfb42e3574a1a30750191138244d8455f94f - pristine_tree_hash: 727306d5730a16fb5ccee2713ca3ae98659b8bd8 + generation_id: 4ef97d03-0aa9-446d-be0a-640958f32299 + pristine_commit_hash: c9d4805d5d46221d8d1860ce211dbda546faa73e + pristine_tree_hash: 89ba8877386433897b1603a8162ed37431516ce4 features: python: acceptHeaders: 3.0.0 @@ -1660,8 +1660,12 @@ trackedFiles: pristine_git_object: ab64c8c0210948fce5ca2c155f3b535158aa59b0 docs/components/byokkey.mdx: id: f67303c7207c - last_write_checksum: sha1:fe8cc7b80b0b01c07683163c02ac1c8f7ad36d47 - pristine_git_object: 21f69ce3212aa1fca5c7ce02b78d9b249f15f3ff + last_write_checksum: sha1:e72f5d77c332e10447486022c917e05f45abcc7a + pristine_git_object: e68d9db4819cb8b67a6add3e9882860bc939dc8c + docs/components/byokkeydeclaredregion.mdx: + id: 772fe37bc6e7 + last_write_checksum: sha1:425dc46ef12ba5539fbcfa426cfd7b15580a0f2c + pristine_git_object: 94e38aedf8cd845831c34c7d6b4499954ccb5c83 docs/components/byokproviderslug.mdx: id: 6ea70819f6d8 last_write_checksum: sha1:77ea10099b6bea344e8afac51865e7b2d69983f6 @@ -2488,12 +2492,16 @@ trackedFiles: pristine_git_object: eeda364d2acbb840c15a3f5cc143cf10d1044c74 docs/components/createbyokkeyrequest.mdx: id: 2af3019aa2a7 - last_write_checksum: sha1:fa51de3c0917b6ae7a96bce2bcb74aeac5a5d9cf - pristine_git_object: 95230b2a6fed0f73db656faec2ce8e6aaa926436 + last_write_checksum: sha1:e540cc01f1219503a5bc39a3908170b5daca98e4 + pristine_git_object: 360386f6f8c7fce7925e0906dd6830dfb94a0419 + docs/components/createbyokkeyrequestdeclaredregion.mdx: + id: dacd66376c4c + last_write_checksum: sha1:0cd1d5e2a197d0ec08ec115489a10cfdea61034b + pristine_git_object: eff58dc1cefe5d7830b0262b16fcb77f72ce0c85 docs/components/createbyokkeyresponse.mdx: id: 73f247dc0e33 - last_write_checksum: sha1:30861793800a2851105bfa5b9406520320129f06 - pristine_git_object: 18d6a80440f1dc702eae3a3917a53a2def1fca72 + last_write_checksum: sha1:b3215e9efd44e81e7986dc22cbdcf05aa50a4a22 + pristine_git_object: 4da6fbee689d2362efb2470e07eedabdb2cb5d90 docs/components/createenduserrequest.mdx: id: e82c759c8be2 last_write_checksum: sha1:a91e5f439be4943f1d2012ae04c52d129fb95326 @@ -3344,8 +3352,8 @@ trackedFiles: pristine_git_object: 780b8f17488040e3a5fda077e100ad88dd91380f docs/components/getbyokkeyresponse.mdx: id: 451f36940fbd - last_write_checksum: sha1:eb48f4135b67e3098078260259b9077ede26578c - pristine_git_object: 26ce72e64459f02c6247db183d67a853e3b0de32 + last_write_checksum: sha1:c8110ef1e428fef2f076745aa37fc5ec614e4696 + pristine_git_object: 30d5539cff455d3658366f5da55f1d1efc09dfab docs/components/getguardrailresponse.mdx: id: a5ffd4aa91ea last_write_checksum: sha1:1b5cf22952bbe43de45da9ce526eff0229c6abd6 @@ -7500,12 +7508,16 @@ trackedFiles: pristine_git_object: 5a7e1816ae9370995ad90941ba4ba288d170d421 docs/components/updatebyokkeyrequest.mdx: id: db0862ec6814 - last_write_checksum: sha1:1c349220240b1ff823e050cb05a62cc1d20b8886 - pristine_git_object: d496aaeae691dbcbfe6b1337fddb8b9b32ae0bf8 + last_write_checksum: sha1:ddd721084b429215859d8b9f33d8a04efae662a0 + pristine_git_object: a9c7eb20176c331278b84c0dc45432b1eb500525 + docs/components/updatebyokkeyrequestdeclaredregion.mdx: + id: c4441f08b1d6 + last_write_checksum: sha1:3c1dee8ee424114784aa0ba804ee21469c974e08 + pristine_git_object: ad71341b7c5854edba5f46c9762207f8523eff83 docs/components/updatebyokkeyresponse.mdx: id: 9b4490c340b4 - last_write_checksum: sha1:5ca8cef381afdb1c03ce16df023738e163dab13b - pristine_git_object: cad8d3e654b3c1c1b570f80f73f1173a72e17db2 + last_write_checksum: sha1:77d6684dbbcf79cd2cef6cf2a87f44bd17892012 + pristine_git_object: b1eafbef06168c35b057c5d53749f255303a6164 docs/components/updateenduserrequest.mdx: id: 42e918f01861 last_write_checksum: sha1:cfc96316a62b5df60663ccec298ad23b33c93876 @@ -9044,8 +9056,8 @@ trackedFiles: pristine_git_object: f55e2c02b03447091d650816e02b71aa2d5ee562 docs/operations/listbyokkeysresponse.mdx: id: ad2f5a3c160a - last_write_checksum: sha1:d4acf188154a0868e3996127dad92c05dff40a33 - pristine_git_object: 24f7bad2b0740b139960ffdc836943c3ba76732a + last_write_checksum: sha1:5b8c84898bbd13a6071cd1d517496e81d20f5712 + pristine_git_object: e1615dcbac3f0195ad1aa62cfc21d3efd6198dfa docs/operations/listcontainerfilesglobals.mdx: id: 89c4df41f2bf last_write_checksum: sha1:0aaf5478ab48cac7f3c7dc011b5b7fdf0f040491 @@ -9824,8 +9836,8 @@ trackedFiles: pristine_git_object: 09ec1e9265382b113df9fa03a6fe8cef09691cb5 docs/sdks/byok/README.mdx: id: 17792f3b180d - last_write_checksum: sha1:7d9373a5a1d5c41b8dc333641812c07a4837965b - pristine_git_object: 9326d7d136af4b87609a5794331bc4a78bd6bdde + last_write_checksum: sha1:52b83dc59593a8117bf43070500d061b1b441305 + pristine_git_object: d159c8b234d69d6c2cd78484acbf8df6ab07b69c docs/sdks/chat/README.mdx: id: 1dd859c23fe1 last_write_checksum: sha1:6dd9a73ac931d57cc5e641488548daf51e98cb39 @@ -9956,8 +9968,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:ff48b4a9fc49e27dc1643badf968004a67da6c3d - pristine_git_object: 971d2d13b8a9955e3049127c7e2657b97aecc2da + last_write_checksum: sha1:a2d65f9ace1d87949e024d0c08f71e07170bc429 + pristine_git_object: 62bbb0adcb4bc0cdea07dfe9b09a9d9a922e1170 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -9984,8 +9996,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:bef127205e8f1604c8b8a275930b921f71e65be5 - pristine_git_object: 59786ba254bd475bc1352c089d0a36cb6b67a181 + last_write_checksum: sha1:84febebabcfc90220554d0884bf4a0fa76c14630 + pristine_git_object: de35bd4c9d2e15c98f53f9f2ff4fe605643bfae7 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:30f55a360f41376ab194b9ea725fe4e001a5ae1a @@ -10020,8 +10032,8 @@ trackedFiles: pristine_git_object: c5a9c739c250db79395f5b0f7db30f56b6fcdaff src/openrouter/byok.py: id: bec352462ae1 - last_write_checksum: sha1:ed4d5ecf5b0bf3fd004cc8629474ec0e100c0df5 - pristine_git_object: 2cc6ba136f9a53803849ba48ab3c85db9ed12436 + last_write_checksum: sha1:85e408a77084380d2f15cc0873b4e5432bbdfabc + pristine_git_object: 2737b2e25e0476bcb25a2debb638ed27f9a198da src/openrouter/chat.py: id: 723fdce15c1d last_write_checksum: sha1:9d9c3915a58c41a74bfebda2b743911324d0bde3 @@ -10032,8 +10044,8 @@ trackedFiles: pristine_git_object: ad3d247954547814054c01989a2dff3d12b3e4e1 src/openrouter/components/__init__.py: id: 81754e97b3f4 - last_write_checksum: sha1:7075570f13cc6d2d06d7169e2a777ceaf563452e - pristine_git_object: bc6c75f42fe5f7993ac396fb11707cc60e83634f + last_write_checksum: sha1:b4332657c5562071bfc8753410542b6376d6ae61 + pristine_git_object: 2e45778d420de470fb82a0280811b373f74a8274 src/openrouter/components/aabenchmarkentry.py: id: e2e0f0b48c82 last_write_checksum: sha1:fab4d9a24d2cea937bb749d46c5f83941e99d65c @@ -10732,8 +10744,8 @@ trackedFiles: pristine_git_object: 219148fc990faf0541310cf55cf11ffbcccc2e55 src/openrouter/components/byokkey.py: id: 94a3339e7dfc - last_write_checksum: sha1:a8f0cf319e0402e9243e182baad52fa8d6954240 - pristine_git_object: 22f7dfead05fc7561df8b836371fd7a2c83188d6 + last_write_checksum: sha1:111a6f211b6ba23c89ab2f3e025a100eb897e13d + pristine_git_object: ca0fc8b6f50b0274e0d90e6870c0d6b278511df7 src/openrouter/components/byokproviderslug.py: id: 6738a8516caf last_write_checksum: sha1:019fc4c14dcb066768ed1b5f8d7e023425f72e6d @@ -11080,8 +11092,8 @@ trackedFiles: pristine_git_object: 15b66bb18088bd61cccfa17e1cb5ef26c02abc84 src/openrouter/components/createbyokkeyrequest.py: id: 238e868445b4 - last_write_checksum: sha1:75e268ee84fc014142b555487c53d1913c12cc2b - pristine_git_object: 593ecbdc4f56e4dff6a7128d0154a9b9f34ab0f4 + last_write_checksum: sha1:f820376e7af7fb41ba0c3adb05290aad107b2fdf + pristine_git_object: 776ff3098d3335c768dfec80bd85ccb2b9287406 src/openrouter/components/createbyokkeyresponse.py: id: 2b6c5e13270a last_write_checksum: sha1:a7a2a40b9ac16a975a4c5ecc8802fc0b7785691c @@ -13164,8 +13176,8 @@ trackedFiles: pristine_git_object: 696d3c578c6b09f9768e52a7dd000284fb62f1b7 src/openrouter/components/updatebyokkeyrequest.py: id: 5edad69c278d - last_write_checksum: sha1:0946f9ccd054880656aa98643be4e773b276a9af - pristine_git_object: c2b4fb7d1982557f6e3e8b6a1090ebbdee5ace17 + last_write_checksum: sha1:6ec5ba2a8b7dbd19973fc447ed4444496d5c19f7 + pristine_git_object: a1ac5e5c69a6e7deac0db3f06352e70af2a1d0e2 src/openrouter/components/updatebyokkeyresponse.py: id: 31338080f7cc last_write_checksum: sha1:794d77355ae37451076a6b5754c6c8cc77063047 @@ -15216,7 +15228,7 @@ examples: limit: 50 responses: "200": - application/json: {"data": [{"allowed_api_key_hashes": null, "allowed_models": null, "allowed_user_ids": null, "created_at": "2025-08-24T10:30:00Z", "declared_zdr": null, "disabled": false, "id": "11111111-2222-3333-4444-555555555555", "is_byok_only": false, "is_fallback": false, "is_required": false, "label": "sk-...AbCd", "provider": "openai", "sort_order": 0, "workspace_id": "550e8400-e29b-41d4-a716-446655440000"}], "total_count": 1} + application/json: {"data": [{"allowed_api_key_hashes": null, "allowed_models": null, "allowed_user_ids": null, "created_at": "2025-08-24T10:30:00Z", "declared_region": null, "declared_zdr": null, "disabled": false, "id": "11111111-2222-3333-4444-555555555555", "is_byok_only": false, "is_fallback": false, "is_required": false, "label": "sk-...AbCd", "provider": "openai", "sort_order": 0, "workspace_id": "550e8400-e29b-41d4-a716-446655440000"}], "total_count": 1} "401": application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} "500": @@ -15229,7 +15241,7 @@ examples: application/json: {"key": "sk-proj-abc123...", "provider": "openai"} responses: "201": - application/json: {"data": {"allowed_api_key_hashes": null, "allowed_models": null, "allowed_user_ids": null, "created_at": "2025-08-24T10:30:00Z", "declared_zdr": null, "disabled": false, "id": "11111111-2222-3333-4444-555555555555", "is_byok_only": false, "is_fallback": false, "is_required": false, "label": "sk-...AbCd", "provider": "openai", "sort_order": 0, "workspace_id": "550e8400-e29b-41d4-a716-446655440000"}} + application/json: {"data": {"allowed_api_key_hashes": null, "allowed_models": null, "allowed_user_ids": null, "created_at": "2025-08-24T10:30:00Z", "declared_region": null, "declared_zdr": null, "disabled": false, "id": "11111111-2222-3333-4444-555555555555", "is_byok_only": false, "is_fallback": false, "is_required": false, "label": "sk-...AbCd", "provider": "openai", "sort_order": 0, "workspace_id": "550e8400-e29b-41d4-a716-446655440000"}} "400": application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} "401": @@ -15259,7 +15271,7 @@ examples: id: "11111111-2222-3333-4444-555555555555" responses: "200": - application/json: {"data": {"allowed_api_key_hashes": null, "allowed_models": null, "allowed_user_ids": null, "created_at": "2025-08-24T10:30:00Z", "declared_zdr": null, "disabled": false, "id": "11111111-2222-3333-4444-555555555555", "is_byok_only": false, "is_fallback": false, "is_required": false, "label": "sk-...AbCd", "provider": "openai", "sort_order": 0, "workspace_id": "550e8400-e29b-41d4-a716-446655440000"}} + application/json: {"data": {"allowed_api_key_hashes": null, "allowed_models": null, "allowed_user_ids": null, "created_at": "2025-08-24T10:30:00Z", "declared_region": null, "declared_zdr": null, "disabled": false, "id": "11111111-2222-3333-4444-555555555555", "is_byok_only": false, "is_fallback": false, "is_required": false, "label": "sk-...AbCd", "provider": "openai", "sort_order": 0, "workspace_id": "550e8400-e29b-41d4-a716-446655440000"}} "401": application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} "404": @@ -15275,7 +15287,7 @@ examples: application/json: {} responses: "200": - application/json: {"data": {"allowed_api_key_hashes": null, "allowed_models": null, "allowed_user_ids": null, "created_at": "2025-08-24T10:30:00Z", "declared_zdr": null, "disabled": false, "id": "11111111-2222-3333-4444-555555555555", "is_byok_only": false, "is_fallback": false, "is_required": false, "label": "sk-...AbCd", "provider": "openai", "sort_order": 0, "workspace_id": "550e8400-e29b-41d4-a716-446655440000"}} + application/json: {"data": {"allowed_api_key_hashes": null, "allowed_models": null, "allowed_user_ids": null, "created_at": "2025-08-24T10:30:00Z", "declared_region": null, "declared_zdr": null, "disabled": false, "id": "11111111-2222-3333-4444-555555555555", "is_byok_only": false, "is_fallback": false, "is_required": false, "label": "sk-...AbCd", "provider": "openai", "sort_order": 0, "workspace_id": "550e8400-e29b-41d4-a716-446655440000"}} "400": application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} "401": @@ -15286,6 +15298,8 @@ examples: application/json: {"error": {"code": 500, "message": "Internal Server Error"}} "403": application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "409": + application/json: {"error": {"code": 409, "message": "Resource conflict. Please try again later."}} getAppRankings: speakeasy-default-get-app-rankings: parameters: @@ -18250,4 +18264,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.provider.allow_fallbacks` **Added**\n" +releaseNotes: "## Python SDK Changes:\n* `open_router.byok.list()`: `response.data[].declared_region` **Added**\n* `open_router.byok.create()`: \n * `request.declared_region` **Added**\n * `response.data.declared_region` **Added**\n* `open_router.byok.get()`: `response.data.declared_region` **Added**\n* `open_router.byok.update()`: \n * `request.declared_region` **Added**\n * `response.data.declared_region` **Added**\n * `error.status[409]` **Added**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 1fc6633f..5d9ea0b2 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -36,7 +36,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.23 + version: 1.3.24 additionalDependencies: dev: {} main: {} diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 2bbd8218..72df5369 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -6411,6 +6411,7 @@ components: allowed_models: null allowed_user_ids: null created_at: '2025-08-24T10:30:00Z' + declared_region: null declared_zdr: null disabled: false id: '11111111-2222-3333-4444-555555555555' @@ -6455,6 +6456,18 @@ components: description: 'ISO timestamp of when the credential was created.' example: '2025-08-24T10:30:00Z' type: 'string' + declared_region: + description: 'Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter''s regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key''s region. Among other providers, only Azure accepts `europe` or `us`.' + enum: + - 'global' + - 'europe' + - 'us' + - null + example: null + type: + - 'string' + - 'null' + x-speakeasy-unknown-values: allow declared_zdr: description: 'Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter''s data policy for the provider''s endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter.' example: null @@ -6515,6 +6528,7 @@ components: - 'is_required' - 'is_byok_only' - 'declared_zdr' + - 'declared_region' - 'allowed_models' - 'allowed_api_key_hashes' - 'allowed_user_ids' @@ -9257,6 +9271,18 @@ components: type: - 'array' - 'null' + declared_region: + description: 'Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter''s regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key''s region. Among other providers, only Azure accepts `europe` or `us`. Defaults to the key''s region for OpenAI and Fireworks, otherwise `null`.' + enum: + - 'global' + - 'europe' + - 'us' + - null + example: null + type: + - 'string' + - 'null' + x-speakeasy-unknown-values: allow declared_zdr: description: 'Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter''s data policy for the provider''s endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Defaults to `null`.' example: null @@ -9309,6 +9335,7 @@ components: allowed_models: null allowed_user_ids: null created_at: '2025-08-24T10:30:00Z' + declared_region: null declared_zdr: null disabled: false id: '11111111-2222-3333-4444-555555555555' @@ -12681,6 +12708,7 @@ components: allowed_models: null allowed_user_ids: null created_at: '2025-08-24T10:30:00Z' + declared_region: null declared_zdr: null disabled: false id: '11111111-2222-3333-4444-555555555555' @@ -15547,6 +15575,7 @@ components: allowed_models: null allowed_user_ids: null created_at: '2025-08-24T10:30:00Z' + declared_region: null declared_zdr: null disabled: false id: '11111111-2222-3333-4444-555555555555' @@ -31108,6 +31137,18 @@ components: type: - 'array' - 'null' + declared_region: + description: 'Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter''s regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key''s region. Among other providers, only Azure accepts `europe` or `us`. Omit to leave the stored value unchanged (rotating an OpenAI or Fireworks `key` re-derives it from the new key); `null` clears the declaration.' + enum: + - 'global' + - 'europe' + - 'us' + - null + example: null + type: + - 'string' + - 'null' + x-speakeasy-unknown-values: allow declared_zdr: description: 'Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter''s data policy for the provider''s endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Omit to leave the stored value unchanged; `null` clears the declaration.' example: null @@ -31150,6 +31191,7 @@ components: allowed_models: null allowed_user_ids: null created_at: '2025-08-24T10:30:00Z' + declared_region: null declared_zdr: null disabled: false id: '11111111-2222-3333-4444-555555555555' @@ -35590,6 +35632,7 @@ paths: allowed_models: null allowed_user_ids: null created_at: '2025-08-24T10:30:00Z' + declared_region: null declared_zdr: null disabled: false id: '11111111-2222-3333-4444-555555555555' @@ -35673,6 +35716,7 @@ paths: allowed_models: null allowed_user_ids: null created_at: '2025-08-24T10:30:00Z' + declared_region: null declared_zdr: null disabled: false id: '11111111-2222-3333-4444-555555555555' @@ -35815,6 +35859,7 @@ paths: allowed_models: null allowed_user_ids: null created_at: '2025-08-24T10:30:00Z' + declared_region: null declared_zdr: null disabled: false id: '11111111-2222-3333-4444-555555555555' @@ -35895,6 +35940,7 @@ paths: allowed_models: null allowed_user_ids: null created_at: '2025-08-24T10:30:00Z' + declared_region: null declared_zdr: null disabled: false id: '11111111-2222-3333-4444-555555555555' @@ -35949,6 +35995,16 @@ paths: schema: $ref: '#/components/schemas/NotFoundResponse' description: 'Not Found - Resource does not exist' + '409': + content: + application/json: + example: + error: + code: 409 + message: 'Resource conflict. Please try again later.' + schema: + $ref: '#/components/schemas/ConflictResponse' + description: 'Conflict - Resource conflict or concurrent modification' '500': content: application/json: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index ddfd9059..ddc372b1 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:c3c70c3b6b932203ac3620c7af2ef189dd4ad5f68e8ecfa96d1ae0205eed2577 - sourceBlobDigest: sha256:abda401f4190895ad03681943992315287b174a683984cae44746bfb1fb4c01b + sourceRevisionDigest: sha256:34a31a86eb3ce6926928dcb1b8069e6b13a27b8f5f2a4d5d936ce3184f63eb9f + sourceBlobDigest: sha256:fe000858819db68aa2e13ffae2fa5e029c4dfff53412f2f4eb40b62b0d8e00fd tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:c3c70c3b6b932203ac3620c7af2ef189dd4ad5f68e8ecfa96d1ae0205eed2577 - sourceBlobDigest: sha256:abda401f4190895ad03681943992315287b174a683984cae44746bfb1fb4c01b + sourceRevisionDigest: sha256:34a31a86eb3ce6926928dcb1b8069e6b13a27b8f5f2a4d5d936ce3184f63eb9f + sourceBlobDigest: sha256:fe000858819db68aa2e13ffae2fa5e029c4dfff53412f2f4eb40b62b0d8e00fd codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:6716b090997cab4e7bab71f18bccdff9954bb6fd397c6309bd37f6c942b08f98 + codeSamplesRevisionDigest: sha256:594f0c8e56794fcbc5c9e1094c66e730f7adeecac2f5336db82e31f7e36e9ae0 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/RELEASES.md b/RELEASES.md index 0dbb3be6..b60bf3da 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2999,4 +2999,14 @@ Based on: ### Generated - [python v1.3.23] . ### Releases -- [PyPI v1.3.23] https://pypi.org/project/openrouter/1.3.23 - . \ No newline at end of file +- [PyPI v1.3.23] https://pypi.org/project/openrouter/1.3.23 - . + +## 2026-10-06 13:44:38 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.24] . +### Releases +- [PyPI v1.3.24] https://pypi.org/project/openrouter/1.3.24 - . \ No newline at end of file diff --git a/docs/components/byokkey.mdx b/docs/components/byokkey.mdx index 21f69ce3..e68d9db4 100644 --- a/docs/components/byokkey.mdx +++ b/docs/components/byokkey.mdx @@ -4,20 +4,21 @@ title: "BYOKKey" ## Fields -| Field | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `allowed_api_key_hashes` | List[*str*] | :heavy_check_mark: | Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction. | [
"f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943"
] | -| `allowed_models` | List[*str*] | :heavy_check_mark: | Optional allowlist of model slugs this credential may be used for. `null` means no restriction. | null | -| `allowed_user_ids` | List[*str*] | :heavy_check_mark: | Optional allowlist of user IDs that may use this credential. `null` means no restriction. | null | -| `created_at` | *str* | :heavy_check_mark: | ISO timestamp of when the credential was created. | 2025-08-24T10:30:00Z | -| `declared_zdr` | *Nullable[bool]* | :heavy_check_mark: | Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. | null | -| `disabled` | *bool* | :heavy_check_mark: | Whether this credential is currently disabled. | false | -| `id` | *str* | :heavy_check_mark: | Stable public identifier for this BYOK credential. | 11111111-2222-3333-4444-555555555555 | -| `is_byok_only` | *bool* | :heavy_check_mark: | Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. | false | -| `is_fallback` | *bool* | :heavy_check_mark: | Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried. Cannot be combined with `is_byok_only`. | false | -| `is_required` | *bool* | :heavy_check_mark: | Whether OpenRouter's shared endpoints on this provider are removed for the models this credential applies to (its `allowed_models`, or every model when `null`). Requests for those models run only on your keys; models outside the allowlist may still fall back to shared capacity on this provider. | false | -| `label` | *str* | :heavy_check_mark: | Short masked snippet of the key (e.g. the first/last few characters) used to identify it in the UI. | sk-...AbCd | -| `name` | *OptionalNullable[str]* | :heavy_minus_sign: | Optional human-readable name for the credential. | Production OpenAI Key | -| `provider` | [components.BYOKProviderSlug](../components/byokproviderslug.mdx) | :heavy_check_mark: | The upstream provider this credential authenticates against, as a lowercase slug (e.g. `openai`, `anthropic`, `amazon-bedrock`). | openai | -| `sort_order` | *int* | :heavy_check_mark: | Position within the provider — credentials are tried in ascending sort order. | 0 | -| `workspace_id` | *Nullable[str]* | :heavy_check_mark: | The workspace this credential is scoped to, or `null` when it is global — usable across every workspace in the account. A `null` value does not mean the default workspace. | 550e8400-e29b-41d4-a716-446655440000 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `allowed_api_key_hashes` | List[*str*] | :heavy_check_mark: | Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction. | [
"f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943"
] | +| `allowed_models` | List[*str*] | :heavy_check_mark: | Optional allowlist of model slugs this credential may be used for. `null` means no restriction. | null | +| `allowed_user_ids` | List[*str*] | :heavy_check_mark: | Optional allowlist of user IDs that may use this credential. `null` means no restriction. | null | +| `created_at` | *str* | :heavy_check_mark: | ISO timestamp of when the credential was created. | 2025-08-24T10:30:00Z | +| `declared_region` | [Nullable[components.BYOKKeyDeclaredRegion]](../components/byokkeydeclaredregion.mdx) | :heavy_check_mark: | Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. | null | +| `declared_zdr` | *Nullable[bool]* | :heavy_check_mark: | Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. | null | +| `disabled` | *bool* | :heavy_check_mark: | Whether this credential is currently disabled. | false | +| `id` | *str* | :heavy_check_mark: | Stable public identifier for this BYOK credential. | 11111111-2222-3333-4444-555555555555 | +| `is_byok_only` | *bool* | :heavy_check_mark: | Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. | false | +| `is_fallback` | *bool* | :heavy_check_mark: | Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried. Cannot be combined with `is_byok_only`. | false | +| `is_required` | *bool* | :heavy_check_mark: | Whether OpenRouter's shared endpoints on this provider are removed for the models this credential applies to (its `allowed_models`, or every model when `null`). Requests for those models run only on your keys; models outside the allowlist may still fall back to shared capacity on this provider. | false | +| `label` | *str* | :heavy_check_mark: | Short masked snippet of the key (e.g. the first/last few characters) used to identify it in the UI. | sk-...AbCd | +| `name` | *OptionalNullable[str]* | :heavy_minus_sign: | Optional human-readable name for the credential. | Production OpenAI Key | +| `provider` | [components.BYOKProviderSlug](../components/byokproviderslug.mdx) | :heavy_check_mark: | The upstream provider this credential authenticates against, as a lowercase slug (e.g. `openai`, `anthropic`, `amazon-bedrock`). | openai | +| `sort_order` | *int* | :heavy_check_mark: | Position within the provider — credentials are tried in ascending sort order. | 0 | +| `workspace_id` | *Nullable[str]* | :heavy_check_mark: | The workspace this credential is scoped to, or `null` when it is global — usable across every workspace in the account. A `null` value does not mean the default workspace. | 550e8400-e29b-41d4-a716-446655440000 | \ No newline at end of file diff --git a/docs/components/byokkeydeclaredregion.mdx b/docs/components/byokkeydeclaredregion.mdx new file mode 100644 index 00000000..94e38aed --- /dev/null +++ b/docs/components/byokkeydeclaredregion.mdx @@ -0,0 +1,23 @@ +--- +title: "BYOKKeyDeclaredRegion" +--- + +Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. + +## Example Usage + +```python +from openrouter.components import BYOKKeyDeclaredRegion + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: BYOKKeyDeclaredRegion = "global" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"global"` +- `"europe"` +- `"us"` diff --git a/docs/components/createbyokkeyrequest.mdx b/docs/components/createbyokkeyrequest.mdx index 95230b2a..360386f6 100644 --- a/docs/components/createbyokkeyrequest.mdx +++ b/docs/components/createbyokkeyrequest.mdx @@ -4,17 +4,18 @@ title: "CreateBYOKKeyRequest" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `allowed_api_key_hashes` | List[*str*] | :heavy_minus_sign: | Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. | [
"f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943"
] | -| `allowed_models` | List[*str*] | :heavy_minus_sign: | Optional allowlist of model slugs this credential may be used for. `null` means no restriction. | null | -| `allowed_user_ids` | List[*str*] | :heavy_minus_sign: | Optional allowlist of user IDs that may use this credential. `null` means no restriction. | null | -| `declared_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Defaults to `null`. | null | -| `disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential should be created in a disabled state. | false | -| `is_byok_only` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Defaults to `false`. | false | -| `is_fallback` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried. Cannot be combined with `is_byok_only`. | false | -| `is_required` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for the models this credential applies to (its `allowed_models`, or every model when `null`). Requests for those models run only on your keys; models outside the allowlist may still fall back to shared capacity on this provider. Defaults to `false`. | false | -| `key` | *str* | :heavy_check_mark: | The raw provider API key or credential. This value is encrypted at rest and never returned in API responses. | sk-proj-abc123... | -| `name` | *OptionalNullable[str]* | :heavy_minus_sign: | Optional human-readable name for the credential. | Production OpenAI Key | -| `provider` | [components.BYOKProviderSlug](../components/byokproviderslug.mdx) | :heavy_check_mark: | The upstream provider this credential authenticates against, as a lowercase slug (e.g. `openai`, `anthropic`, `amazon-bedrock`). | openai | -| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | Optional workspace ID to scope the credential to. When omitted, the credential is created in the account's default workspace; if that default has been deleted, the request returns a 400 and you must pass `workspace_id` explicitly. | 550e8400-e29b-41d4-a716-446655440000 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `allowed_api_key_hashes` | List[*str*] | :heavy_minus_sign: | Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. | [
"f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943"
] | +| `allowed_models` | List[*str*] | :heavy_minus_sign: | Optional allowlist of model slugs this credential may be used for. `null` means no restriction. | null | +| `allowed_user_ids` | List[*str*] | :heavy_minus_sign: | Optional allowlist of user IDs that may use this credential. `null` means no restriction. | null | +| `declared_region` | [OptionalNullable[components.CreateBYOKKeyRequestDeclaredRegion]](../components/createbyokkeyrequestdeclaredregion.mdx) | :heavy_minus_sign: | Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Defaults to the key's region for OpenAI and Fireworks, otherwise `null`. | null | +| `declared_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Defaults to `null`. | null | +| `disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential should be created in a disabled state. | false | +| `is_byok_only` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Defaults to `false`. | false | +| `is_fallback` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried. Cannot be combined with `is_byok_only`. | false | +| `is_required` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for the models this credential applies to (its `allowed_models`, or every model when `null`). Requests for those models run only on your keys; models outside the allowlist may still fall back to shared capacity on this provider. Defaults to `false`. | false | +| `key` | *str* | :heavy_check_mark: | The raw provider API key or credential. This value is encrypted at rest and never returned in API responses. | sk-proj-abc123... | +| `name` | *OptionalNullable[str]* | :heavy_minus_sign: | Optional human-readable name for the credential. | Production OpenAI Key | +| `provider` | [components.BYOKProviderSlug](../components/byokproviderslug.mdx) | :heavy_check_mark: | The upstream provider this credential authenticates against, as a lowercase slug (e.g. `openai`, `anthropic`, `amazon-bedrock`). | openai | +| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | Optional workspace ID to scope the credential to. When omitted, the credential is created in the account's default workspace; if that default has been deleted, the request returns a 400 and you must pass `workspace_id` explicitly. | 550e8400-e29b-41d4-a716-446655440000 | \ No newline at end of file diff --git a/docs/components/createbyokkeyrequestdeclaredregion.mdx b/docs/components/createbyokkeyrequestdeclaredregion.mdx new file mode 100644 index 00000000..eff58dc1 --- /dev/null +++ b/docs/components/createbyokkeyrequestdeclaredregion.mdx @@ -0,0 +1,23 @@ +--- +title: "CreateBYOKKeyRequestDeclaredRegion" +--- + +Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Defaults to the key's region for OpenAI and Fireworks, otherwise `null`. + +## Example Usage + +```python +from openrouter.components import CreateBYOKKeyRequestDeclaredRegion + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: CreateBYOKKeyRequestDeclaredRegion = "global" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"global"` +- `"europe"` +- `"us"` diff --git a/docs/components/createbyokkeyresponse.mdx b/docs/components/createbyokkeyresponse.mdx index 18d6a804..4da6fbee 100644 --- a/docs/components/createbyokkeyresponse.mdx +++ b/docs/components/createbyokkeyresponse.mdx @@ -4,6 +4,6 @@ title: "CreateBYOKKeyResponse" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `data` | [components.BYOKKey](../components/byokkey.mdx) | :heavy_check_mark: | N/A | \{
"allowed_api_key_hashes": null,
"allowed_models": null,
"allowed_user_ids": null,
"created_at": "2025-08-24T10:30:00Z",
"declared_zdr": null,
"disabled": false,
"id": "11111111-2222-3333-4444-555555555555",
"is_byok_only": false,
"is_fallback": false,
"is_required": false,
"label": "sk-...AbCd",
"name": "Production OpenAI Key",
"provider": "openai",
"sort_order": 0,
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `data` | [components.BYOKKey](../components/byokkey.mdx) | :heavy_check_mark: | N/A | \{
"allowed_api_key_hashes": null,
"allowed_models": null,
"allowed_user_ids": null,
"created_at": "2025-08-24T10:30:00Z",
"declared_region": null,
"declared_zdr": null,
"disabled": false,
"id": "11111111-2222-3333-4444-555555555555",
"is_byok_only": false,
"is_fallback": false,
"is_required": false,
"label": "sk-...AbCd",
"name": "Production OpenAI Key",
"provider": "openai",
"sort_order": 0,
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
} | \ No newline at end of file diff --git a/docs/components/getbyokkeyresponse.mdx b/docs/components/getbyokkeyresponse.mdx index 26ce72e6..30d5539c 100644 --- a/docs/components/getbyokkeyresponse.mdx +++ b/docs/components/getbyokkeyresponse.mdx @@ -4,6 +4,6 @@ title: "GetBYOKKeyResponse" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `data` | [components.BYOKKey](../components/byokkey.mdx) | :heavy_check_mark: | N/A | \{
"allowed_api_key_hashes": null,
"allowed_models": null,
"allowed_user_ids": null,
"created_at": "2025-08-24T10:30:00Z",
"declared_zdr": null,
"disabled": false,
"id": "11111111-2222-3333-4444-555555555555",
"is_byok_only": false,
"is_fallback": false,
"is_required": false,
"label": "sk-...AbCd",
"name": "Production OpenAI Key",
"provider": "openai",
"sort_order": 0,
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `data` | [components.BYOKKey](../components/byokkey.mdx) | :heavy_check_mark: | N/A | \{
"allowed_api_key_hashes": null,
"allowed_models": null,
"allowed_user_ids": null,
"created_at": "2025-08-24T10:30:00Z",
"declared_region": null,
"declared_zdr": null,
"disabled": false,
"id": "11111111-2222-3333-4444-555555555555",
"is_byok_only": false,
"is_fallback": false,
"is_required": false,
"label": "sk-...AbCd",
"name": "Production OpenAI Key",
"provider": "openai",
"sort_order": 0,
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
} | \ No newline at end of file diff --git a/docs/components/updatebyokkeyrequest.mdx b/docs/components/updatebyokkeyrequest.mdx index d496aaea..a9c7eb20 100644 --- a/docs/components/updatebyokkeyrequest.mdx +++ b/docs/components/updatebyokkeyrequest.mdx @@ -4,15 +4,16 @@ title: "UpdateBYOKKeyRequest" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `allowed_api_key_hashes` | List[*str*] | :heavy_minus_sign: | Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` clears the restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. | [
"f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943"
] | -| `allowed_models` | List[*str*] | :heavy_minus_sign: | Optional allowlist of model slugs this credential may be used for. `null` means no restriction. | null | -| `allowed_user_ids` | List[*str*] | :heavy_minus_sign: | Optional allowlist of user IDs that may use this credential. `null` means no restriction. | null | -| `declared_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Omit to leave the stored value unchanged; `null` clears the declaration. | null | -| `disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is disabled. | false | -| `is_byok_only` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Omit to leave the stored value unchanged. | false | -| `is_fallback` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried. Cannot be combined with `is_byok_only`. Omit to leave the stored value unchanged. | false | -| `is_required` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for the models this credential applies to (its `allowed_models`, or every model when `null`). Requests for those models run only on your keys; models outside the allowlist may still fall back to shared capacity on this provider. Omit to leave the stored value unchanged. | false | -| `key` | *Optional[str]* | :heavy_minus_sign: | A new raw provider API key to rotate the credential in-place. The previous key material is overwritten and the masked label is regenerated. Encrypted at rest and never returned in API responses. | sk-proj-newkey456... | -| `name` | *OptionalNullable[str]* | :heavy_minus_sign: | Optional human-readable name for the credential. | Updated OpenAI Key | \ No newline at end of file +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `allowed_api_key_hashes` | List[*str*] | :heavy_minus_sign: | Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` clears the restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. | [
"f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943"
] | +| `allowed_models` | List[*str*] | :heavy_minus_sign: | Optional allowlist of model slugs this credential may be used for. `null` means no restriction. | null | +| `allowed_user_ids` | List[*str*] | :heavy_minus_sign: | Optional allowlist of user IDs that may use this credential. `null` means no restriction. | null | +| `declared_region` | [OptionalNullable[components.UpdateBYOKKeyRequestDeclaredRegion]](../components/updatebyokkeyrequestdeclaredregion.mdx) | :heavy_minus_sign: | Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Omit to leave the stored value unchanged (rotating an OpenAI or Fireworks `key` re-derives it from the new key); `null` clears the declaration. | null | +| `declared_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Omit to leave the stored value unchanged; `null` clears the declaration. | null | +| `disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is disabled. | false | +| `is_byok_only` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Omit to leave the stored value unchanged. | false | +| `is_fallback` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried. Cannot be combined with `is_byok_only`. Omit to leave the stored value unchanged. | false | +| `is_required` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for the models this credential applies to (its `allowed_models`, or every model when `null`). Requests for those models run only on your keys; models outside the allowlist may still fall back to shared capacity on this provider. Omit to leave the stored value unchanged. | false | +| `key` | *Optional[str]* | :heavy_minus_sign: | A new raw provider API key to rotate the credential in-place. The previous key material is overwritten and the masked label is regenerated. Encrypted at rest and never returned in API responses. | sk-proj-newkey456... | +| `name` | *OptionalNullable[str]* | :heavy_minus_sign: | Optional human-readable name for the credential. | Updated OpenAI Key | \ No newline at end of file diff --git a/docs/components/updatebyokkeyrequestdeclaredregion.mdx b/docs/components/updatebyokkeyrequestdeclaredregion.mdx new file mode 100644 index 00000000..ad71341b --- /dev/null +++ b/docs/components/updatebyokkeyrequestdeclaredregion.mdx @@ -0,0 +1,23 @@ +--- +title: "UpdateBYOKKeyRequestDeclaredRegion" +--- + +Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Omit to leave the stored value unchanged (rotating an OpenAI or Fireworks `key` re-derives it from the new key); `null` clears the declaration. + +## Example Usage + +```python +from openrouter.components import UpdateBYOKKeyRequestDeclaredRegion + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: UpdateBYOKKeyRequestDeclaredRegion = "global" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"global"` +- `"europe"` +- `"us"` diff --git a/docs/components/updatebyokkeyresponse.mdx b/docs/components/updatebyokkeyresponse.mdx index cad8d3e6..b1eafbef 100644 --- a/docs/components/updatebyokkeyresponse.mdx +++ b/docs/components/updatebyokkeyresponse.mdx @@ -4,6 +4,6 @@ title: "UpdateBYOKKeyResponse" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `data` | [components.BYOKKey](../components/byokkey.mdx) | :heavy_check_mark: | N/A | \{
"allowed_api_key_hashes": null,
"allowed_models": null,
"allowed_user_ids": null,
"created_at": "2025-08-24T10:30:00Z",
"declared_zdr": null,
"disabled": false,
"id": "11111111-2222-3333-4444-555555555555",
"is_byok_only": false,
"is_fallback": false,
"is_required": false,
"label": "sk-...AbCd",
"name": "Production OpenAI Key",
"provider": "openai",
"sort_order": 0,
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `data` | [components.BYOKKey](../components/byokkey.mdx) | :heavy_check_mark: | N/A | \{
"allowed_api_key_hashes": null,
"allowed_models": null,
"allowed_user_ids": null,
"created_at": "2025-08-24T10:30:00Z",
"declared_region": null,
"declared_zdr": null,
"disabled": false,
"id": "11111111-2222-3333-4444-555555555555",
"is_byok_only": false,
"is_fallback": false,
"is_required": false,
"label": "sk-...AbCd",
"name": "Production OpenAI Key",
"provider": "openai",
"sort_order": 0,
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
} | \ No newline at end of file diff --git a/docs/operations/listbyokkeysresponse.mdx b/docs/operations/listbyokkeysresponse.mdx index 24f7bad2..e1615dcb 100644 --- a/docs/operations/listbyokkeysresponse.mdx +++ b/docs/operations/listbyokkeysresponse.mdx @@ -4,6 +4,6 @@ title: "ListBYOKKeysResponse" ## Fields -| Field | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `result` | [components.ListBYOKKeysResponse](../components/listbyokkeysresponse.mdx) | :heavy_check_mark: | N/A | \{
"data": [
\{
"allowed_api_key_hashes": null,
"allowed_models": null,
"allowed_user_ids": null,
"created_at": "2025-08-24T10:30:00Z",
"declared_zdr": null,
"disabled": false,
"id": "11111111-2222-3333-4444-555555555555",
"is_byok_only": false,
"is_fallback": false,
"is_required": false,
"label": "sk-...AbCd",
"name": "Production OpenAI Key",
"provider": "openai",
"sort_order": 0,
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
}
],
"total_count": 1
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `result` | [components.ListBYOKKeysResponse](../components/listbyokkeysresponse.mdx) | :heavy_check_mark: | N/A | \{
"data": [
\{
"allowed_api_key_hashes": null,
"allowed_models": null,
"allowed_user_ids": null,
"created_at": "2025-08-24T10:30:00Z",
"declared_region": null,
"declared_zdr": null,
"disabled": false,
"id": "11111111-2222-3333-4444-555555555555",
"is_byok_only": false,
"is_fallback": false,
"is_required": false,
"label": "sk-...AbCd",
"name": "Production OpenAI Key",
"provider": "openai",
"sort_order": 0,
"workspace_id": "550e8400-e29b-41d4-a716-446655440000"
}
],
"total_count": 1
} | \ No newline at end of file diff --git a/docs/sdks/byok/README.mdx b/docs/sdks/byok/README.mdx index 9326d7d1..d159c8b2 100644 --- a/docs/sdks/byok/README.mdx +++ b/docs/sdks/byok/README.mdx @@ -95,24 +95,25 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `key` | *str* | :heavy_check_mark: | The raw provider API key or credential. This value is encrypted at rest and never returned in API responses. | sk-proj-abc123... | -| `provider` | [components.BYOKProviderSlug](../../components/byokproviderslug.mdx) | :heavy_check_mark: | The upstream provider this credential authenticates against, as a lowercase slug (e.g. `openai`, `anthropic`, `amazon-bedrock`). | openai | -| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `allowed_api_key_hashes` | List[*str*] | :heavy_minus_sign: | Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. | [
"f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943"
] | -| `allowed_models` | List[*str*] | :heavy_minus_sign: | Optional allowlist of model slugs this credential may be used for. `null` means no restriction. | null | -| `allowed_user_ids` | List[*str*] | :heavy_minus_sign: | Optional allowlist of user IDs that may use this credential. `null` means no restriction. | null | -| `declared_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Defaults to `null`. | null | -| `disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential should be created in a disabled state. | false | -| `is_byok_only` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Defaults to `false`. | false | -| `is_fallback` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried. Cannot be combined with `is_byok_only`. | false | -| `is_required` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for the models this credential applies to (its `allowed_models`, or every model when `null`). Requests for those models run only on your keys; models outside the allowlist may still fall back to shared capacity on this provider. Defaults to `false`. | false | -| `name` | *OptionalNullable[str]* | :heavy_minus_sign: | Optional human-readable name for the credential. | Production OpenAI Key | -| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | Optional workspace ID to scope the credential to. When omitted, the credential is created in the account's default workspace; if that default has been deleted, the request returns a 400 and you must pass `workspace_id` explicitly. | 550e8400-e29b-41d4-a716-446655440000 | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `key` | *str* | :heavy_check_mark: | The raw provider API key or credential. This value is encrypted at rest and never returned in API responses. | sk-proj-abc123... | +| `provider` | [components.BYOKProviderSlug](../../components/byokproviderslug.mdx) | :heavy_check_mark: | The upstream provider this credential authenticates against, as a lowercase slug (e.g. `openai`, `anthropic`, `amazon-bedrock`). | openai | +| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `allowed_api_key_hashes` | List[*str*] | :heavy_minus_sign: | Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. | [
"f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943"
] | +| `allowed_models` | List[*str*] | :heavy_minus_sign: | Optional allowlist of model slugs this credential may be used for. `null` means no restriction. | null | +| `allowed_user_ids` | List[*str*] | :heavy_minus_sign: | Optional allowlist of user IDs that may use this credential. `null` means no restriction. | null | +| `declared_region` | [OptionalNullable[components.CreateBYOKKeyRequestDeclaredRegion]](../../components/createbyokkeyrequestdeclaredregion.mdx) | :heavy_minus_sign: | Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Defaults to the key's region for OpenAI and Fireworks, otherwise `null`. | null | +| `declared_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Defaults to `null`. | null | +| `disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential should be created in a disabled state. | false | +| `is_byok_only` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Defaults to `false`. | false | +| `is_fallback` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried. Cannot be combined with `is_byok_only`. | false | +| `is_required` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for the models this credential applies to (its `allowed_models`, or every model when `null`). Requests for those models run only on your keys; models outside the allowlist may still fall back to shared capacity on this provider. Defaults to `false`. | false | +| `name` | *OptionalNullable[str]* | :heavy_minus_sign: | Optional human-readable name for the credential. | Production OpenAI Key | +| `workspace_id` | *Optional[str]* | :heavy_minus_sign: | Optional workspace ID to scope the credential to. When omitted, the credential is created in the account's default workspace; if that default has been deleted, the request returns a 400 and you must pass `workspace_id` explicitly. | 550e8400-e29b-41d4-a716-446655440000 | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | ### Response @@ -251,23 +252,24 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `id` | *str* | :heavy_check_mark: | The BYOK credential ID (UUID). | 11111111-2222-3333-4444-555555555555 | -| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `allowed_api_key_hashes` | List[*str*] | :heavy_minus_sign: | Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` clears the restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. | [
"f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943"
] | -| `allowed_models` | List[*str*] | :heavy_minus_sign: | Optional allowlist of model slugs this credential may be used for. `null` means no restriction. | null | -| `allowed_user_ids` | List[*str*] | :heavy_minus_sign: | Optional allowlist of user IDs that may use this credential. `null` means no restriction. | null | -| `declared_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Omit to leave the stored value unchanged; `null` clears the declaration. | null | -| `disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is disabled. | false | -| `is_byok_only` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Omit to leave the stored value unchanged. | false | -| `is_fallback` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried. Cannot be combined with `is_byok_only`. Omit to leave the stored value unchanged. | false | -| `is_required` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for the models this credential applies to (its `allowed_models`, or every model when `null`). Requests for those models run only on your keys; models outside the allowlist may still fall back to shared capacity on this provider. Omit to leave the stored value unchanged. | false | -| `key` | *Optional[str]* | :heavy_minus_sign: | A new raw provider API key to rotate the credential in-place. The previous key material is overwritten and the masked label is regenerated. Encrypted at rest and never returned in API responses. | sk-proj-newkey456... | -| `name` | *OptionalNullable[str]* | :heavy_minus_sign: | Optional human-readable name for the credential. | Updated OpenAI Key | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *str* | :heavy_check_mark: | The BYOK credential ID (UUID). | 11111111-2222-3333-4444-555555555555 | +| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `allowed_api_key_hashes` | List[*str*] | :heavy_minus_sign: | Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` clears the restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. | [
"f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943"
] | +| `allowed_models` | List[*str*] | :heavy_minus_sign: | Optional allowlist of model slugs this credential may be used for. `null` means no restriction. | null | +| `allowed_user_ids` | List[*str*] | :heavy_minus_sign: | Optional allowlist of user IDs that may use this credential. `null` means no restriction. | null | +| `declared_region` | [OptionalNullable[components.UpdateBYOKKeyRequestDeclaredRegion]](../../components/updatebyokkeyrequestdeclaredregion.mdx) | :heavy_minus_sign: | Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{"api_key": ..., "region": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Omit to leave the stored value unchanged (rotating an OpenAI or Fireworks `key` re-derives it from the new key); `null` clears the declaration. | null | +| `declared_zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Omit to leave the stored value unchanged; `null` clears the declaration. | null | +| `disabled` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is disabled. | false | +| `is_byok_only` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Omit to leave the stored value unchanged. | false | +| `is_fallback` | *Optional[bool]* | :heavy_minus_sign: | Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried. Cannot be combined with `is_byok_only`. Omit to leave the stored value unchanged. | false | +| `is_required` | *Optional[bool]* | :heavy_minus_sign: | Whether OpenRouter's shared endpoints on this provider are removed for the models this credential applies to (its `allowed_models`, or every model when `null`). Requests for those models run only on your keys; models outside the allowlist may still fall back to shared capacity on this provider. Omit to leave the stored value unchanged. | false | +| `key` | *Optional[str]* | :heavy_minus_sign: | A new raw provider API key to rotate the credential in-place. The previous key material is overwritten and the masked label is regenerated. Encrypted at rest and never returned in API responses. | sk-proj-newkey456... | +| `name` | *OptionalNullable[str]* | :heavy_minus_sign: | Optional human-readable name for the credential. | Updated OpenAI Key | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | ### Response @@ -281,5 +283,6 @@ with OpenRouter( | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | +| errors.ConflictResponseError | 409 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 971d2d13..62bbb0ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.23" +version = "1.3.24" 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 59786ba2..de35bd4c 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.23" +__version__: str = "1.3.24" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.914.0" -__user_agent__: str = "speakeasy-sdk/python 1.3.23 2.914.0 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.24 2.914.0 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/byok.py b/src/openrouter/byok.py index 2cc6ba13..2737b2e2 100644 --- a/src/openrouter/byok.py +++ b/src/openrouter/byok.py @@ -369,6 +369,9 @@ def create( allowed_api_key_hashes: OptionalNullable[Iterable[str]] = UNSET, allowed_models: OptionalNullable[Iterable[str]] = UNSET, allowed_user_ids: OptionalNullable[Iterable[str]] = UNSET, + declared_region: OptionalNullable[ + components.CreateBYOKKeyRequestDeclaredRegion + ] = UNSET, declared_zdr: OptionalNullable[bool] = UNSET, disabled: Optional[bool] = None, is_byok_only: Optional[bool] = None, @@ -397,6 +400,7 @@ def create( :param allowed_api_key_hashes: Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. :param allowed_models: Optional allowlist of model slugs this credential may be used for. `null` means no restriction. :param allowed_user_ids: Optional allowlist of user IDs that may use this credential. `null` means no restriction. + :param declared_region: Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Defaults to the key's region for OpenAI and Fireworks, otherwise `null`. :param declared_zdr: Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Defaults to `null`. :param disabled: Whether this credential should be created in a disabled state. :param is_byok_only: Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Defaults to `false`. @@ -433,6 +437,7 @@ def create( allowed_user_ids=utils.unmarshal( allowed_user_ids, OptionalNullable[List[str]] ), + declared_region=declared_region, declared_zdr=declared_zdr, disabled=disabled, is_byok_only=is_byok_only, @@ -550,6 +555,9 @@ async def create_async( allowed_api_key_hashes: OptionalNullable[Iterable[str]] = UNSET, allowed_models: OptionalNullable[Iterable[str]] = UNSET, allowed_user_ids: OptionalNullable[Iterable[str]] = UNSET, + declared_region: OptionalNullable[ + components.CreateBYOKKeyRequestDeclaredRegion + ] = UNSET, declared_zdr: OptionalNullable[bool] = UNSET, disabled: Optional[bool] = None, is_byok_only: Optional[bool] = None, @@ -578,6 +586,7 @@ async def create_async( :param allowed_api_key_hashes: Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. :param allowed_models: Optional allowlist of model slugs this credential may be used for. `null` means no restriction. :param allowed_user_ids: Optional allowlist of user IDs that may use this credential. `null` means no restriction. + :param declared_region: Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Defaults to the key's region for OpenAI and Fireworks, otherwise `null`. :param declared_zdr: Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Defaults to `null`. :param disabled: Whether this credential should be created in a disabled state. :param is_byok_only: Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Defaults to `false`. @@ -614,6 +623,7 @@ async def create_async( allowed_user_ids=utils.unmarshal( allowed_user_ids, OptionalNullable[List[str]] ), + declared_region=declared_region, declared_zdr=declared_zdr, disabled=disabled, is_byok_only=is_byok_only, @@ -1242,6 +1252,9 @@ def update( allowed_api_key_hashes: OptionalNullable[Iterable[str]] = UNSET, allowed_models: OptionalNullable[Iterable[str]] = UNSET, allowed_user_ids: OptionalNullable[Iterable[str]] = UNSET, + declared_region: OptionalNullable[ + components.UpdateBYOKKeyRequestDeclaredRegion + ] = UNSET, declared_zdr: OptionalNullable[bool] = UNSET, disabled: Optional[bool] = None, is_byok_only: Optional[bool] = None, @@ -1269,6 +1282,7 @@ def update( :param allowed_api_key_hashes: Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` clears the restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. :param allowed_models: Optional allowlist of model slugs this credential may be used for. `null` means no restriction. :param allowed_user_ids: Optional allowlist of user IDs that may use this credential. `null` means no restriction. + :param declared_region: Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Omit to leave the stored value unchanged (rotating an OpenAI or Fireworks `key` re-derives it from the new key); `null` clears the declaration. :param declared_zdr: Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Omit to leave the stored value unchanged; `null` clears the declaration. :param disabled: Whether this credential is disabled. :param is_byok_only: Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Omit to leave the stored value unchanged. @@ -1306,6 +1320,7 @@ def update( allowed_user_ids=utils.unmarshal( allowed_user_ids, OptionalNullable[List[str]] ), + declared_region=declared_region, declared_zdr=declared_zdr, disabled=disabled, is_byok_only=is_byok_only, @@ -1397,6 +1412,11 @@ def update( errors.NotFoundResponseErrorData, http_res ) raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) if utils.match_response(http_res, "500", "application/json"): response_data = unmarshal_json_response( errors.InternalServerResponseErrorData, http_res @@ -1425,6 +1445,9 @@ async def update_async( allowed_api_key_hashes: OptionalNullable[Iterable[str]] = UNSET, allowed_models: OptionalNullable[Iterable[str]] = UNSET, allowed_user_ids: OptionalNullable[Iterable[str]] = UNSET, + declared_region: OptionalNullable[ + components.UpdateBYOKKeyRequestDeclaredRegion + ] = UNSET, declared_zdr: OptionalNullable[bool] = UNSET, disabled: Optional[bool] = None, is_byok_only: Optional[bool] = None, @@ -1452,6 +1475,7 @@ async def update_async( :param allowed_api_key_hashes: Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` clears the restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400. :param allowed_models: Optional allowlist of model slugs this credential may be used for. `null` means no restriction. :param allowed_user_ids: Optional allowlist of user IDs that may use this credential. `null` means no restriction. + :param declared_region: Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Omit to leave the stored value unchanged (rotating an OpenAI or Fireworks `key` re-derives it from the new key); `null` clears the declaration. :param declared_zdr: Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Omit to leave the stored value unchanged; `null` clears the declaration. :param disabled: Whether this credential is disabled. :param is_byok_only: Whether OpenRouter's shared endpoints on this provider are removed for every model, including models outside `allowed_models` and after all of your keys for the provider fail. The provider is skipped instead of spending OpenRouter credits. Only valid on non-fallback credentials. Omit to leave the stored value unchanged. @@ -1489,6 +1513,7 @@ async def update_async( allowed_user_ids=utils.unmarshal( allowed_user_ids, OptionalNullable[List[str]] ), + declared_region=declared_region, declared_zdr=declared_zdr, disabled=disabled, is_byok_only=is_byok_only, @@ -1580,6 +1605,11 @@ async def update_async( errors.NotFoundResponseErrorData, http_res ) raise errors.NotFoundResponseError(response_data, http_res) + if utils.match_response(http_res, "409", "application/json"): + response_data = unmarshal_json_response( + errors.ConflictResponseErrorData, http_res + ) + raise errors.ConflictResponseError(response_data, http_res) if utils.match_response(http_res, "500", "application/json"): response_data = unmarshal_json_response( errors.InternalServerResponseErrorData, http_res diff --git a/src/openrouter/components/__init__.py b/src/openrouter/components/__init__.py index bc6c75f4..2e45778d 100644 --- a/src/openrouter/components/__init__.py +++ b/src/openrouter/components/__init__.py @@ -964,7 +964,7 @@ BulkUnassignMembersResponse, BulkUnassignMembersResponseTypedDict, ) - from .byokkey import BYOKKey, BYOKKeyTypedDict + from .byokkey import BYOKKey, BYOKKeyDeclaredRegion, BYOKKeyTypedDict from .byokproviderslug import BYOKProviderSlug from .capabilitydescriptor import ( CapabilityDescriptor, @@ -1400,6 +1400,7 @@ from .costdetails import CostDetails, CostDetailsTypedDict from .createbyokkeyrequest import ( CreateBYOKKeyRequest, + CreateBYOKKeyRequestDeclaredRegion, CreateBYOKKeyRequestTypedDict, ) from .createbyokkeyresponse import ( @@ -4106,6 +4107,7 @@ ) from .updatebyokkeyrequest import ( UpdateBYOKKeyRequest, + UpdateBYOKKeyRequestDeclaredRegion, UpdateBYOKKeyRequestTypedDict, ) from .updatebyokkeyresponse import ( @@ -4775,6 +4777,7 @@ "AutoRouterPluginTypedDict", "BYOK", "BYOKKey", + "BYOKKeyDeclaredRegion", "BYOKKeyTypedDict", "BYOKProviderSlug", "BadGatewayResponseErrorData", @@ -5291,6 +5294,7 @@ "CostDetails", "CostDetailsTypedDict", "CreateBYOKKeyRequest", + "CreateBYOKKeyRequestDeclaredRegion", "CreateBYOKKeyRequestTypedDict", "CreateBYOKKeyResponse", "CreateBYOKKeyResponseTypedDict", @@ -7323,6 +7327,7 @@ "UnprocessableEntityResponseErrorData", "UnprocessableEntityResponseErrorDataTypedDict", "UpdateBYOKKeyRequest", + "UpdateBYOKKeyRequestDeclaredRegion", "UpdateBYOKKeyRequestTypedDict", "UpdateBYOKKeyResponse", "UpdateBYOKKeyResponseTypedDict", @@ -8157,6 +8162,7 @@ "BulkUnassignMembersResponse": ".bulkunassignmembersresponse", "BulkUnassignMembersResponseTypedDict": ".bulkunassignmembersresponse", "BYOKKey": ".byokkey", + "BYOKKeyDeclaredRegion": ".byokkey", "BYOKKeyTypedDict": ".byokkey", "BYOKProviderSlug": ".byokproviderslug", "CapabilityDescriptor": ".capabilitydescriptor", @@ -8465,6 +8471,7 @@ "CostDetails": ".costdetails", "CostDetailsTypedDict": ".costdetails", "CreateBYOKKeyRequest": ".createbyokkeyrequest", + "CreateBYOKKeyRequestDeclaredRegion": ".createbyokkeyrequest", "CreateBYOKKeyRequestTypedDict": ".createbyokkeyrequest", "CreateBYOKKeyResponse": ".createbyokkeyresponse", "CreateBYOKKeyResponseTypedDict": ".createbyokkeyresponse", @@ -10480,6 +10487,7 @@ "UnprocessableEntityResponseErrorData": ".unprocessableentityresponseerrordata", "UnprocessableEntityResponseErrorDataTypedDict": ".unprocessableentityresponseerrordata", "UpdateBYOKKeyRequest": ".updatebyokkeyrequest", + "UpdateBYOKKeyRequestDeclaredRegion": ".updatebyokkeyrequest", "UpdateBYOKKeyRequestTypedDict": ".updatebyokkeyrequest", "UpdateBYOKKeyResponse": ".updatebyokkeyresponse", "UpdateBYOKKeyResponseTypedDict": ".updatebyokkeyresponse", diff --git a/src/openrouter/components/byokkey.py b/src/openrouter/components/byokkey.py index 22f7dfea..ca0fc8b6 100644 --- a/src/openrouter/components/byokkey.py +++ b/src/openrouter/components/byokkey.py @@ -8,12 +8,24 @@ OptionalNullable, UNSET, UNSET_SENTINEL, + UnrecognizedStr, ) from pydantic import model_serializer -from typing import List +from typing import List, Literal, Union from typing_extensions import NotRequired, TypedDict +BYOKKeyDeclaredRegion = Union[ + Literal[ + "global", + "europe", + "us", + ], + UnrecognizedStr, +] +r"""Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`.""" + + class BYOKKeyTypedDict(TypedDict): allowed_api_key_hashes: Nullable[List[str]] r"""Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` means no restriction.""" @@ -23,6 +35,8 @@ class BYOKKeyTypedDict(TypedDict): r"""Optional allowlist of user IDs that may use this credential. `null` means no restriction.""" created_at: str r"""ISO timestamp of when the credential was created.""" + declared_region: Nullable[BYOKKeyDeclaredRegion] + r"""Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`.""" declared_zdr: Nullable[bool] r"""Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter.""" disabled: bool @@ -60,6 +74,9 @@ class BYOKKey(BaseModel): created_at: str r"""ISO timestamp of when the credential was created.""" + declared_region: Nullable[BYOKKeyDeclaredRegion] + r"""Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`.""" + declared_zdr: Nullable[bool] r"""Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter.""" @@ -101,6 +118,7 @@ def serialize_model(self, handler): "allowed_api_key_hashes", "allowed_models", "allowed_user_ids", + "declared_region", "declared_zdr", "name", "workspace_id", diff --git a/src/openrouter/components/createbyokkeyrequest.py b/src/openrouter/components/createbyokkeyrequest.py index 593ecbdc..776ff309 100644 --- a/src/openrouter/components/createbyokkeyrequest.py +++ b/src/openrouter/components/createbyokkeyrequest.py @@ -8,12 +8,24 @@ OptionalNullable, UNSET, UNSET_SENTINEL, + UnrecognizedStr, ) from pydantic import model_serializer -from typing import List, Optional +from typing import List, Literal, Optional, Union from typing_extensions import NotRequired, TypedDict +CreateBYOKKeyRequestDeclaredRegion = Union[ + Literal[ + "global", + "europe", + "us", + ], + UnrecognizedStr, +] +r"""Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Defaults to the key's region for OpenAI and Fireworks, otherwise `null`.""" + + class CreateBYOKKeyRequestTypedDict(TypedDict): key: str r"""The raw provider API key or credential. This value is encrypted at rest and never returned in API responses.""" @@ -25,6 +37,8 @@ class CreateBYOKKeyRequestTypedDict(TypedDict): r"""Optional allowlist of model slugs this credential may be used for. `null` means no restriction.""" allowed_user_ids: NotRequired[Nullable[List[str]]] r"""Optional allowlist of user IDs that may use this credential. `null` means no restriction.""" + declared_region: NotRequired[Nullable[CreateBYOKKeyRequestDeclaredRegion]] + r"""Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Defaults to the key's region for OpenAI and Fireworks, otherwise `null`.""" declared_zdr: NotRequired[Nullable[bool]] r"""Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Defaults to `null`.""" disabled: NotRequired[bool] @@ -57,6 +71,9 @@ class CreateBYOKKeyRequest(BaseModel): allowed_user_ids: OptionalNullable[List[str]] = UNSET r"""Optional allowlist of user IDs that may use this credential. `null` means no restriction.""" + declared_region: OptionalNullable[CreateBYOKKeyRequestDeclaredRegion] = UNSET + r"""Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Defaults to the key's region for OpenAI and Fireworks, otherwise `null`.""" + declared_zdr: OptionalNullable[bool] = UNSET r"""Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Defaults to `null`.""" @@ -85,6 +102,7 @@ def serialize_model(self, handler): "allowed_api_key_hashes", "allowed_models", "allowed_user_ids", + "declared_region", "declared_zdr", "disabled", "is_byok_only", @@ -99,6 +117,7 @@ def serialize_model(self, handler): "allowed_api_key_hashes", "allowed_models", "allowed_user_ids", + "declared_region", "declared_zdr", "name", ] diff --git a/src/openrouter/components/updatebyokkeyrequest.py b/src/openrouter/components/updatebyokkeyrequest.py index c2b4fb7d..a1ac5e5c 100644 --- a/src/openrouter/components/updatebyokkeyrequest.py +++ b/src/openrouter/components/updatebyokkeyrequest.py @@ -7,12 +7,24 @@ OptionalNullable, UNSET, UNSET_SENTINEL, + UnrecognizedStr, ) from pydantic import model_serializer -from typing import List, Optional +from typing import List, Literal, Optional, Union from typing_extensions import NotRequired, TypedDict +UpdateBYOKKeyRequestDeclaredRegion = Union[ + Literal[ + "global", + "europe", + "us", + ], + UnrecognizedStr, +] +r"""Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Omit to leave the stored value unchanged (rotating an OpenAI or Fireworks `key` re-derives it from the new key); `null` clears the declaration.""" + + class UpdateBYOKKeyRequestTypedDict(TypedDict): allowed_api_key_hashes: NotRequired[Nullable[List[str]]] r"""Optional allowlist of OpenRouter API key hashes (`api_keys.hash`) that may use this credential. `null` clears the restriction. Must contain at least one hash if provided. Hashes that do not belong to your account return a 400.""" @@ -20,6 +32,8 @@ class UpdateBYOKKeyRequestTypedDict(TypedDict): r"""Optional allowlist of model slugs this credential may be used for. `null` means no restriction.""" allowed_user_ids: NotRequired[Nullable[List[str]]] r"""Optional allowlist of user IDs that may use this credential. `null` means no restriction.""" + declared_region: NotRequired[Nullable[UpdateBYOKKeyRequestDeclaredRegion]] + r"""Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Omit to leave the stored value unchanged (rotating an OpenAI or Fireworks `key` re-derives it from the new key); `null` clears the declaration.""" declared_zdr: NotRequired[Nullable[bool]] r"""Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Omit to leave the stored value unchanged; `null` clears the declaration.""" disabled: NotRequired[bool] @@ -46,6 +60,9 @@ class UpdateBYOKKeyRequest(BaseModel): allowed_user_ids: OptionalNullable[List[str]] = UNSET r"""Optional allowlist of user IDs that may use this credential. `null` means no restriction.""" + declared_region: OptionalNullable[UpdateBYOKKeyRequestDeclaredRegion] = UNSET + r"""Your declaration of the data region in which the upstream provider account behind this credential processes requests, used for routing eligibility on OpenRouter's regional hosts. `null` means undeclared and `global` is behaviorally identical: the credential follows the region OpenRouter records for the endpoint. `europe` or `us` lets requests to `eu.openrouter.ai` or `us.openrouter.ai` use this credential for that provider (private endpoints, endpoints pinned to another cloud region, cross-region inference profiles and video models are excluded). Self-declared and not verified by OpenRouter. For OpenAI and Fireworks the region comes from the key material (a `{\"api_key\": ..., \"region\": ...}` key), so the value must match the key's region. Among other providers, only Azure accepts `europe` or `us`. Omit to leave the stored value unchanged (rotating an OpenAI or Fireworks `key` re-derives it from the new key); `null` clears the declaration.""" + declared_zdr: OptionalNullable[bool] = UNSET r"""Your declaration of whether the upstream provider account behind this credential has zero data retention (ZDR). `null` inherits OpenRouter's data policy for the provider's endpoint; `true` declares the account ZDR so requests that require ZDR may route to this credential even when the shared endpoint retains data; `false` declares it non-ZDR so such requests never route to it. Self-declared and not verified by OpenRouter. Omit to leave the stored value unchanged; `null` clears the declaration.""" @@ -74,6 +91,7 @@ def serialize_model(self, handler): "allowed_api_key_hashes", "allowed_models", "allowed_user_ids", + "declared_region", "declared_zdr", "disabled", "is_byok_only", @@ -88,6 +106,7 @@ def serialize_model(self, handler): "allowed_api_key_hashes", "allowed_models", "allowed_user_ids", + "declared_region", "declared_zdr", "name", ] diff --git a/uv.lock b/uv.lock index 581e7dc0..97a11cdb 100644 --- a/uv.lock +++ b/uv.lock @@ -213,7 +213,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.23" +version = "1.3.24" source = { editable = "." } dependencies = [ { name = "httpcore" }, From 5fc0629ea65a6636b4732f406062f8a9c25f4eb3 Mon Sep 17 00:00:00 2001 From: "speakeasy-github[bot]" <128539517+speakeasy-github[bot]@users.noreply.github.com> Date: Tue, 6 Oct 2026 13:47:37 +0000 Subject: [PATCH 2/2] empty commit to trigger [run-tests] workflow