# Como usar sua própria chave de API no Cursor IDE

Cursor Pro costs $20/month with a usage cap. With a RunAPI key you pay per token — the same Claude and GPT-4o models at 50% off official rates, no monthly fee, no Pro subscription required. This guide covers where to paste your key in Settings &gt; Models, how to set the base URL (the step most guides skip), and how to fix the common &#39;unauthorized user api key&#39; error.

*Updated June 23, 2026 · RunAPI Editorial*

## Posso usar o Cursor com minha própria chave de API?

Yes. Cursor lets you add your own API key on the free plan — you do not need Cursor Pro. Go to Settings &gt; Models, scroll to the OpenAI section, and fill in two fields: the OpenAI Base URL (https://runapi.ai/v1) and the OpenAI API Key (your RunAPI key). RunAPI gives you access to Claude 3.5 Sonnet, GPT-4o, Gemini, and other models at 50% of what Anthropic and OpenAI charge directly. The most common setup error — the &#39;unauthorized user api key&#39; message — means the base URL field is empty, so Cursor is sending your key to the wrong endpoint.

- **Funciona em todos os planos Cursor**: You do not need a Pro subscription to use your own API key. BYOK works on the free Cursor tier and on Pro.
- **Endpoint compatível com OpenAI**: RunAPI uses the same request and response format as the OpenAI API. Cursor&#39;s OpenAI API Key field accepts it without any code changes.
- **50% de desconto nos preços oficiais dos modelos**: O RunAPI cobra metade do preço de lista do provedor. A entrada do Claude 3.5 Sonnet custa $1,50/M tokens pelo RunAPI versus $3,00/M diretamente pela Anthropic.
- **Corrija &#39;unauthorized user api key&#39;**: This error almost always means the OpenAI Base URL field is empty. Set it to https://runapi.ai/v1 alongside your key and the error clears.

## Onde inserir sua chave de API no Cursor

Cursor keeps all model configuration in one place. Open Cursor, press Cmd+Shift+J (Mac) or Ctrl+Shift+J (Windows/Linux) to open Settings, then click the Models tab on the left. Find the OpenAI section — you need to fill in two fields there. The OpenAI Base URL tells Cursor to send requests to RunAPI instead of OpenAI directly. The OpenAI API Key field is where you paste your RunAPI key. Both fields must be set. If you leave the base URL blank, Cursor sends your key to api.openai.com, which will reject it every time.

## Corrigindo o erro &#39;unauthorized user api key&#39; no Cursor

The &#39;unauthorized user api key&#39; message from Cursor means one of three things. First, the OpenAI Base URL field is empty, so Cursor sends your RunAPI key to api.openai.com, which rejects it — this is the most common cause. Second, the key was copied with a leading or trailing space. Third, the key was revoked or regenerated and the old value is stale. RunAPI keys start with &#39;rp-&#39; and are not standard OpenAI keys — they will always fail if Cursor tries to authenticate them against openai.com. Always set the base URL alongside the key. If a specific model still returns an error after the key and URL are correct, double-check the model name matches the exact slug shown at runapi.ai/pricing — a mismatch returns a different error than an auth failure.

### URL base ausente

A causa mais comum. Se a URL Base OpenAI estiver em branco, o Cursor envia sua chave RunAPI para api.openai.com, que a rejeita. Defina a URL base como https://runapi.ai/v1 e o erro desaparece.

### Chave copiada com espaço em branco extra

Paste the key and look for a leading or trailing space. Some terminals and browsers add invisible whitespace when you copy. Delete the field and paste again if in doubt.

### Chave expirada ou revogada

As chaves RunAPI podem ser revogadas pelo painel. Se você regenerou sua chave recentemente, o valor antigo retornará 401. Copie a nova chave em Painel &gt; Chaves de API.

### Slug de modelo incorreto

Se a chave e a URL estiverem corretas, mas um modelo específico retornar erro, o nome do modelo pode não corresponder ao catálogo do RunAPI. Verifique o slug exato em runapi.ai/pricing e cole no campo de modelo do Cursor.


## O Cursor Pro vale $20/mês, ou você deveria usar sua própria chave?

Cursor Pro gives you a fixed monthly allowance of fast-model requests. Once you hit the cap, Cursor slows you down or stops until the month resets. BYOK with RunAPI has no cap — you pay per token at 50% of official rates. For most developers, the break-even point is around 8–12 hours of heavy AI coding per month. Below that, RunAPI costs less. Above that, a subscription becomes more predictable but not necessarily cheaper.

## Como usar sua própria chave de API no Cursor com RunAPI

1. **Crie uma conta RunAPI gratuita** — Acesse runapi.ai e cadastre-se. Não é necessário cartão de crédito. Você recebe um pequeno crédito gratuito para testar a conexão.
2. **Copie sua chave de API e URL base** — In the RunAPI dashboard, go to API Keys and generate a key. Copy it right away and note the base URL — it is https://runapi.ai/v1.
3. **Abra as Configurações do Cursor** — In Cursor, press Cmd+Shift+J (Mac) or Ctrl+Shift+J (Windows/Linux) to open Settings. Click the Models tab on the left sidebar.
4. **Insira a URL base** — Scroll to the OpenAI section. Paste https://runapi.ai/v1 into the OpenAI Base URL field. Most guides skip this step — without it, Cursor sends all requests to OpenAI and rejects your key.
5. **Paste your key and click Enable** — Paste your RunAPI key into the OpenAI API Key field. Check that there is no leading or trailing whitespace. Toggle the OpenAI section on if it is off, then click Verify or Enable.
6. **Selecione um modelo e teste** — In the Cursor chat bar, choose a model such as gpt-5.4. Send a test message. A response confirms the connection works. Check your RunAPI dashboard under Usage to see the request logged.

## FAQ de configuração de chave de API do Cursor

### Por que o Cursor mostra &#39;unauthorized user api key&#39;?

Este erro aparece quando o Cursor não consegue autenticar sua chave no endpoint que está direcionando. O motivo mais comum é que o campo URL Base OpenAI está vazio, então o Cursor envia sua chave RunAPI para api.openai.com, que a rejeita. Defina a URL base como https://runapi.ai/v1 junto com sua chave para corrigir.

### Do I need a Pro version of Cursor to add custom API keys?

No — you do not need a Pro subscription to use your own API key. Cursor lets you add custom API keys on the free plan. Go to Settings &gt; Models, paste your key into the OpenAI API Key field, set the base URL, and you are done. Cursor&#39;s own built-in model requests have separate limits, but those do not apply when you supply your own key.

### Quais modelos posso usar no Cursor via RunAPI?

Qualquer modelo no catálogo RunAPI que exponha um endpoint de conclusões de chat — incluindo Claude 3.5 Sonnet, Claude 3.7 Sonnet, GPT-4o, GPT-4.1, Gemini 1.5 Pro e Llama 3.1. Insira o slug exato do modelo em runapi.ai/pricing no campo de modelo do Cursor. Modelos de imagem e áudio não estão disponíveis na interface de chat do Cursor.

### O RunAPI é mais barato que o Cursor Pro?

Para uso leve a moderado, sim. O Cursor Pro a $20/mês é adequado para desenvolvedores que desejam uma taxa fixa. O RunAPI cobra por token a 50% dos preços de lista do provedor — Claude 3.5 Sonnet custa $1,50/M tokens de entrada. Usuários intensos que ficam dentro do limite Pro podem achar a assinatura mais previsível, mas não há restrições com o RunAPI.

### Posso usar a mesma chave RunAPI no Windsurf e no Claude Code também?

Sim. Uma chave RunAPI funciona no Cursor, Windsurf, Claude Code, Codex e qualquer outra ferramenta que aceite um endpoint personalizado compatível com OpenAI. O uso e os gastos são consolidados em um único painel RunAPI, portanto você não precisa gerenciar chaves ou saldos separados por ferramenta.

### Qual é a URL Base OpenAI que preciso inserir no Cursor?

Defina como https://runapi.ai/v1. O Cursor usa esta URL para todas as requisições de modelo quando a seção OpenAI está ativa. Sem este campo, o Cursor envia suas requisições para api.openai.com em vez disso, o que rejeitará uma chave RunAPI e retornará um erro não autorizado toda vez.

### Usar BYOK no Cursor desativa os recursos integrados do Cursor?

Não. O preenchimento automático, a visualização de diferenças e os recursos de agente do Cursor continuam funcionando. O BYOK apenas muda qual modelo e endpoint o Cursor usa para chat e conclusões inline. Se você definir um modelo que a interface do Cursor não lista por padrão, digite o slug diretamente no seletor de modelo.

### Como sei se minha chave RunAPI está funcionando no Cursor?

Envie uma mensagem curta no chat do Cursor e verifique o painel do RunAPI em Uso. Uma nova entrada de log com o nome do modelo, contagem de tokens e custo aparece alguns segundos após cada requisição. Se nenhuma entrada aparecer, a URL base ou a chave não está alcançando o RunAPI.

