Skip to content

Commit 2a404c7

Browse files
authored
fix(anthropic): support bearer key auth for gateways (#595)
* fix(anthropic): honor bearer key auth for gateway models Use apiKeyTransport when building Anthropic key-auth requests and normalize Anthropic model discovery URLs so /v1 base URLs do not become /v1/v1/models. * fix(auth): propagate anthropic key transport to validation Carry apiKeyTransport through key-login provider derivation and use the same bearer vs x-api-key selection during Anthropic API-key validation. * fix(anthropic): expose bearer key auth setup * fix(gui): add Russian auth transport labels
1 parent 285e2bf commit 2a404c7

41 files changed

Lines changed: 300 additions & 33 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs-site/src/content/docs/ja/reference/adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ interface ProviderAdapter {
4545
## `anthropic`
4646

4747
**対象:** Anthropic **Messages**`/v1/messages`)。
48-
**認証:** `key``x-api-key`)または `oauth`(Bearer + `anthropic-beta`、Claude Pro/Max 用)。
48+
**認証:** `key`デフォルトは `x-api-key`、または `apiKeyTransport: "bearer"` による `Authorization: Bearer`)または `oauth`(Bearer + `anthropic-beta`、Claude Pro/Max 用)。
4949

5050
- メッセージを Anthropic content block(text、base64 image、`tool_use``thinking`)に変換します。
5151
- **Extended thinking の計算:** Anthropic は `max_tokens > thinking.budget_tokens` を要求します。

docs-site/src/content/docs/ja/reference/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ token の代わりに使えます。すべての候補は timing side channel
136136
| `responsesPath?` | `string` | `key` 認証の `openai-responses` リクエストに使う任意の相対 resource path。`/` で始め、URL scheme、query、fragment を含めてはいけません。省略時は従来の `/v1/responses` URL 構築を維持します。 |
137137
| `disabled?` | `boolean` | 設定はディスクに残すがルーティングとモデル/カタログ一覧から除外します。 |
138138
| `apiKey?` | `string` | API キーまたはリクエスト時に解釈する `${ENV_VAR}` / `$ENV_VAR` 参照。 |
139+
| `apiKeyTransport?` | `"x-api-key" \| "bearer"` | Anthropic API キーのヘッダー方式。デフォルトはネイティブの `x-api-key` です。`Authorization: Bearer <key>` が必要な互換 gateway では `"bearer"` を設定します。key 認証の `anthropic` プロバイダーでのみ有効です。 |
139140
| `apiKeyPool?` | `ApiKeyPoolEntry[]` | 複数キーを納める pool。`apiKey` はアクティブ項目を反映します。各項目には `id``key`、選択 `label`、選択数値 `addedAt` があります。 |
140141
| `defaultModel?` | `string` | 明示的なモデルなしでこのプロバイダーを選んだときに使うモデル。 |
141142
| `models?` | `string[]` | seed/fallback モデル一覧。`liveModels``false` ならここにあるモデルだけが発見されます。 |

docs-site/src/content/docs/ko/reference/adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ interface ProviderAdapter {
5454
## `anthropic`
5555

5656
**대상:** Anthropic **Messages**(`/v1/messages`).
57-
**인증:** `key`(`x-api-key`) 또는 `oauth`(Bearer + `anthropic-beta`, Claude Pro/Max용).
57+
**인증:** `key`(기본 `x-api-key`, 또는 `apiKeyTransport: "bearer"` 설정 시 `Authorization: Bearer`) 또는 `oauth`(Bearer + `anthropic-beta`, Claude Pro/Max용).
5858

5959
- 메시지를 Anthropic content block(text, base64 image, `tool_use`, `thinking`)으로 변환합니다.
6060
- **Extended thinking 계산:** Anthropic은 `max_tokens > thinking.budget_tokens`를 요구합니다.

docs-site/src/content/docs/ko/reference/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ token 대신 쓸 수 있습니다. 모든 후보는 timing side channel을 막
139139
| `responsesPath?` | `string` | `key` 인증 `openai-responses` 요청에 사용할 선택적 상대 resource path. `/`로 시작해야 하며 URL scheme, query, fragment를 포함할 수 없습니다. 생략하면 기존 `/v1/responses` URL 구성을 유지합니다. |
140140
| `disabled?` | `boolean` | 설정은 디스크에 남기되 라우팅과 모델/카탈로그 목록에서 제외합니다. |
141141
| `apiKey?` | `string` | API 키 또는 요청 시점에 해석할 `${ENV_VAR}` / `$ENV_VAR` 참조. |
142+
| `apiKeyTransport?` | `"x-api-key" \| "bearer"` | Anthropic API 키 헤더 방식입니다. 기본값은 네이티브 `x-api-key`이며, `Authorization: Bearer <key>`를 요구하는 호환 gateway에는 `"bearer"`를 설정합니다. key 인증 `anthropic` 프로바이더에서만 유효합니다. |
142143
| `apiKeyPool?` | `ApiKeyPoolEntry[]` | 여러 키를 담는 pool. `apiKey`는 활성 항목을 반영합니다. 각 항목에는 `id`, `key`, 선택 `label`, 선택 숫자 `addedAt`이 있습니다. |
143144
| `defaultModel?` | `string` | 명시적인 모델 없이 이 프로바이더를 선택했을 때 쓸 모델. |
144145
| `models?` | `string[]` | seed/fallback 모델 목록. `liveModels``false`이면 여기 있는 모델만 발견됩니다. |

docs-site/src/content/docs/reference/adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ streams the response back **untranslated**.
5454
## `anthropic`
5555

5656
**Targets:** Anthropic **Messages** (`/v1/messages`).
57-
**Auth:** `key` (`x-api-key`) or `oauth` (Bearer + `anthropic-beta`, for Claude Pro/Max).
57+
**Auth:** `key` (`x-api-key` by default, or `Authorization: Bearer` with `apiKeyTransport: "bearer"`) or `oauth` (Bearer + `anthropic-beta`, for Claude Pro/Max).
5858

5959
- Converts messages to Anthropic content blocks (text, base64 image, `tool_use`, `thinking`).
6060
- **Extended thinking math:** Anthropic requires `max_tokens > thinking.budget_tokens`. The adapter

docs-site/src/content/docs/reference/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ or bind the forward explicitly to loopback (`ssh -L 127.0.0.1:20100:localhost:10
241241
| `responsesPath?` | `string` | Optional relative resource path for key-auth `openai-responses` requests. It must start with `/` and contain no URL scheme, query, or fragment. When omitted, the adapter keeps its legacy `/v1/responses` URL construction. |
242242
| `disabled?` | `boolean` | Keep the provider on disk but exclude it from routing and model/catalog listings. |
243243
| `apiKey?` | `string` | API key, or an `${ENV_VAR}` / `$ENV_VAR` reference resolved at request time. |
244+
| `apiKeyTransport?` | `"x-api-key" \| "bearer"` | Anthropic API-key header style. Defaults to native `x-api-key`; set `"bearer"` for compatible gateways that require `Authorization: Bearer <key>`. Valid only for key-auth `anthropic` providers. |
244245
| `apiKeyPool?` | `ApiKeyPoolEntry[]` | Multi-key pool. `apiKey` mirrors the active entry; each item has `id`, `key`, optional `label`, and optional numeric `addedAt`. |
245246
| `defaultModel?` | `string` | Model used when this provider is selected without an explicit model. |
246247
| `models?` | `string[]` | Seed/fallback model list. When `liveModels` is `false`, these are the only discovered models. |

docs-site/src/content/docs/ru/reference/adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ interface ProviderAdapter {
5757
## `anthropic`
5858

5959
**Назначение:** Anthropic **Messages** (`/v1/messages`).
60-
**Аутентификация:** `key` (`x-api-key`) или `oauth` (Bearer + `anthropic-beta`, для Claude Pro/Max).
60+
**Аутентификация:** `key` (по умолчанию `x-api-key`, либо `Authorization: Bearer` при `apiKeyTransport: "bearer"`) или `oauth` (Bearer + `anthropic-beta`, для Claude Pro/Max).
6161

6262
- Преобразует сообщения в блоки контента Anthropic (text, base64 image, `tool_use`, `thinking`).
6363
- **Арифметика extended thinking:** Anthropic требует `max_tokens > thinking.budget_tokens`.

docs-site/src/content/docs/ru/reference/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ x-opencodex-api-key: your-secret-token
158158
| `responsesPath?` | `string` | Необязательный относительный путь ресурса для запросов `openai-responses` с аутентификацией `key`. Должен начинаться с `/` и не содержать схему URL, query или fragment. Если поле опущено, сохраняется прежнее построение URL `/v1/responses`. |
159159
| `disabled?` | `boolean` | Провайдер остаётся на диске, но исключается из маршрутизации и списков моделей/каталога. |
160160
| `apiKey?` | `string` | API-ключ или ссылка `${ENV_VAR}` / `$ENV_VAR`, разрешаемая в момент запроса. |
161+
| `apiKeyTransport?` | `"x-api-key" \| "bearer"` | Способ передачи API-ключа Anthropic. По умолчанию используется нативный `x-api-key`; для совместимых gateway, требующих `Authorization: Bearer <key>`, задайте `"bearer"`. Допустимо только для `anthropic` provider с key-аутентификацией. |
161162
| `apiKeyPool?` | `ApiKeyPoolEntry[]` | Пул из нескольких ключей. `apiKey` отражает активную запись; каждый элемент содержит `id`, `key`, необязательный `label` и необязательное числовое `addedAt`. |
162163
| `defaultModel?` | `string` | Модель, используемая при выборе этого провайдера без явной модели. |
163164
| `models?` | `string[]` | Список seed/fallback-моделей. Когда `liveModels` равен `false`, обнаруживаются только эти модели. |

docs-site/src/content/docs/zh-cn/reference/adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ interface ProviderAdapter {
5252
## `anthropic`
5353

5454
**目标:** Anthropic **Messages**`/v1/messages`)。
55-
**认证:** `key``x-api-key`)或 `oauth`(Bearer + `anthropic-beta`,用于 Claude Pro/Max)。
55+
**认证:** `key`默认 `x-api-key`,或设置 `apiKeyTransport: "bearer"` 后使用 `Authorization: Bearer`)或 `oauth`(Bearer + `anthropic-beta`,用于 Claude Pro/Max)。
5656

5757
- 把消息转换成 Anthropic content block(text、base64 image、`tool_use``thinking`)。
5858
- **Extended thinking 计算:** Anthropic 要求 `max_tokens > thinking.budget_tokens`。adapter 把

docs-site/src/content/docs/zh-cn/reference/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ x-opencodex-api-key: your-secret-token
131131
| `responsesPath?` | `string` | `key` 认证的 `openai-responses` 请求可选相对 resource path。必须以 `/` 开头,且不得包含 URL scheme、query 或 fragment。省略时保留原有的 `/v1/responses` URL 构造。 |
132132
| `disabled?` | `boolean` | 配置保留在磁盘上,但从路由和模型/目录列表排除。 |
133133
| `apiKey?` | `string` | API key,或在请求时解析的 `${ENV_VAR}` / `$ENV_VAR` 引用。 |
134+
| `apiKeyTransport?` | `"x-api-key" \| "bearer"` | Anthropic API key 的请求头方式。默认使用原生 `x-api-key`;兼容 gateway 要求 `Authorization: Bearer <key>` 时设为 `"bearer"`。仅适用于使用 key 认证的 `anthropic` provider。 |
134135
| `apiKeyPool?` | `ApiKeyPoolEntry[]` | 多 key pool。`apiKey` 映射当前活动条目;每项包含 `id``key`、可选 `label` 和可选数字 `addedAt`|
135136
| `defaultModel?` | `string` | 选中该 provider 但未指定明确模型时使用的模型。 |
136137
| `models?` | `string[]` | seed/fallback 模型列表。`liveModels``false` 时,只会发现这些模型。 |

0 commit comments

Comments
 (0)