Connect n8n to an AI API from Iran: the complete guide
In n8n every AI node, from the OpenAI node to AI Agent and the LLM chains, works with a credential. That credential has a Base URL field; put 1xAi's address there in place of OpenAI's own and all your workflows run from Iran, billed in Toman.
Setting up n8n
- [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.
- [02]
Create a new credential of type OpenAI. In n8n go to Credentials, press Create Credential and choose the type OpenAI.
- [03]
Enter the key and the base URL. Put the 1xai-* key in the API Key field and change the Base URL field to https://1xai.ir/v1. Then save.
- [04]
Choose the credential in your nodes. In the OpenAI node, or the AI Agent and Basic LLM Chain nodes, choose this credential and write the model name; a small, cheap model suits high-volume automations.
- [05]
Run the workflow once as a test. Do a test run. The Toman cost of each call is recorded at once in the usage report of the 1xAi dashboard, and you can separate each workflow's usage with a key of its own.
Ready to copy
; n8n → Credentials → Create Credential → OpenAI API Key = 1xai-XXXXXXXXXXXXXXXX Base URL = https://1xai.ir/v1 ; gpt-4o-mini → OpenAI ; claude-haiku-4-5 → Anthropic ; gemini-2.5-flash → Google
Recommended model
Recommended: gpt-4o-mini. A cheaper alternative: gemini-2.5-flash. Automations usually run often; a light model keeps the cost of each run minimal. Put a stronger model only on the complex steps (analysis, long text). Every model and its Toman price is on the models page.
Common errors
- The model drop-down does not load
- Type the model name by hand. n8n reads the list from /v1/models, and when that is unavailable for a moment, typing the name is entirely sufficient.
- Create a separate key for each workflow
- In the dashboard you can issue several keys, each with its own name and even its own spend cap; each automation's usage is then visible, and one faulty workflow cannot use up the whole balance.
- 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.
Which n8n nodes work with this credential?
Every node that accepts a credential of type OpenAI: the OpenAI node, AI Agent, Basic LLM Chain and the other language-model nodes. Because 1xAi speaks the OpenAI-compatible API, n8n sees no difference from OpenAI itself.
Which model is economical for high-volume automation?
Light models are usually enough for classification, summaries and short answers, and keep the cost minimal. Prices are the vendor's list price plus a markup of 15–30% depending on the model; estimate your monthly cost with 1xAi's calculator.
Other guides: Cursor, Claude Code, 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.