Connect Open WebUI to an AI API from Iran
Open WebUI is the most popular self-hosted chat interface: a personal ChatGPT on your own server or laptop. Two environment variables connect it to 1xAi, so that the models of all ten vendors are available in the same interface with one key billed in Toman.
Setting up Open WebUI
- [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]
Run the container with the environment variables. When starting Docker, set OPENAI_API_BASE_URL=https://1xai.ir/v1 and OPENAI_API_KEY to the 1xai-* key. The variables have to be defined before the container starts.
- [03]
Or: set it in the admin panel. If Open WebUI is already running, open Admin Panel → Settings → Connections, the OpenAI API section, and enter and save the address and the key there.
- [04]
Choose a model. The model list is read automatically from /v1/models. Pick the model you want from the selector at the top of the chat page.
- [05]
A first conversation. Send a message to confirm the connection. The Toman cost of each call is recorded in the usage report of the 1xAi dashboard.
Ready to copy
docker run -d -p 3000:8080 \ -e OPENAI_API_BASE_URL=https://1xai.ir/v1 \ -e OPENAI_API_KEY=1xai-XXXXXXXXXXXXXXXX \ -v open-webui:/app/backend/data \ --name open-webui \ ghcr.io/open-webui/open-webui:main
Recommended model
Recommended: gpt-5. A cheaper alternative: gpt-4o-mini. Use a strong model for the main conversation and switch to a light one for everyday, repetitive work; Open WebUI's model selector makes the switch one click. Every model and its Toman price is on the models page.
Common errors
- The model list is empty
- The environment variables have to be set before the container starts; restart the container after every change. Make sure the address ends in /v1 and that the connection is switched on under Connections.
- 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.
Can I have several models from several vendors at once?
Yes, with that one connection. 1xAi returns every priced model from /v1/models and routes by model name to the right vendor, so the models of all ten vendors appear side by side in the model selector.
Is the text of my conversations stored anywhere?
The chat history stays on your own server (Open WebUI's volume). 1xAi passes the request to the vendor of that model. Next to each usage record, the start of the request and of the response (up to 64 KB each) and, when it is longer, its last 16 KB are kept so that you can read them in your own usage report. That text is erased after 30 days. The numbers (model, tokens, cost, status and time) stay for accounting.
Other guides: Cursor, Claude Code, n8n, Cline, 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.