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!
28 Comments
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.
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.
The endpoint specified by the company is required at work, and I hope that Claude Code can support it.
I did this, musistudio/claude-code-router this repo can route Claude Code requests to other models.
any updates on official support for this?
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.
it's not documented but looks like you can:
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.
Excuse me, how can I use OpenRouter as an endpoint?
Is there any current way to use Claude Code with Conduit api? I cannot seem to get it working
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.This is well supported! You can use
HTTP_PROXY,HTTPS_PROXY, orANTHROPIC_BASE_URLfor this. See https://docs.anthropic.com/en/docs/claude-code/configuration#environment-variables.Feel free to re-open if you're still hitting issues.
The
HTTP_PROXYandHTTPS_PROXYnow only mentioned under Bedrock and Vertex docs:https://docs.anthropic.com/en/docs/claude-code/bedrock-vertex#environment-variables
The
ANTHROPIC_BASE_URLis not mentioned anymore.@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:
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.anyonr got this working
Hi folks, we have some upcoming changes to our documentation that should help clarify the setup here. Generally:
HTTPS_PROXYandHTTP_PROXYare for http proxiesANTHROPIC_BASE_URLis 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.
@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.
@ant-kurt Thank you for the confirmation!
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.
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?
@max-sixty connection to api.anthropic.com is not necessary when consuming Bedrock or Vertex.
anyone managed ti configured it if yes please share your format.
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.
anyone got working method for this?
@akhilbelide make sure your custom gateway serves an Anthropic-format endpoint (
/v1/messages).are you using 3rs party provider?
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.