From de98cd250d40bf86f604976b6bb28823fb44db42 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Sat, 28 Feb 2026 07:48:50 +0000 Subject: [PATCH 1/4] chore: update CHANGELOG for @ai-sdk/anthropic upgrade Co-authored-by: Brendan Kellam --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef3b02021..eb1165be2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Upgraded Vercel AI SDK from v5 to v6. [#969](https://github.com/sourcebot-dev/sourcebot/pull/969) +- Added support for using bearer tokens with anthropic. [#967](https://github.com/sourcebot-dev/sourcebot/pull/967) ## [4.13.1] - 2026-02-28 From ae3b60bd64d31928c23a73ff28ee8c41844e0975 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Sat, 28 Feb 2026 18:55:11 +0000 Subject: [PATCH 2/4] chore: fix PR reference in CHANGELOG.md Co-authored-by: Brendan Kellam --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb1165be2..e85b80b97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Upgraded Vercel AI SDK from v5 to v6. [#969](https://github.com/sourcebot-dev/sourcebot/pull/969) - Added support for using bearer tokens with anthropic. [#967](https://github.com/sourcebot-dev/sourcebot/pull/967) +- Upgraded `@ai-sdk/anthropic` to `^3.0.22` to support `ANTHROPIC_AUTH_TOKEN` environment variable. [#968](https://github.com/sourcebot-dev/sourcebot/pull/968) ## [4.13.1] - 2026-02-28 From 4f1de65c098f0907b42720ffa69e4a881c4e5347 Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Sat, 28 Feb 2026 11:08:49 -0800 Subject: [PATCH 3/4] wip --- .../language-model-providers.mdx | 5 ++ docs/snippets/schemas/v3/index.schema.mdx | 66 ++++++++++++++++++- .../schemas/v3/languageModel.schema.mdx | 66 ++++++++++++++++++- packages/schemas/src/v3/index.schema.ts | 66 ++++++++++++++++++- packages/schemas/src/v3/index.type.ts | 18 ++++- .../schemas/src/v3/languageModel.schema.ts | 66 ++++++++++++++++++- packages/schemas/src/v3/languageModel.type.ts | 18 ++++- packages/shared/src/env.server.ts | 1 + packages/web/src/features/chat/actions.ts | 3 + schemas/v3/languageModel.json | 6 +- 10 files changed, 304 insertions(+), 11 deletions(-) diff --git a/docs/docs/configuration/language-model-providers.mdx b/docs/docs/configuration/language-model-providers.mdx index d888fd39f..91aab43de 100644 --- a/docs/docs/configuration/language-model-providers.mdx +++ b/docs/docs/configuration/language-model-providers.mdx @@ -89,9 +89,14 @@ For a detailed description of all the providers, please refer to the [schema](ht "provider": "anthropic", "model": "YOUR_MODEL_HERE", "displayName": "OPTIONAL_DISPLAY_NAME", + // Auth can be provided via a API key that is sent using the `x-api-key` header... "token": { "env": "ANTHROPIC_API_KEY" }, + // ...or via a auth token sent using the `Authorization: Bearer` header. + "authToken": { + "env": "ANTHROPIC_AUTH_TOKEN" + }, "baseUrl": "OPTIONAL_BASE_URL" } ] diff --git a/docs/snippets/schemas/v3/index.schema.mdx b/docs/snippets/schemas/v3/index.schema.mdx index d5e6721d1..4e857ee8c 100644 --- a/docs/snippets/schemas/v3/index.schema.mdx +++ b/docs/snippets/schemas/v3/index.schema.mdx @@ -1769,7 +1769,38 @@ "additionalProperties": false } ], - "description": "Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable." + "description": "Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable." + }, + "authToken": { + "anyOf": [ + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "googleCloudSecret": { + "type": "string", + "description": "The resource name of a Google Cloud secret. Must be in the format `projects//secrets//versions/`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets" + } + }, + "required": [ + "googleCloudSecret" + ], + "additionalProperties": false + } + ], + "description": "Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable." }, "baseUrl": { "type": "string", @@ -3198,7 +3229,38 @@ "additionalProperties": false } ], - "description": "Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable." + "description": "Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable." + }, + "authToken": { + "anyOf": [ + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "googleCloudSecret": { + "type": "string", + "description": "The resource name of a Google Cloud secret. Must be in the format `projects//secrets//versions/`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets" + } + }, + "required": [ + "googleCloudSecret" + ], + "additionalProperties": false + } + ], + "description": "Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable." }, "baseUrl": { "type": "string", diff --git a/docs/snippets/schemas/v3/languageModel.schema.mdx b/docs/snippets/schemas/v3/languageModel.schema.mdx index 40758fdbe..7d3eff422 100644 --- a/docs/snippets/schemas/v3/languageModel.schema.mdx +++ b/docs/snippets/schemas/v3/languageModel.schema.mdx @@ -222,7 +222,38 @@ "additionalProperties": false } ], - "description": "Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable." + "description": "Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable." + }, + "authToken": { + "anyOf": [ + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "googleCloudSecret": { + "type": "string", + "description": "The resource name of a Google Cloud secret. Must be in the format `projects//secrets//versions/`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets" + } + }, + "required": [ + "googleCloudSecret" + ], + "additionalProperties": false + } + ], + "description": "Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable." }, "baseUrl": { "type": "string", @@ -1651,7 +1682,38 @@ "additionalProperties": false } ], - "description": "Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable." + "description": "Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable." + }, + "authToken": { + "anyOf": [ + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "googleCloudSecret": { + "type": "string", + "description": "The resource name of a Google Cloud secret. Must be in the format `projects//secrets//versions/`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets" + } + }, + "required": [ + "googleCloudSecret" + ], + "additionalProperties": false + } + ], + "description": "Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable." }, "baseUrl": { "type": "string", diff --git a/packages/schemas/src/v3/index.schema.ts b/packages/schemas/src/v3/index.schema.ts index 52685c591..da6546ca6 100644 --- a/packages/schemas/src/v3/index.schema.ts +++ b/packages/schemas/src/v3/index.schema.ts @@ -1768,7 +1768,38 @@ const schema = { "additionalProperties": false } ], - "description": "Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable." + "description": "Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable." + }, + "authToken": { + "anyOf": [ + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "googleCloudSecret": { + "type": "string", + "description": "The resource name of a Google Cloud secret. Must be in the format `projects//secrets//versions/`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets" + } + }, + "required": [ + "googleCloudSecret" + ], + "additionalProperties": false + } + ], + "description": "Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable." }, "baseUrl": { "type": "string", @@ -3197,7 +3228,38 @@ const schema = { "additionalProperties": false } ], - "description": "Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable." + "description": "Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable." + }, + "authToken": { + "anyOf": [ + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "googleCloudSecret": { + "type": "string", + "description": "The resource name of a Google Cloud secret. Must be in the format `projects//secrets//versions/`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets" + } + }, + "required": [ + "googleCloudSecret" + ], + "additionalProperties": false + } + ], + "description": "Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable." }, "baseUrl": { "type": "string", diff --git a/packages/schemas/src/v3/index.type.ts b/packages/schemas/src/v3/index.type.ts index ac5c5d0c0..f60dd68f4 100644 --- a/packages/schemas/src/v3/index.type.ts +++ b/packages/schemas/src/v3/index.type.ts @@ -715,7 +715,7 @@ export interface AnthropicLanguageModel { */ displayName?: string; /** - * Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable. + * Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable. */ token?: | { @@ -730,6 +730,22 @@ export interface AnthropicLanguageModel { */ googleCloudSecret: string; }; + /** + * Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable. + */ + authToken?: + | { + /** + * The name of the environment variable that contains the token. + */ + env: string; + } + | { + /** + * The resource name of a Google Cloud secret. Must be in the format `projects//secrets//versions/`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets + */ + googleCloudSecret: string; + }; /** * Optional base URL. */ diff --git a/packages/schemas/src/v3/languageModel.schema.ts b/packages/schemas/src/v3/languageModel.schema.ts index 7e9e9c6bc..5832ddfcb 100644 --- a/packages/schemas/src/v3/languageModel.schema.ts +++ b/packages/schemas/src/v3/languageModel.schema.ts @@ -221,7 +221,38 @@ const schema = { "additionalProperties": false } ], - "description": "Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable." + "description": "Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable." + }, + "authToken": { + "anyOf": [ + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "googleCloudSecret": { + "type": "string", + "description": "The resource name of a Google Cloud secret. Must be in the format `projects//secrets//versions/`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets" + } + }, + "required": [ + "googleCloudSecret" + ], + "additionalProperties": false + } + ], + "description": "Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable." }, "baseUrl": { "type": "string", @@ -1650,7 +1681,38 @@ const schema = { "additionalProperties": false } ], - "description": "Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable." + "description": "Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable." + }, + "authToken": { + "anyOf": [ + { + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "The name of the environment variable that contains the token." + } + }, + "required": [ + "env" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "googleCloudSecret": { + "type": "string", + "description": "The resource name of a Google Cloud secret. Must be in the format `projects//secrets//versions/`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets" + } + }, + "required": [ + "googleCloudSecret" + ], + "additionalProperties": false + } + ], + "description": "Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable." }, "baseUrl": { "type": "string", diff --git a/packages/schemas/src/v3/languageModel.type.ts b/packages/schemas/src/v3/languageModel.type.ts index 1bc86ec95..fad8f6cc7 100644 --- a/packages/schemas/src/v3/languageModel.type.ts +++ b/packages/schemas/src/v3/languageModel.type.ts @@ -124,7 +124,7 @@ export interface AnthropicLanguageModel { */ displayName?: string; /** - * Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable. + * Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable. */ token?: | { @@ -139,6 +139,22 @@ export interface AnthropicLanguageModel { */ googleCloudSecret: string; }; + /** + * Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable. + */ + authToken?: + | { + /** + * The name of the environment variable that contains the token. + */ + env: string; + } + | { + /** + * The resource name of a Google Cloud secret. Must be in the format `projects//secrets//versions/`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets + */ + googleCloudSecret: string; + }; /** * Optional base URL. */ diff --git a/packages/shared/src/env.server.ts b/packages/shared/src/env.server.ts index 15ba17cc9..f3627ad9b 100644 --- a/packages/shared/src/env.server.ts +++ b/packages/shared/src/env.server.ts @@ -202,6 +202,7 @@ export const env = createEnv({ REVIEW_AGENT_REVIEW_COMMAND: z.string().default('review'), ANTHROPIC_API_KEY: z.string().optional(), + ANTHROPIC_AUTH_TOKEN: z.string().optional(), ANTHROPIC_THINKING_BUDGET_TOKENS: numberSchema.default(12000), AZURE_API_KEY: z.string().optional(), diff --git a/packages/web/src/features/chat/actions.ts b/packages/web/src/features/chat/actions.ts index 3889a3a2f..6d646f6fb 100644 --- a/packages/web/src/features/chat/actions.ts +++ b/packages/web/src/features/chat/actions.ts @@ -764,6 +764,9 @@ export const _getAISDKLanguageModelAndOptions = async (config: LanguageModel): P apiKey: config.token ? await getTokenFromConfig(config.token) : env.ANTHROPIC_API_KEY, + authToken: config.authToken + ? await getTokenFromConfig(config.authToken) + : env.ANTHROPIC_AUTH_TOKEN, headers: config.headers ? await extractLanguageModelKeyValuePairs(config.headers) : undefined, diff --git a/schemas/v3/languageModel.json b/schemas/v3/languageModel.json index e56df4cee..7d2b261e7 100644 --- a/schemas/v3/languageModel.json +++ b/schemas/v3/languageModel.json @@ -71,7 +71,11 @@ }, "token": { "$ref": "./shared.json#/definitions/Token", - "description": "Optional API key to use with the model. Defaults to the `ANTHROPIC_API_KEY` environment variable." + "description": "Optional API key to use with the model, sent as the `x-api-key` header. Defaults to the `ANTHROPIC_API_KEY` environment variable." + }, + "authToken": { + "$ref": "./shared.json#/definitions/Token", + "description": "Optional auth token to use with the model, sent as the `Authorization: Bearer` header. Defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable." }, "baseUrl": { "type": "string", From fa2bcc124c12becc2f6f8f11e371f9db8a335bfe Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Sat, 28 Feb 2026 16:35:35 -0800 Subject: [PATCH 4/4] changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e85b80b97..eb1165be2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Upgraded Vercel AI SDK from v5 to v6. [#969](https://github.com/sourcebot-dev/sourcebot/pull/969) - Added support for using bearer tokens with anthropic. [#967](https://github.com/sourcebot-dev/sourcebot/pull/967) -- Upgraded `@ai-sdk/anthropic` to `^3.0.22` to support `ANTHROPIC_AUTH_TOKEN` environment variable. [#968](https://github.com/sourcebot-dev/sourcebot/pull/968) ## [4.13.1] - 2026-02-28