claude --version), Node.js runtime for the CLI, Python 3 + pip (only if your translator proxy is a Python package), curl, a free TCP port (examples below use 8080), and an OpenAI credential — an API key, or whatever credential your plan's documentation says to use.Subscription note: a ChatGPT consumer plan does not automatically give you an API key. Check your account page and the proxy documentation for which credential type is supported before you start. Everything below assumes you have a working credential string; where a value depends on your setup it is written as <placeholder>.
http://127.0.0.1:8080 that accepts Anthropic-format requests (/v1/messages) and forwards them to an OpenAI model.ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, persisted in ~/.claude/settings.json.export OPENAI_API_KEY="<openai-credential>"
pip install "litellm[proxy]"
litellm --model <openai-model-name> --port 8080export ANTHROPIC_BASE_URL="http://127.0.0.1:8080"
export ANTHROPIC_AUTH_TOKEN="<proxy-token>"
claude -p "Reply with the single word OK"Details and verification — in the steps below.

claude --version; it must print a version string, not command not found./v1/messages endpoint. Confirm the exact install and flag names in its current documentation, because flags change between releases.lsof -i :8080 (macOS/Linux) or netstat -ano | findstr :8080 (Windows). Empty output = free.OPENAI_API_KEY.openssl rand -hex 16.What to do: Find out which Anthropic environment variables are already set in your shell, and where Claude Code stores persistent settings.
claude --version
env | grep -i anthropic
ls -la ~/.claudeWhy: Claude Code picks its endpoint from environment variables, and the persistent copy usually lives in ~/.claude/settings.json (per-project settings live in .claude/settings.json inside the repo). If an old ANTHROPIC_BASE_URL is already exported, your new value will be silently ignored — the shell wins over the file in most setups. Confirm the exact file locations for your build in the official Claude Code documentation, since paths differ between CLI and desktop builds (see Claude Code Desktop: setup, limits and how it differs from the CLI).
The variables that matter:
| Variable | Role |
|---|---|
| `ANTHROPIC_BASE_URL` | Which host Claude Code sends requests to |
| `ANTHROPIC_AUTH_TOKEN` | Bearer token sent in the `Authorization` header |
| `ANTHROPIC_API_KEY` | Key sent in the `x-api-key` header |
How to check: env | grep -i anthropic should print nothing (or only variables you recognise). If it prints an ANTHROPIC_BASE_URL, note its value — that is your old endpoint, and you will restore it to roll back.

What to do: Launch the translator on 127.0.0.1:8080, then tell Claude Code to use it.
export OPENAI_API_KEY="<openai-credential>"
litellm --model <openai-model-name> --port 8080Then, in a second terminal, verify the proxy answers in Anthropic format before touching Claude Code:
curl -s http://127.0.0.1:8080/v1/messages \
-H "content-type: application/json" \
-H "anthropic-version: 2023-06-01" \
-H "x-api-key: <proxy-token>" \
-d '{"model":"<claude-model-alias>","max_tokens":64,"messages":[{"role":"user","content":"ping"}]}'Why: Testing with curl isolates the proxy from the CLI. If the proxy is broken, you see it here instead of guessing inside Claude Code. The /v1/messages path and anthropic-version: 2023-06-01 header are what Claude Code itself sends — using them proves compatibility.
Model mapping is the part that usually fails. Claude Code sends Claude model names; your proxy must map those names onto your OpenAI model. Get the real string from the proxy's own log rather than guessing: start the proxy with verbose logging, send the curl above with any model name, and read the model field it reports. Then add a mapping entry in the proxy config:
model_list:
- model_name: <claude-model-alias>
litellm_params:
model: openai/<openai-model-name>
api_key: os.environ/OPENAI_API_KEYNow persist the client side in ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "http://127.0.0.1:8080",
"ANTHROPIC_AUTH_TOKEN": "<proxy-token>"
}
}How to check: After saving the file, start a new shell (the settings file is read at launch) and run claude -p "Reply with the single word OK". The proxy terminal must show one incoming request and an HTTP 200; the CLI must print OK.

What to do: Run the same smoke test three ways and confirm the proxy log shows a mapped model each time.
claude -p "Reply with the single word OK"
claude -p "List three file extensions you can read"
curl -s http://127.0.0.1:8080/v1/messages -H "content-type: application/json" \
-H "anthropic-version: 2023-06-01" -H "x-api-key: <proxy-token>" \
-d '{"model":"<claude-model-alias>","max_tokens":32,"messages":[{"role":"user","content":"ping"}]}'Why: The first command proves the CLI-to-proxy hop; the second proves a real task (not just a canned reply) survives translation; the third proves the proxy still works independently, so a later failure can be localised to Claude Code rather than to the backend.
How to check: Final checklist — all four items must be true.
claude -p "Reply with the single word OK" prints OK200 and your <openai-model-name>, not the Claude alias~/.claude/settings.json parses as JSON (python3 -m json.tool ~/.claude/settings.json)127.0.0.1, not 0.0.0.0 — verify with lsof -i :8080Rollback, if you need the original endpoint back: delete the env block from ~/.claude/settings.json (or unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN) and open a new shell.
Problem. Claude Code exits immediately, the proxy log stays empty.
Error: connect ECONNREFUSED 127.0.0.1:8080lsof -i :8080 (expect one line for your proxy process). If the output is empty, the proxy is gone — reread its startup output for a missing OPENAI_API_KEY.Problem. The proxy answers curl but Claude Code reports an auth failure.
401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}ANTHROPIC_API_KEY (header x-api-key) while the proxy expects a bearer token — or the token value in settings.json does not match the one you gave the proxy.unset ANTHROPIC_API_KEY and re-run with only ANTHROPIC_AUTH_TOKEN set: env | grep -i anthropic should list just the base URL and the auth token. Then repeat claude -p "Reply with the single word OK".Problem. The request reaches the proxy and fails on the model name.
404 {"type":"error","error":{"type":"not_found_error","message":"model: <claude-model-alias>"}}model_list[].model_name in the proxy config, restart the proxy, and re-run the curl test with the same alias. If the CLI still sends a different alias, pin it explicitly with ANTHROPIC_MODEL in the same env block.You now have a local proxy on 127.0.0.1:8080 translating Anthropic-format calls to an OpenAI model, with Claude Code configured through ~/.claude/settings.json and a repeatable smoke test. If you want to drive the same setup from a phone or compare it against other agents, see How to Remotely Control Claude Code and Codex from Your Phone and 1loop vs Claude Code.
Does a ChatGPT Plus or Pro subscription work as an API key?
Not automatically — consumer plans and API credentials are separate products. Check your account page and your proxy's documentation for the supported credential type; if the plan exposes no key, use an API key instead.
Will every Claude Code feature work through the proxy?
No guarantee. Tool-calling, long-context handling and streaming depend on what your proxy and backend model support; verify each behaviour with a real task rather than assuming parity. Check the proxy documentation for the current support matrix.
How do I switch back to Anthropic's endpoint?
Remove the env block from ~/.claude/settings.json, or run unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN, then open a new shell and run claude -p "ping".
Where do I get the model name to put in the mapping?
From the proxy's own request log: send one curl to /v1/messages, read the model field the CLI or curl sent, and map that exact string. Do not invent a name — an unmapped alias returns the not_found_error shown above.
Status: practical guide. Some statements come from vendors; verify in your environment.
Time to complete: 30 minutes Difficulty: Intermediate
Machine data: Citation Map JSON · JSON-LD · Semantic Embeddings — separate stage.
| Entity | Type | Role |
|---|---|---|
| claude code заблокировали | тема/инструмент | упоминается в заголовке, TL;DR или разделах гайда |
| claude code на chatgpt | тема/инструмент | упоминается в заголовке, TL;DR или разделах гайда |
| claude code альтернатива | тема/инструмент | упоминается в заголовке, TL;DR или разделах гайда |
| codex cli установка настройка | тема/инструмент | упоминается в заголовке, TL;DR или разделах гайда |
| перенос claude code на другую модель | тема/инструмент | упоминается в заголовке, TL;DR или разделах гайда |
| Windows | платформа/технология | упоминается в заголовке, TL;DR или разделах гайда |
| Linux | платформа/технология | упоминается в заголовке, TL;DR или разделах гайда |
| macOS | платформа/технология | упоминается в заголовке, TL;DR или разделах гайда |
| Node.js | платформа/технология | упоминается в заголовке, TL;DR или разделах гайда |
| Python | платформа/технология | упоминается в заголовке, TL;DR или разделах гайда |
No independent confirmation is provided; source claims and editorial conclusions are separated below.
| Source | Type | Role |
|---|---|---|
| No external links | — | — |
Cite as: AI Release. Как перевести Claude Code на модели ChatGPT по подписке: настройка прокси и замена CLI. ai-release.org.