ANTHROPIC_BASE_URL should preserve query parameters when constructing request URLs

Resolved 💬 1 comment Opened Feb 22, 2026 by kalil0321 Closed Feb 22, 2026

Problem

When using the Claude Agent SDK with ANTHROPIC_BASE_URL set to a proxy URL that includes query parameters, the query parameters are lost or mangled when the SDK constructs the final request URL.

Example: When deploying on Vercel with Deployment Protection, requests to the proxy need a x-vercel-protection-bypass query parameter. Setting:

ANTHROPIC_BASE_URL=https://my-app.vercel.app/api/proxy?x-vercel-protection-bypass=<secret>

Results in requests like:

https://my-app.vercel.app/api/proxy/v1/messages?beta=true

instead of the expected:

https://my-app.vercel.app/api/proxy/v1/messages?x-vercel-protection-bypass=<secret>&beta=true

The base URL's query parameters are dropped when the SDK appends the API path and its own query parameters.

Expected behavior

ANTHROPIC_BASE_URL query parameters should be preserved and merged with any query parameters the SDK adds when constructing the final request URL.

Use case

This is needed when proxying Anthropic API requests through a deployment that requires authentication via query parameters (e.g., Vercel Deployment Protection bypass). The proxy pattern is useful for:

  • Avoiding exposing the real ANTHROPIC_API_KEY to sandboxed environments
  • Per-user authentication and usage tracking
  • Rate limiting

Workaround

Currently the only workaround is to either disable Vercel Deployment Protection for the proxy route, or pass the bypass token as a header instead (which requires control over the SDK's HTTP client, not currently possible).

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗