IN ENGLISH · IDE

Connect Cursor to an AI API from Iran: the complete guide

By default Cursor connects to OpenAI's own API, which is not reachable from Iran. The way round is a feature of Cursor itself: overriding the base URL. With two fields in the settings, a 1xAi key and the OpenAI-compatible base URL, the editor's chat works with your own key, without a VPN and without a foreign card.

[01]STEPS

Setting up Cursor

  1. [01]

    Create an account and a 1xAi key. Register at 1xai.ir (the app is in Persian) and confirm your email or mobile number. You spin the sign-up gift wheel (from 100,000 to 1,000,000 Toman of gift credit) once, which is enough to test the connection. Then create a 1xai-* key in the dashboard and copy it at once: a key is shown only once.

  2. [02]

    Open the model settings. In Cursor open the settings (Ctrl/Cmd + Shift + J) and go to Models.

  3. [03]

    Enter the key under OpenAI API Key. Paste the 1xai-* key into the OpenAI API Key field, exactly where it accepts OpenAI's own key.

  4. [04]

    Switch on Override OpenAI Base URL. Enable Override OpenAI Base URL and enter https://1xai.ir/v1. Without this step the 1xAi key is not accepted.

  5. [05]

    Verify the connection. Press Verify. When the key and the address are right, the connection is confirmed and the models are enabled.

  6. [06]

    Choose a model and send a first message. Enable one of the listed models, or add a name of your own with Add model (a Claude or Gemini id, for example), and send a message in Cursor's chat. The Toman cost of that call is recorded in the 1xAi dashboard.

[02]CONFIGURATION

Ready to copy

Cursor → Settings → Modelsini
; Cursor Settings (Ctrl/Cmd + Shift + J) → Models
OpenAI API Key           = 1xai-XXXXXXXXXXXXXXXX
Override OpenAI Base URL = https://1xai.ir/v1

;   claude-sonnet-4-6   → Anthropic
;   gemini-2.5-flash    → Google
[03]MODEL

Recommended model

Recommended: claude-sonnet-4-6. A cheaper alternative: gpt-4o-mini. For chat and code edits the recommended model balances coding quality and cost; for light, quick questions the alternative is far cheaper. Every model and its Toman price is on the models page.

[04]TROUBLESHOOTING

Common errors

Verify fails
Make sure the address is exactly https://1xai.ir/v1, with /v1 at the end and no extra slash, and that the key was pasted without a leading or trailing space. The service's current state is on the status page.
401: invalid key
The key is wrong, has expired, or you revoked it. Copy it again from the dashboard or create a new one, with no space before or after it.
402: insufficient balance
The account's Toman credit is used up. A top-up starts at 100,000 Toman, by the Zarinpal gateway or the Digipay gateway or card-to-card transfer with a receipt; calls work again as soon as a payment succeeds.
Model name or routing error
1xAi routes by model name: claude-* to Anthropic, gemini-* to Google, deepseek-* to DeepSeek; grok-*, kimi-*, glm-*, qwen*, MiniMax-* and hy* reach the Grok, Kimi, GLM, Qwen, MiniMax and Hunyuan models; every other name goes to OpenAI. Write a model id exactly as the model list shows it.

Every error code is in the error reference.

FAQ · IN ENGLISH

Do Claude and Gemini models work in Cursor this way?

Yes. 1xAi routes by model name, so adding a Claude or Gemini id with Add model is enough. The same key and the same base URL serve all ten vendors.

What does it cost to start with Cursor and 1xAi?

The sign-up gift wheel (from 100,000 to 1,000,000 Toman of gift credit) is enough to test the connection fully. After that, a top-up starts at 100,000 Toman, by the Zarinpal gateway or the Digipay gateway or card-to-card transfer with a receipt; each model costs its vendor's list price plus a markup of 15–30% depending on the model.

Other guides: Claude Code, n8n, Cline, Open WebUI, LibreChat, Continue.

1xAi is an independent gateway. It is not affiliated with, endorsed by, or a reseller for OpenAI, Anthropic, Google, DeepSeek, xAI, Moonshot AI, Z.ai, Alibaba Qwen, MiniMax or Tencent Hunyuan. Requests are relayed upstream rather than answered by models of our own, so each provider's own usage policies apply to what their models will and will not do, and their model availability is theirs to change. Current reachability is published on the status page.