← Blog
CursorTutorialIDE

How to Use Cursor with an Affordable AI API

· Updated (prices in the text follow the live price list)

Short answer

Cursor lets you replace the OpenAI base URL with your own. Set it to https://api.apivai.com/v1, paste an APIVAI key as the OpenAI API key, add the model IDs you want, and Cursor's chat can use Claude and GPT models billed per token from a prepaid balance.

As of 2026-10-10, Claude Sonnet 4.6 costs $1.15 / $5.74 per million input / output tokens this way, against $3.00 / $15.00 at Anthropic's list price. The same key also works in VS Code with Cline or Continue and in JetBrains plugins that accept an OpenAI-compatible endpoint.

Should you use Cursor's subscription or your own key?

OptionHow you payNotes
Cursor's own plansFixed monthly subscriptionUsage limits depend on the plan; see Cursor pricing
Cursor + official API keyPer token at list price$3.00 / $15.00 for Claude Sonnet 4.6
Cursor + APIVAI keyPer token, below list price for most models$1.15 / $5.74 for Claude Sonnet 4.6; 60 requests/min per key

Your own key tends to be cheaper when you use Cursor lightly or unevenly, and it lets you pick exactly which model answers. A subscription can make more sense if you code all day and stay within the plan's limits.

One caveat: some Cursor features may only run on Cursor's own models and not on a custom key. In past versions this has included things like Tab autocomplete and some agent or apply features. Which features use your key can change between releases, so check the API keys section of the Cursor docs for your version. For a broader comparison, see Claude Code vs Cursor: cost comparison.

How do you set up Cursor with your own API key?

Step 1: Get an API key

  1. Sign up at apivai.com with your email and a verification code
  2. Top up your balance: from $10 by card or crypto, or ¥20 via Alipay / WeChat Pay
  3. Create a key on the Dashboard, optionally with its own budget, and copy it

Step 2: Point Cursor at the API

The setting names below are the ones in current versions; they may be worded slightly differently in yours.

  1. Open Cursor Settings (Cmd+, on macOS, Ctrl+, on Windows and Linux) and go to the Models section
  2. Find the setting named roughly Override OpenAI Base URL, turn it on and enter:
https://api.apivai.com/v1
  1. Paste your APIVAI key into the OpenAI API Key field
  2. Click Verify (or the equivalent button). Turn the base URL override on before you verify, otherwise Cursor checks the key against OpenAI and rejects it.

Step 3: Add custom model IDs

In the same Models section, add each model ID you want as a custom model, for example claude-sonnet-4-6, then enable it. Type the ID exactly as shown in the table below. To check which IDs your key can see, request GET https://api.apivai.com/v1/models with the key.

Which models can you use, and what do they cost?

Prices per 1M tokens as of 2026-10-10. Every model and the current price list are on the pricing page.

Model IDModelInputOutputUse it for
claude-sonnet-5-5Claude Sonnet 5.5$0.77$3.82Everyday coding: the best value (newer and cheaper than 4.6)
claude-sonnet-4-6Claude Sonnet 4.6$1.15$5.74Widely supported; Sonnet 5.5 is newer and cheaper
claude-opus-5-5Claude Opus 5.5$1.54$7.65Complex refactors and debugging
claude-fable-5-1Claude Fable 5.1$4.42$22.08The hardest problems
claude-haiku-4-5Claude Haiku 4.5$0.38$1.92Fast, cheap edits
gpt-5.5GPT-5.5$0.77$4.56OpenAI alternative
gpt-5.6-lunaGPT-5.6 Luna$0.0304$0.18Smallest, cheapest GPT

Which model should you pick for which task?

  • Questions, small edits, renames, explaining code: Claude Haiku 4.5 or GPT-5.6 Luna. They are fast and cost little per turn.
  • Everyday feature work and bug fixes: Claude Sonnet 5.5 (or the older Claude Sonnet 4.6). This is the sensible default for most people.
  • Large refactors, tricky bugs across many files, design decisions: Claude Opus 5.5.
  • Problems where Opus gets stuck: Claude Fable 5.1, the most capable and most expensive option. Use it for single hard tasks rather than as a default.
  • A second opinion: switch to GPT-5.5 when you want a different model family to review the same code.

## How much does Cursor cost with your own key?

Costs depend on how many tokens each request sends. Three typical cases with Claude Sonnet 4.6:

  • One chat turn of about 4,000 input and 1,500 output tokens: $0.0132 ($0.0345 at list price).
  • One agent run that reads many files and makes 15 requests of about 40,000 input and 2,000 output tokens each: $0.862 ($2.25 at list price). Agent runs cost more because each step resends the files and conversation so far.
  • A month of 30 chat turns a day for 30 days: $11.89 ($31.05 at list price). Add two agent runs a workday (about 44 a month) and that adds roughly $37.94.

The same month of chat turns on Claude Haiku 4.5 would be $3.96. The Dashboard shows the tokens and cost of every request, so you can see your real numbers after a day or two. The Claude API pricing comparison has the full price list next to official prices.

How do you use the same key in VS Code with Cline?

Cline is a VS Code extension with an agent mode. In current versions you open Cline's settings and choose an API Provider. There are two ways to connect:

  • OpenAI Compatible provider: set the Base URL to https://api.apivai.com/v1, paste your APIVAI key as the API key, and enter a model ID such as claude-sonnet-4-6 or gpt-5.5.
  • Anthropic provider: paste your key and enable the option named roughly Use custom base URL, then enter https://api.apivai.com (no /v1, because Cline adds the path itself). Pick a Claude model from the list.

Either works. The Anthropic provider speaks the native Claude format; the OpenAI Compatible one lets you mix Claude and GPT models with one setting.

How do you set up Continue in VS Code or JetBrains?

Continue is configured in a file. Recent versions use config.yaml (older ones used config.json with the same fields). Add a model entry with provider openai and the APIVAI base URL:

models:
  - name: Claude Sonnet via APIVAI
    provider: openai
    model: claude-sonnet-4-6
    apiBase: https://api.apivai.com/v1
    apiKey: your-key

Add one entry per model; Continue's docs list the other fields.

What about other JetBrains plugins?

JetBrains IDEs (IntelliJ IDEA, PyCharm, WebStorm and others) work with any plugin that accepts an OpenAI-compatible endpoint. Continue has a JetBrains version that uses the same config file. Recent versions of JetBrains AI Assistant can also connect to third-party OpenAI-compatible providers; see the AI Assistant docs for the current menu. In any such plugin, the values are the same: base URL https://api.apivai.com/v1, your APIVAI key, and a model ID from the table. See OpenAI-compatible API for the general details.

Troubleshooting

  • "Invalid API key" or 401: turn the base URL override on before you verify the key. Also check that the key was copied in full, has not been deleted, and has budget left on the Dashboard.
  • 404: the base URL is wrong. OpenAI-format tools (Cursor, Cline's OpenAI Compatible provider, Continue) need /v1 exactly once. Anthropic-format settings (Cline's Anthropic provider) must not include /v1.
  • Model not found: the model ID must match exactly, for example claude-sonnet-4-6, not a display name.
  • 429: the default limit is 60 requests per minute per key. Agent runs can hit it; wait a moment, or ask support for a higher limit.

All API error codes and their fixes are collected in Claude API error codes.

FAQ

Do I still need a Cursor subscription?

Cursor's terms for using your own key have changed over time, so check Cursor pricing for what your plan allows. The API side needs no subscription: you only top up an APIVAI balance.

Does APIVAI see my code?

APIVAI does not store or inspect the content of requests or responses. Only usage metadata such as model, token counts, cost and time is kept for billing.

Can I use Claude and GPT models with one key?

Yes. One key works with every model on the pricing page, in both the OpenAI format (https://api.apivai.com/v1) and the Anthropic format (https://api.apivai.com).

Does tab autocomplete use my key?

Possibly not. Some Cursor features may only work with Cursor's own models. In Continue you can set an autocomplete model yourself.

How do I keep costs under control?

Give the editor its own key with a budget, use a cheaper model by default, and check the Dashboard, which lists every request with its cost. For terminal workflows, see the Claude Code setup guide.

Create an APIVAI account and top up from $10 to start.

Ready to start?

Get your API key in 30 seconds. Pay as you go for Claude and GPT.

Get Started