Request: Custom Claude API Endpoint Support

Resolved 💬 28 comments Opened Feb 28, 2025 by d3vw Closed May 6, 2025
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Hi, I love using claude-code—it’s a great tool!

However, my network restricts access to the default Claude API endpoint, requiring a proxy.

I’d like to request a feature to set a custom API endpoint URL in the config.

This would let me use an intermediary service and keep the tool working smoothly.

It could help others with similar issues too. Thanks for considering this!

View original on GitHub ↗

28 Comments

imsardine · 1 year ago

It would be great if Claude Code allowed custom API keys and endpoints, making it possible to integrate with OpenRouter or a self-hosted AI/LLM gateway.

Nayshins · 1 year ago

I would like to use claude code at my work, but we are forced to go through a genAI proxy. Adding a custom endpoint would allow me to access the bedrock models via our proxy service.

ryoshin0830 · 1 year ago

The endpoint specified by the company is required at work, and I hope that Claude Code can support it.

musistudio · 1 year ago

I did this, musistudio/claude-code-router this repo can route Claude Code requests to other models.

0xRaduan · 1 year ago

any updates on official support for this?

majerm · 1 year ago

If you look here https://www.npmjs.com/package/@anthropic-ai/claude-code?activeTab=code to cli.js
There is ANTHROPIC_BASE_URL in source code. Maybe it is possible to use this in your case.

saucoide · 1 year ago

it's not documented but looks like you can:

export ANTHROPIC_BASE_URL="https://llm.proxy"
export ANTHROPIC_AUTH_TOKEN="some-api-key"
kintz09 · 1 year ago

We access our Claude models through Open WebUI which uses Amazon Bedrock instead of a direct connection to Anthropic. I'd like to figure out how to use Claude Code with my Open WebUI user's API Key.

zsio · 1 year ago

Excuse me, how can I use OpenRouter as an endpoint?

mcguipat · 1 year ago

Is there any current way to use Claude Code with Conduit api? I cannot seem to get it working

CRogers · 1 year ago

Unfortunately, being unable to hit a custom endpoint means I can't use claude-code. OpenAI codex lets you set a base url; I guess we're going to end up using that, even though it would be nice to use 3.7 sonnet.

I tried setting ANTHROPIC_BASE_URL - it doesn't seem to do anything.

bcherny collaborator · 1 year ago

This is well supported! You can use HTTP_PROXY, HTTPS_PROXY, or ANTHROPIC_BASE_URL for this. See https://docs.anthropic.com/en/docs/claude-code/configuration#environment-variables.

Feel free to re-open if you're still hitting issues.

propell-ant · 1 year ago

The HTTP_PROXY and HTTPS_PROXY now only mentioned under Bedrock and Vertex docs:
https://docs.anthropic.com/en/docs/claude-code/bedrock-vertex#environment-variables

The ANTHROPIC_BASE_URL is not mentioned anymore.

marcomayer · 1 year ago

@bcherny I'd like to use an bedrock API gateway (https://github.com/aws-samples/bedrock-access-gateway, so basically openai-compatible API) to use sonnet-4. How would I set it up? HTTPS_PROXY doesn't seem to work, I get this error:

Z42 [InvalidArgumentError]: invalid url
    at Object.g_6 [as parseOrigin] (file:///home/mmayer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:380:32051)
    at new f82 (file:///home/mmayer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:418:8137)
    at sf6 (file:///home/mmayer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:418:13484)
    at new BB2 (file:///home/mmayer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:418:14481)
    at cp6 (file:///home/mmayer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1364:8422)
    at file:///home/mmayer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1364:8368 {
  code: 'UND_ERR_INVALID_ARG'
}

Is there some guidance somewhere what is required for this and what to set? What I have is the URL to the API, and an API Key.

I tried all sort of combinations of setting ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY` but none worked so far.

sudip358 · 1 year ago

anyonr got this working

ant-kurt collaborator · 1 year ago

Hi folks, we have some upcoming changes to our documentation that should help clarify the setup here. Generally:

  • HTTPS_PROXY and HTTP_PROXY are for http proxies
  • ANTHROPIC_BASE_URL is for "LLM gateways", and needs to point to a path that hosts an Anthropic API-format endpoint (/v1/messages), see https://docs.anthropic.com/en/api/messages
kintz09 · 1 year ago
Hi folks, we have some upcoming changes to our documentation that should help clarify the setup here. Generally: HTTPS_PROXY and HTTP_PROXY are for http proxies ANTHROPIC_BASE_URL is for "LLM gateways", and needs to point to a path that hosts an Anthropic API-format endpoint (/v1/messages), see https://docs.anthropic.com/en/api/messages

@ant-kurt I see you specified an Anthropic API-format endpoint. Could you please confirm whether or not it should be possible to use Claude through an OpenAI-compatible API?

Our organization is using Anthropic models delivered by AWS Bedrock with Open WebUI. So I'm looking to clarify whether it should be possible to use Claude Code with the OWUI API and if not, should it be possible to use Claude Code directly with AWS Bedrock.

ant-kurt collaborator · 1 year ago

@kintz09 it is not currently possible to use Claude Code with an OAI-compatible API. You can use Claude Code directly with Bedrock, see https://docs.anthropic.com/en/docs/claude-code/amazon-bedrock.

kintz09 · 1 year ago

@ant-kurt Thank you for the confirmation!

marcomayer · 1 year ago
@kintz09 it is not currently possible to use Claude Code with an OAI-compatible API. You can use Claude Code directly with Bedrock, see https://docs.anthropic.com/en/docs/claude-code/amazon-bedrock.

We have the same use case/issue. Using AWS Bedrock Gateway we'd need to access the Anthropic models via open ai endpoints. Hope this soon gets possible.

max-sixty · 1 year ago

thanks @ant-kurt !

is a connection to api.anthropic.com still required (possible through a proxy)?

or can we hit the Vertex anthropic endpoint only?

ant-kurt collaborator · 1 year ago

@max-sixty connection to api.anthropic.com is not necessary when consuming Bedrock or Vertex.

sudip358 · 1 year ago

anyone managed ti configured it if yes please share your format.

akhilbelide · 1 year ago

Connecting to a custom LLM gateway gives me a API Connection Error even though it works witj local host and curl to the url is also giving me a response.

sudip358 · 1 year ago

anyone got working method for this?

ant-kurt collaborator · 1 year ago

@akhilbelide make sure your custom gateway serves an Anthropic-format endpoint (/v1/messages).

sudip358 · 1 year ago
@akhilbelide make sure your custom gateway serves an Anthropic-format endpoint (/v1/messages).

are you using 3rs party provider?

github-actions[bot] · 11 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.