feat(anthropic): add authToken option for Bearer authentication#11782
Merged
aayush-kapoor merged 3 commits intovercel:mainfrom Jan 22, 2026
Merged
feat(anthropic): add authToken option for Bearer authentication#11782aayush-kapoor merged 3 commits intovercel:mainfrom
aayush-kapoor merged 3 commits intovercel:mainfrom
Conversation
12324c0 to
15c19b1
Compare
Collaborator
aayush-kapoor
left a comment
There was a problem hiding this comment.
can you please add unit tests for this behaviour as well as an e2e cli example (example/ai-functions/src/generate-text)
15c19b1 to
cee5441
Compare
Comment on lines
+121
to
+127
| if (authToken && apiKey) { | ||
| throw new InvalidArgumentError({ | ||
| argument: 'apiKey/authToken', | ||
| message: | ||
| 'Both apiKey and authToken were provided. Please use only one authentication method.', | ||
| }); | ||
| } |
Collaborator
There was a problem hiding this comment.
this check leads to an error if the apiKey and authToken are defined in the .env file (and not the actual client file)
one can have both apiKey and authToken in the .env file and still only use one
this error should only pop up if the user passed both while initialising the provider
Collaborator
|
i'll make a fix and push it |
Collaborator
|
i assume you tested it with a URL that will accept the proper bearer token? |
aayush-kapoor
approved these changes
Jan 15, 2026
B-Step62
pushed a commit
to B-Step62/ai
that referenced
this pull request
Jan 28, 2026
…el#11782) ## Background Some use cases require `Authorization: Bearer` header authentication instead of the `x-api-key` header when using the Anthropic API. This is particularly useful when working with proxy services or custom API gateways that expect Bearer token authentication. ## Summary Added a new `authToken` option to the Anthropic provider that enables `Authorization: Bearer` header authentication as an alternative to the existing `x-api-key` authentication method. Changes: - Added `authToken` option to `AnthropicProviderSettings` - Added support for `ANTHROPIC_AUTH_TOKEN` environment variable - When `authToken` is provided, uses `Authorization: Bearer` header instead of `x-api-key` ## Manual Verification Tested locally by configuring the provider with `authToken` option and verifying the correct `Authorization: Bearer` header is sent in API requests. ## Checklist - [x] Tests have been added / updated (for bug fixes / features) - [ ] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] I have reviewed this pull request (self-review) --------- Co-authored-by: Aayush Kapoor <[email protected]> Co-authored-by: Aayush Kapoor <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Some use cases require
Authorization: Bearerheader authentication instead of thex-api-keyheader when using the Anthropic API. This is particularly useful when working with proxy services or custom API gateways that expect Bearer token authentication.Summary
Added a new
authTokenoption to the Anthropic provider that enablesAuthorization: Bearerheader authentication as an alternative to the existingx-api-keyauthentication method.Changes:
authTokenoption toAnthropicProviderSettingsANTHROPIC_AUTH_TOKENenvironment variableauthTokenis provided, usesAuthorization: Bearerheader instead ofx-api-keyManual Verification
Tested locally by configuring the provider with
authTokenoption and verifying the correctAuthorization: Bearerheader is sent in API requests.Checklist
pnpm changesetin the project root)