IN ENGLISH · VS CODE CODING AGENT

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

Cline is an open-source coding agent extension for VS Code: it creates files, edits them and runs commands. For the model, choose the OpenAI Compatible provider and give it 1xAi's base URL and key; it then works from Iran with nothing else in between.

[01]STEPS

Setting up Cline

  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]

    Install the Cline extension. In VS Code install Cline from Extensions and open its icon in the side bar.

  3. [03]

    Choose the OpenAI Compatible provider. In Cline's settings set API Provider to OpenAI Compatible, not OpenAI; it is the Compatible option that allows a custom base URL.

  4. [04]

    Enter the base URL and the key. Set Base URL to https://1xai.ir/v1 and enter the 1xai-* key in the API Key field.

  5. [05]

    Set the Model ID. Write the exact model name in the Model ID field. Copy the name from 1xAi's models page.

  6. [06]

    A first task. Give it a simple task (for example "explain this file") to confirm the connection. The Toman cost of each call is recorded in the 1xAi dashboard.

[02]CONFIGURATION

Ready to copy

Cline → Settings → API Configurationini
; Cline (VS Code) → Settings → API Configuration
API Provider = OpenAI Compatible
Base URL     = https://1xai.ir/v1
API Key      = 1xai-XXXXXXXXXXXXXXXX
Model ID     = claude-sonnet-4-6
[03]MODEL

Recommended model

Recommended: claude-sonnet-4-6. A cheaper alternative: gpt-4o-mini. Coding agents such as Cline make several calls in a row for each task; the recommended model keeps multi-file edits good, and for small tasks the alternative lowers the cost. Every model and its Toman price is on the models page.

[04]TROUBLESHOOTING

Common errors

Usage higher than expected
Agents make several calls per task and send all the context files. When you create the key in the dashboard you can set a spend cap for that key, so that Cline's usage cannot pass a set amount.
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

Why OpenAI Compatible and not OpenAI?

Cline's OpenAI option is tied to the official address api.openai.com. OpenAI Compatible speaks the same protocol with a base URL of your choice, and since 1xAi follows exactly that standard, you change only the address and the key.

Can I switch between Claude and GPT with one key?

Yes. Change only the Model ID. 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. The key, the address and the Toman bill stay the same.

Other guides: Cursor, Claude Code, n8n, 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.