Use Claude Code & Cursor with a Cheaper Claude API

If you spend your day in Claude Code or Cursor, you already know how good Claude is at real engineering work — reading a repo, planning a refactor, writing tests, and fixing its own mistakes. The one thing that stings is the bill. This guide shows how to point those same tools at a cheaper Claude API using a single key from ApiTopMix, without changing how you actually work.

ApiTopMix is a unified AI API gateway. It exposes both an OpenAI-compatible endpoint at https://apitopmix.com/v1 and a native Anthropic endpoint at /v1/messages. That combination is exactly what coding tools need: Claude Code talks the Anthropic protocol, Cursor talks the OpenAI protocol, and one ApiTopMix key drives both. Any developer, anywhere, can set this up in about five minutes.

TL;DR: Set ANTHROPIC_BASE_URL=https://apitopmix.com and ANTHROPIC_AUTH_TOKEN=<your key> for Claude Code, or override Cursor's OpenAI Base URL to https://apitopmix.com/v1. Use claude-sonnet-4-6 for daily work and claude-opus-4-6 for the hard stuff.

What you get with one key

A single ApiTopMix key unlocks the full Claude lineup plus other model families, so you are never locked into one tool or one vendor:

Because both an OpenAI-shaped and an Anthropic-shaped endpoint sit behind the same key, you can mix tools freely — Claude Code in the terminal, Cursor in the editor, and a curl script in CI — all billed to one account.

Step 0: Get your API key

  1. Create an account at apitopmix.com/register (email signup works).
  2. Open the console, go to Tokens, and click Create new token.
  3. Copy the key — it starts with sk-. Keep it somewhere safe; you will paste it into Claude Code and Cursor below.

That single sk- key is all you need for the rest of this guide.

Connect Claude Code

Claude Code is configured entirely through environment variables. It reads two of them to decide where to send requests and how to authenticate:

Point them at ApiTopMix and launch Claude Code. On macOS or Linux, run:

export ANTHROPIC_BASE_URL=https://apitopmix.com
export ANTHROPIC_AUTH_TOKEN=sk-your-apitopmix-key
claude

On Windows PowerShell, the equivalent is:

$env:ANTHROPIC_BASE_URL = "https://apitopmix.com"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-apitopmix-key"
claude

That's it. With those variables set, Claude Code sends every request to ApiTopMix's native Anthropic endpoint (/v1/messages) instead of the default. Tool use, streaming output, file edits, and long-context reads all work exactly as before — you're just routing through a cheaper gateway.

Make it permanent: add the two export lines to your ~/.zshrc, ~/.bashrc, or shell profile so every new terminal is ready to go. To switch back to the default at any time, just unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN.

Choosing a model in Claude Code

Two models cover almost everything:

Because both live behind the same key, switching model in Claude Code needs no config change — pick the model that fits the task and keep going.

Connect Cursor

Cursor lets you override the OpenAI Base URL, which is exactly the hook we need. Because ApiTopMix speaks the OpenAI protocol at https://apitopmix.com/v1, Cursor can send its requests there and get Claude back. Here's the flow:

  1. Open Cursor Settings (the gear icon, or Cmd/Ctrl + Shift + J).
  2. Go to Models.
  3. Enable OpenAI API Key and expand its options.
  4. Turn on Override OpenAI Base URL and set it to https://apitopmix.com/v1.
  5. Paste your ApiTopMix sk- key into the API key field.
  6. Under custom models, add a model name such as claude-sonnet-4-6 (and claude-opus-4-6 if you want both). Save.

Now select your custom claude-sonnet-4-6 model from Cursor's model picker, and chat, edits, and inline completions route through ApiTopMix to Claude. If Cursor asks you to verify the key, it sends a small test request to the Base URL you set — a normal part of enabling a custom endpoint.

Heads up: when you override the Base URL, Cursor sends requests to that endpoint instead of its own backend. Keep the URL as https://apitopmix.com/v1 (with the /v1 suffix) and use a model name you actually added, or the picker won't route correctly.

Models and pricing at a glance

Here's a quick reference for the coding-oriented Claude models and their ApiTopMix pricing:

ModelBest forInput / 1MOutput / 1M
claude-sonnet-4-6Everyday coding, refactors, quick edits$2.20$11.00
claude-opus-4-6Complex reasoning, big refactors, hard debugging$3.00$15.00
claude-haiku-4-5-20251001Fast, cheap bulk tasks and classification$0.60$3.00

Prices are in USD per million tokens and reflect the ApiTopMix rate, which sits below the official list price. For the full, current table across every model, see the ApiTopMix pricing page, and check the API documentation for endpoint details and code samples.

Verify it's working

Want to confirm the route before you open your editor? Fire a one-line request at the OpenAI-compatible endpoint:

curl https://apitopmix.com/v1/chat/completions \
  -H "Authorization: Bearer sk-your-apitopmix-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet-4-6","messages":[{"role":"user","content":"Say hi from Claude"}]}'

A normal chat completion in the response means Cursor is good to go. For Claude Code, simply launch claude after exporting the two variables and ask it a question — a reply confirms the native endpoint is wired up.

Frequently asked questions

Does this work with Claude Code?

Yes. Claude Code reads ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN. Set the base URL to https://apitopmix.com and the token to your ApiTopMix key, then run claude. Requests go to ApiTopMix's native Anthropic /v1/messages endpoint, so tool use, streaming, and long context all behave normally.

Which model should I use?

Use claude-sonnet-4-6 for daily coding and claude-opus-4-6 when a task needs deeper reasoning or spans many files. Both are on the same key, so switching is instant and needs no reconfiguration.

Is it OpenAI-compatible?

Yes. ApiTopMix exposes an OpenAI-compatible endpoint at https://apitopmix.com/v1 (for example /v1/chat/completions) alongside the native Anthropic /v1/messages endpoint. Cursor uses the OpenAI-compatible one via the Base URL override; Claude Code uses the native one automatically.

How do I get a key?

Sign up at apitopmix.com/register, open the console, go to Tokens, and create a new token. Copy the sk- string and use it as your ANTHROPIC_AUTH_TOKEN in Claude Code or as the API key in Cursor. Billing is pay-as-you-go.

Will my existing config break?

No, and it's fully reversible. In Claude Code you only set two environment variables — unset them to return to the default. In Cursor you only override the Base URL and key in Settings — clear the override to restore the default. Your prompts, projects, and workflows are untouched.

Point your coding tools at a cheaper Claude

Grab a key, set two variables (or one Base URL), and keep coding with Claude Code and Cursor for less.

Further reading

Conclusion

The tooling around Claude has matured to the point where the model and the price no longer have to come as a bundle. With one ApiTopMix key, Claude Code picks up the native Anthropic endpoint through two environment variables, and Cursor picks up the OpenAI-compatible endpoint through a single Base URL override. Nothing about how you write code changes — you just route the same requests through a cheaper Claude API and keep the workflow you already like.

Set it up once, add the exports to your shell profile, and you're done. From then on, every session in Claude Code and every completion in Cursor runs on claude-sonnet-4-6 or claude-opus-4-6 at a lower cost — with the freedom to switch models or tools whenever the task calls for it.

More guides: Claude Haiku API · Gemini API · DeepSeek API · Claude Opus API · Claude Sonnet API · Suno API · GPT-5 API · Claude in Cursor · Claude in Cline / Roo Code · Claude Code without a subscription · Cheap Claude API · Base URL troubleshooting · GPT-5.6 API