Skip to content

Conversation

@ibetitsmike
Copy link
Contributor

Summary

Enables Anthropic models to work when credentials are configured via environment variables instead of requiring explicit providers.jsonc configuration.

Changes

  • Remove mandatory apiKey check in providers.jsonc for Anthropic provider
  • Support both ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN env vars
  • Auto-normalize base URLs to include /v1 suffix (SDK expects it)
  • Return structured api_key_not_found error when no credentials exist anywhere

Credential Resolution Order

  1. providers.jsoncanthropic.apiKey
  2. ANTHROPIC_API_KEY env var (SDK reads automatically)
  3. ANTHROPIC_AUTH_TOKEN env var (passed explicitly)

Base URL Normalization

The Anthropic SDK expects base URLs to end with /v1. Users often configure URLs without this suffix, so we now auto-append it:

  • https://api.anthropic.comhttps://api.anthropic.com/v1
  • https://api.anthropic.com/v1 → unchanged

Generated with mux

- Remove mandatory apiKey check in providers.jsonc for Anthropic
- Support ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN env vars
- Auto-normalize base URLs to include /v1 suffix
- Return structured api_key_not_found error when no credentials exist

Credential resolution order:
1. providers.jsonc anthropic.apiKey
2. ANTHROPIC_API_KEY env var (SDK reads automatically)
3. ANTHROPIC_AUTH_TOKEN env var (passed explicitly)

_Generated with mux_
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike ibetitsmike force-pushed the anthropic-env-vars-validation branch from c459be5 to 338d466 Compare November 27, 2025 13:05
The api_key_not_found test was failing in CI because ANTHROPIC_API_KEY
is set in the environment. Now we clear all Anthropic env vars during
the test and restore them in cleanup.
@ibetitsmike ibetitsmike added this pull request to the merge queue Nov 27, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 27, 2025
## Summary

Enables Anthropic models to work when credentials are configured via
environment variables instead of requiring explicit `providers.jsonc`
configuration.

### Changes

- Remove mandatory `apiKey` check in `providers.jsonc` for Anthropic
provider
- Support both `ANTHROPIC_API_KEY` and `ANTHROPIC_AUTH_TOKEN` env vars
- Auto-normalize base URLs to include `/v1` suffix (SDK expects it)
- Return structured `api_key_not_found` error when no credentials exist
anywhere

### Credential Resolution Order

1. `providers.jsonc` → `anthropic.apiKey`
2. `ANTHROPIC_API_KEY` env var (SDK reads automatically)
3. `ANTHROPIC_AUTH_TOKEN` env var (passed explicitly)

### Base URL Normalization

The Anthropic SDK expects base URLs to end with `/v1`. Users often
configure URLs without this suffix, so we now auto-append it:

- `https://api.anthropic.com` → `https://api.anthropic.com/v1`
- `https://api.anthropic.com/v1` → unchanged

_Generated with `mux`_
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 27, 2025
@ibetitsmike ibetitsmike added this pull request to the merge queue Nov 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 27, 2025
@ibetitsmike ibetitsmike merged commit 4d02e15 into main Nov 27, 2025
25 of 27 checks passed
@ibetitsmike ibetitsmike deleted the anthropic-env-vars-validation branch November 27, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant