Cursor setup · built-in terminal + Claude Code

Cursor third-party API setup: Claude Code in the built-in terminal

In Cursor's built-in terminal, set the AI Code With Anthropic Messages endpoint the same way as Claude Code, then keep coding in the same editor. Enter only the domain as the Base URL — no /v1.

For developers already using Cursor who want pay-as-you-go access to Claude and other models. The terminal tutorial comes from the official AI Code With docs, and this page follows the same setup.

Terminal env previewCursor built-in terminal
ANTHROPIC_BASE_URL
https://api.aicodewith.ai
ANTHROPIC_AUTH_TOKEN
Your AI Code With API key
ANTHROPIC_API_KEY
""
Model
claude-sonnet-4-6 (example; use the model list)

Set up in Cursor's built-in terminal

Diesen Schlüssel für spätere Terminals speichern

Sobald Sie angemeldet sind, enthält dieser Befehl Ihren eigenen Schlüssel. Kopieren Sie ihn, führen Sie ihn einmal aus, und das Tool behält den Schlüssel an der von uns getesteten Stelle.

bash
for rc in "$HOME/.zshrc" "$HOME/.bashrc"; do
  touch "$rc"
  echo 'export ANTHROPIC_BASE_URL=https://api.aicodewith.ai' >> "$rc"
  echo 'export ANTHROPIC_AUTH_TOKEN=sk-***' >> "$rc"
  echo 'export ANTHROPIC_API_KEY=' >> "$rc"
done

Nicht angemeldete Besucher sehen nur einen Platzhalter. Melden Sie sich an, dann tragen wir Ihren Schlüssel ein. Sign in · Einen Schlüssel in der Konsole abrufen

Durch das Kopieren wird der Befehl nur in die Zwischenablage gelegt. Sie müssen ihn weiterhin in einem Terminal ausführen oder den Schlüssel in die Tool-Einstellungen einfügen. So erhalten Sie einen API-Schlüssel

Cursor's official hint is that the terminal setup is enough. Configure the Claude Code environment variables first, then run Claude Code in the same terminal. The commands below can be copied after signing in.

When signed in, the placeholder in the command is replaced with your key; you can also copy the placeholder and replace it manually.

  1. 1

    Create an API key

    Sign in to the AI Code With dashboard and create a key on the API Keys page. Keep the key in the local terminal environment, not in the repo or a screenshot.

    Open the API Keys page
  2. 2

    Open Cursor's built-in terminal

    Open your project in Cursor and press Ctrl+` (Cmd+` on macOS) to open the built-in terminal. The variables only apply to this terminal session.

  3. 3

    Set the three environment variables

    Run the command below in the terminal. Set ANTHROPIC_BASE_URL to https://api.aicodewith.ai only, with no /v1; use the full key for ANTHROPIC_AUTH_TOKEN; leave ANTHROPIC_API_KEY empty.

    macOS / Linux (Cursor built-in terminal)
    export ANTHROPIC_BASE_URL=https://api.aicodewith.ai
    export ANTHROPIC_AUTH_TOKEN=sk-***
    export ANTHROPIC_API_KEY=
    Windows PowerShell
    $env:ANTHROPIC_BASE_URL = "https://api.aicodewith.ai"
    $env:ANTHROPIC_AUTH_TOKEN = "sk-***"
    $env:ANTHROPIC_API_KEY = ""
  4. 4

    Run Claude Code

    Run claude in the same terminal (install it first if needed, following the Claude Code docs). Claude Code reads the variables above and does not need an Anthropic account login.

  5. 5

    Pick a model and confirm the ID

    Use /model in Claude Code and make the Model ID exactly match the AI Code With model list; do not type an approximate name.

How does this path work?

AI Code With serves an Anthropic Messages-compatible endpoint. Cursor does not take over these variables; Claude Code, running in the built-in terminal, makes the request. Plugins read the same terminal setup.

ANTHROPIC_BASE_URL
The endpoint. Use https://api.aicodewith.ai only, with no /v1 or /v1/messages; adding /v1 causes 404 errors.
ANTHROPIC_AUTH_TOKEN
Your AI Code With API key, sent as Authorization: Bearer with each request.
ANTHROPIC_API_KEY
Leave it empty. AUTH_TOKEN carries the key, so an official Anthropic key is not needed and the two credentials do not override each other.

Flow: Cursor built-in terminal → Claude Code environment variables → AI Code With Anthropic Messages endpoint. Cursor's official editor docs also suggest configuring the terminal first; plugins read the same setup.

Cursor built-in Chat / Agent (not verified)

Cursor settings also have an Override OpenAI Base URL entry that can point built-in Chat / Agent at an OpenAI-compatible endpoint. We only pre-checked the API layer and did not verify it in the Cursor app, so it is not the main tutorial on this page.

OpenAI proposed November 12; defer to Cursor's official date.

Note: this entry only applies to Chat and Agent, not to Tab, Auto, Cloud, Background, Automations, CLI or API.

1

Open Cursor settings

Find Override OpenAI Base URL in Cursor settings, enter the AI Code With OpenAI-compatible address, and fill in the API key.

2

Use it only for Chat / Agent

Following the scope above, switch only built-in Chat / Agent to that address; Tab, Auto, Cloud and other features keep Cursor's official behavior.

3

Check the date with official docs

OpenAI proposed November 12; defer to Cursor's official date. Scope and dates may change as the client updates.

The date comes from OpenAI's proposed shutoff date of November 12, 2026; actual behavior follows Cursor's official documentation. On this path the Base URL is the OpenAI-compatible address (usually with /v1), which differs from the Anthropic address used above.

How do I know it works?

Success comes from a real request, not from a successful copy. Check these in order in Cursor's built-in terminal:

  • echo $ANTHROPIC_BASE_URL (PowerShell: $env:ANTHROPIC_BASE_URL) should print https://api.aicodewith.ai with no /v1 at the end.
  • Confirm claude runs directly in the terminal and does not ask you to log in to an official Anthropic account.
  • Use /model to choose a Model ID from the AI Code With model list, send a short message, and get a normal reply.
  • Match the request by time and model in AI Code With usage records to confirm it went through AI Code With.

All four checks must pass before setup is complete; copying a command or seeing variables set in the terminal is not the same as a working request.

Common error troubleshooting

Terminal setup problems usually fall into 4 categories. Match the symptom, then return to the relevant step.

404 / wrong path

Symptom Claude Code requests fail with 404.

Most likely cause ANTHROPIC_BASE_URL includes /v1, so Claude Code appends the path twice.

  • Change ANTHROPIC_BASE_URL back to https://api.aicodewith.ai
  • Remove any trailing /v1, /v1/messages or guessed path
  • Reopen the terminal and run claude again

401 / invalid API key

Symptom Requests return 401, Unauthorized or Invalid API Key.

Most likely cause The key is incomplete, copied with spaces, or not a valid AI Code With key.

  • Copy the full key again from the API Keys page
  • Set ANTHROPIC_AUTH_TOKEN again with no line breaks or spaces
  • Confirm ANTHROPIC_API_KEY is empty and retry

Model Not Found / wrong Model ID

Symptom Requests report Model Not Found or an unknown model.

Most likely cause The Model ID does not match the AI Code With model list, or the key lacks access.

  • Copy the full Model ID from the model list
  • Choose the same ID with /model
  • Confirm the key can access that model

Setup not applied / official endpoint still used

Symptom Claude Code still asks for official login or official quota.

Most likely cause The variables were set in a different terminal, or the terminal was not reopened.

  • Run the environment variable command again in Cursor's built-in terminal
  • Confirm the current terminal shows all three variables
  • Close the old terminal and any old claude session, then retry

FAQ

Do I need a plugin to use AI Code With in Cursor?

Not on the main path. Following the official editor docs, Cursor's terminal setup is enough: configure the Claude Code environment variables in the built-in terminal. A plugin only reads the same terminal setup and is not a prerequisite.

Should the Base URL include /v1?

Claude Code uses Anthropic Messages, so use https://api.aicodewith.ai only, with no /v1; adding it causes 404 errors. Only the OpenAI-compatible built-in Chat / Agent path uses an address with /v1.

Why leave ANTHROPIC_API_KEY empty?

ANTHROPIC_AUTH_TOKEN carries the AI Code With key here. Leaving ANTHROPIC_API_KEY empty prevents it from overriding AUTH_TOKEN.

Where does the Model ID come from?

It must exactly match the AI Code With model list. Copy the full ID from the model list, then choose the same one in Claude Code's /model.

Do Cursor Tab, Auto and Cloud also use AI Code With?

On the terminal + Claude Code path, Claude Code in the terminal makes the request. If you switch built-in Chat / Agent with Override OpenAI Base URL, it only covers Chat and Agent, not Tab, Auto, Cloud, Background, Automations, CLI or API.

Check the official docs

This page only restates the official setup and did not verify Chat / Agent in the Cursor app. Use these three docs as the source of truth before configuring:

Sources

Related links

This page follows the official AI Code With docs and Cursor's official hint. Cursor client versions, UI and built-in Chat / Agent behavior may change; parts not verified in the Cursor app are labeled separately.