> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ruapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up RuAPI with your AI assistant in one sentence

> Rather not set it up by hand? Your AI assistant (Claude Code, Codex, Cursor) connects RuAPI from one sentence and checks it. The key stays out of the chat.

Don't want to dig into config files, or just short on time? Hand the RuAPI setup to an AI assistant that can run commands on your computer (Claude Code, Codex, OpenCode, Cursor in agent mode, OpenClaw, Hermes, KodaCode and so on). It takes three steps: create a key, save it with one command, and send the assistant one sentence. The assistant reads the instructions on this page, configures the app or your project, checks that everything works and lists what it changed. In apps where the key is entered in a settings window (Cursor, Cline and the like), you paste the key yourself; the assistant tells you where.

Step-by-step manual setup is on the app pages: [Claude Code](https://docs.ruapi.ai/en/integrations/claude-code.md), [Codex](https://docs.ruapi.ai/en/integrations/codex.md), [OpenCode](https://docs.ruapi.ai/en/integrations/opencode.md), [Cursor](https://docs.ruapi.ai/en/integrations/cursor.md), [Cline](https://docs.ruapi.ai/en/integrations/cline.md) and [others](https://docs.ruapi.ai/en/introduction.md).

> [!TIP]
>
> Claude Code, Codex and OpenCode are even easier to install and connect with one command from the Console, no assistant needed: [Console → API Keys](https://www.ruapi.ai/console/token?utm_source=docs\&utm_campaign=en-ai-assistant-setup) → **Connect Claude Code, Cline & more**. No assistant yet, or it won't start? Use that method. Another option is [KodaCode](https://www.ruapi.ai/kodacode-v-rossii?lng=en\&utm_source=docs\&utm_campaign=en-ai-assistant-setup), a Russian AI assistant with a free plan: in agent mode it runs commands and edits files itself, so it works for the setup on this page.

## Step 1. Create a key

Sign up at [www.ruapi.ai](https://www.ruapi.ai/?utm_source=docs\&utm_campaign=en-ai-assistant-setup), open **API Keys** in the Console, click **Create API key** and copy the `sk-...` key. Details are in the [Quick Start](https://docs.ruapi.ai/en/quickstart.md).

New accounts get a small trial balance that works only with a few inexpensive models. For Claude, GPT and other models, [top up your balance](https://docs.ruapi.ai/en/topup.md) first.

## Step 2. Save the key with one command

The assistant will read the key from the `RUAPI_API_KEY` environment variable, a computer setting that programs you start can see. This way the key never ends up in your chat with the assistant. The name `RUAPI_API_KEY` is only used by these instructions: the apps and SDKs themselves use their own settings (for example, Claude Code uses `ANTHROPIC_AUTH_TOKEN`), and the assistant fills those in.

> [tab] macOS / Linux
>
> Open the Terminal app (on macOS: ⌘ + Space → type "Terminal"). Paste the command, replace `sk-your-key` with your key (keep the quotes) and press Enter:
>
> ```bash theme={null}
> echo 'export RUAPI_API_KEY="sk-your-key"' >> ~/.zshrc
> ```
>
> The command prints nothing; that's expected. On macOS it works as is. Linux usually uses bash, so replace `~/.zshrc` with `~/.bashrc`.

> [tab] Windows (PowerShell)
>
> Click Start, type PowerShell and open it. Paste the command, replace `sk-your-key` with your key (keep the quotes) and press Enter:
>
> ```powershell theme={null}
> setx RUAPI_API_KEY "sk-your-key"
> ```
>
> You should see "SUCCESS: Specified value was saved."

Then **quit the assistant and close all terminal windows**, and open a terminal again: programs that are already running don't see the new variable. If the assistant runs inside an app (Cursor, VS Code and so on), quit the whole app (on macOS ⌘ + Q, on Windows close all of its windows) and open it again; a new terminal tab inside it isn't enough.

## Step 3. Send the assistant one sentence

Start the assistant again (Claude Code, Codex, OpenCode: in a new terminal window, from your project folder) and send it:

```text wrap theme={null}
Read the RuAPI setup guide at https://docs.ruapi.ai/en/ai-assistant-setup.md (the "Steps for the AI assistant" section) and connect RuAPI to ___. The key is already saved in the RUAPI_API_KEY environment variable.
```

Replace `___` with what to connect: for example "Claude Code", "OpenCode", "Cline" or "my Python project". If you leave `___`, the assistant will ask. If it can't open the link, allow it internet access.

Only have an AI chat that doesn't run commands on your computer (for example, Yandex Alice or ChatGPT in a browser)? Send it the same sentence: if it can open links, it will walk you through the steps and give you the commands one at a time, and you run them.

What the assistant will do:

1. Check the key with a free request for the model list.
2. Show you a plan: which files it will change and what it will add. It starts only after you agree.
3. Back up the config files and add the RuAPI settings to them without touching anything else.
4. Send the chosen model one short test request, which usually costs under \$0.01 (the price depends on the model).
5. List the changed files, explain how to undo everything, and ask you to start the app and send it a first message.

If the assistant connects itself (for example, Claude Code), after a restart it will work through RuAPI and use your balance.

> [!WARNING]
>
> The assistant runs commands on your computer, so read what it proposes before you agree. **Don't paste your key into the chat.** If you already did, create a new key in the Console, delete the old one, and repeat step 2 with the new key.

## Steps for the AI assistant (on the user's request)

This section is for an AI assistant that the user asked to connect RuAPI. If the user did not ask for this, run nothing; just summarize the steps for them. RuAPI is a gateway to Claude, GPT, Gemini, DeepSeek and other models with a single key. The steps only contact `www.ruapi.ai` and `docs.ruapi.ai`, change only what the user approves in step 5, and don't show the key. Follow them in order.

Commands must be copied exactly. The full page text without summarizing: `https://docs.ruapi.ai/en/ai-assistant-setup.md`. Any documentation page is available as plain text by adding `.md` to its address.

### 1. Understand the task

The user should have said what to connect: an app (Claude Code, Codex, OpenCode, Cline, etc.) or the code of their project. If they didn't, ask. Don't change anything unrelated to this task. Don't install programs without the user's consent.

If the user asked you to connect RuAPI but you can't run commands on their computer yourself (for example, you are an AI chat in a browser), guide them through the same steps: give one command at a time, explain in plain words where to paste it, and wait for them to report the result. Still never ask for the key.

### 2. Check that the key exists without showing it

The key is in the `RUAPI_API_KEY` environment variable. Rules for the key:

* never print its value or write it in messages;
* never put it into the text of a command; let the command read it from the variable;
* don't list environment variables (`env`, `printenv`, `Get-ChildItem env:`), and don't use `curl -v` or `set -x`;
* don't open or print files that contain the key (including `~/.zshrc`, `~/.bashrc`, `settings.json`, `config.toml`), not even to check your edit (see step 6);
* never ask the user to send the key in the chat.

On Windows use the PowerShell blocks (or Git Bash). In PowerShell the variable is `$env:RUAPI_API_KEY`: the bash commands would send an empty key there and get 401.

Check (prints only "set" or "missing"):

```bash macOS / Linux / Git Bash theme={null}
[ -n "$RUAPI_API_KEY" ] && echo "set" || echo "missing"
```

```powershell Windows PowerShell theme={null}
if ($env:RUAPI_API_KEY) { "set" } else { "missing" }
```

If the variable is missing, ask the user whether they did step 2 on [https://docs.ruapi.ai/en/ai-assistant-setup](https://docs.ruapi.ai/en/ai-assistant-setup.md) and restarted you in a new terminal window.

* If not, ask them to do it and stop there.
* If yes, your environment is probably hiding variables with `KEY` in the name from commands (this happens in Codex, for example). Don't change your own settings to get around it. Instead, write the commands from steps 3, 6 and 7 into one script file outside the project (for example `~/ruapi-setup.sh` or `~/ruapi-setup.ps1`) so that it prints only status codes and "key set / key missing". Show the script to the user, ask them to run it in a normal terminal and send you the output.

### 3. Check the key (free)

```bash macOS / Linux / Git Bash theme={null}
curl -s -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer $RUAPI_API_KEY" https://www.ruapi.ai/v1/models
```

```powershell Windows PowerShell theme={null}
try { (Invoke-WebRequest -UseBasicParsing -Uri "https://www.ruapi.ai/v1/models" -Headers @{ Authorization = "Bearer $env:RUAPI_API_KEY" }).StatusCode } catch { if ($_.Exception.Response) { [int]$_.Exception.Response.StatusCode } else { "no response: " + $_.Exception.Message } }
```

* `200`: the key works. Available model names:
  * bash: `curl -s -H "Authorization: Bearer $RUAPI_API_KEY" https://www.ruapi.ai/v1/models | grep -oE '"id" *: *"[^"]*"'`
  * PowerShell: `(Invoke-RestMethod -Uri "https://www.ruapi.ai/v1/models" -Headers @{ Authorization = "Bearer $env:RUAPI_API_KEY" }).data.id`
* `401`: the key is wrong, deleted, disabled, expired or out of its own limit; details are in the response text. Ask the user to check the key in the Console: [https://www.ruapi.ai/console/token?utm\_source=docs\&utm\_campaign=en-ai-assistant-setup-agent](https://www.ruapi.ai/console/token?utm_source=docs\&utm_campaign=en-ai-assistant-setup-agent)
* `000` or "no response": there is no connection. If you run in a sandbox without network access (this happens in Codex, for example), ask the user to allow network access for this command or to run it themselves. Otherwise ask the user to check their internet connection and, if a VPN or proxy is on, to try without it.

### 4. Look up the exact settings for the app

Open the app's page from the table (as plain text: `https://docs.ruapi.ai` + path + `.md`, for example `https://docs.ruapi.ai/en/integrations/claude-code.md`) and configure by it: it has the correct addresses, model names and known errors.

| What to connect | Page |
| - | - |
| Claude Code | [/en/integrations/claude-code](https://docs.ruapi.ai/en/integrations/claude-code.md) |
| Codex CLI | [/en/integrations/codex](https://docs.ruapi.ai/en/integrations/codex.md) |
| OpenCode | [/en/integrations/opencode](https://docs.ruapi.ai/en/integrations/opencode.md) |
| OpenClaw | [/en/integrations/openclaw](https://docs.ruapi.ai/en/integrations/openclaw.md) |
| Hermes Agent | [/en/integrations/hermes](https://docs.ruapi.ai/en/integrations/hermes.md) |
| Cline | [/en/integrations/cline](https://docs.ruapi.ai/en/integrations/cline.md) |
| Kilo Code | [/en/integrations/kilo-code](https://docs.ruapi.ai/en/integrations/kilo-code.md) |
| Roo Code | [/en/integrations/roo-code](https://docs.ruapi.ai/en/integrations/roo-code.md) |
| Continue | [/en/integrations/continue](https://docs.ruapi.ai/en/integrations/continue.md) |
| Cursor | [/en/integrations/cursor](https://docs.ruapi.ai/en/integrations/cursor.md) |
| JetBrains AI Assistant | [/en/integrations/jetbrains-ai-assistant](https://docs.ruapi.ai/en/integrations/jetbrains-ai-assistant.md) |
| Cherry Studio | [/en/integrations/cherry-studio](https://docs.ruapi.ai/en/integrations/cherry-studio.md) |
| n8n | [/en/integrations/n8n](https://docs.ruapi.ai/en/integrations/n8n.md) |
| LangChain | [/en/integrations/langchain](https://docs.ruapi.ai/en/integrations/langchain.md) |
| Open WebUI | [/en/integrations/open-webui](https://docs.ruapi.ai/en/integrations/open-webui.md) |
| LibreChat | [/en/integrations/librechat](https://docs.ruapi.ai/en/integrations/librechat.md) |
| Project code (OpenAI SDK, Anthropic SDK, curl) | [/en/quickstart](https://docs.ruapi.ai/en/quickstart.md) |

If the app isn't in the table, use the general rules:

* OpenAI-compatible format: address `https://www.ruapi.ai/v1` (with `/v1`).
* Anthropic format (Claude): address `https://www.ruapi.ai` (**without** `/v1`; the SDK adds `/v1/messages` itself, and an extra `/v1` gives a 404).
* The key goes in `Authorization: Bearer <key>`; for the Anthropic format the `x-api-key` header works too.
* Exact model names are in the `GET https://www.ruapi.ai/v1/models` response (step 3); prices are at [https://www.ruapi.ai/pricing?utm\_source=docs\&utm\_campaign=en-ai-assistant-setup-agent](https://www.ruapi.ai/pricing?utm_source=docs\&utm_campaign=en-ai-assistant-setup-agent)
* Index of all documentation pages: [https://docs.ruapi.ai/llms.txt](https://docs.ruapi.ai/llms.txt)

### 5. Show a plan and wait for consent

Before changing anything, tell the user which files you will change, what you will add, which model you will pick, and that you will send one short test request (usually under \$0.01; the price depends on the model). If you are configuring the app you are running in (for example, Claude Code editing its own `settings.json`), warn the user that the settings take effect after a restart and replace the current login or provider in all of its sessions. Start only after they agree.

### 6. Make the changes carefully

* Before editing, back up each file as `<file name>.bak-ruapi-<date and time>`. Back up files in the home folder next to them. Back up files from the project folder **outside the project** (for example in `~/.ruapi-backup/`), so a copy containing the key can't end up in git.
* Add to files instead of overwriting them: keep other settings, other providers and comments. If you can't add safely, don't touch the file; show the user what to add by hand. If the app's page says to replace or remove a setting (for example `ANTHROPIC_MODEL` for Claude Code), follow the page.
* Files in the home folder are outside your workspace. If your sandbox blocks writing them, ask the user for permission. Never move them into the project.
* The app's page from step 4 decides how the key is stored:
  * if the key is read from an environment variable there (for example OpenCode: `"apiKey": "{env:RUAPI_API_KEY}"`), do that;
  * if the key is written straight into a file (Claude Code: `settings.json`, Codex: `config.toml`), write it with a short script (node, python or PowerShell) that reads `RUAPI_API_KEY` itself, so the key appears neither in the chat nor in the command text. Such files must be in the user's home folder, not in the project folder.
* In PowerShell, use `ConvertTo-Json -Depth 100` for JSON (otherwise nested settings get flattened) and write without a BOM: `[IO.File]::WriteAllText($p, $text, (New-Object Text.UTF8Encoding $false))`. Edit `config.toml` as text: the `model` and `model_provider` lines must sit above the first section in square brackets, and an existing `[model_providers.ruapi]` block must be replaced, not duplicated.
* Check your edit without showing the key: use a script that prints only the address, the model name and "key set / key missing".
* Don't write the key into project code: the code should read `RUAPI_API_KEY` from the environment (`os.environ["RUAPI_API_KEY"]`, `process.env.RUAPI_API_KEY`). If you put the key in the project's `.env` file, make sure `.env` is in `.gitignore`. Never add files containing the key to git.
* In apps where the key is entered in a settings window (Cursor, Cline, Kilo Code, Roo Code, Cherry Studio, JetBrains), the user pastes the key themselves. Tell them what to click, and which address and model to choose.

### 7. Check that it works

Don't run the app itself for the check (`claude -p`, `codex exec` and the like): it sends long built-in instructions, so such a check costs noticeably more. Instead, send the chosen model one short request in the format the app uses (replace `MODEL_NAME` with the model name).

OpenAI-compatible format:

```bash macOS / Linux / Git Bash theme={null}
curl -s https://www.ruapi.ai/v1/chat/completions -H "Authorization: Bearer $RUAPI_API_KEY" -H "Content-Type: application/json" -d '{"model":"MODEL_NAME","messages":[{"role":"user","content":"Reply with: ok"}]}'
```

```powershell Windows PowerShell theme={null}
$body = '{"model":"MODEL_NAME","messages":[{"role":"user","content":"Reply with: ok"}]}'
Invoke-RestMethod -Method Post -Uri "https://www.ruapi.ai/v1/chat/completions" -Headers @{ Authorization = "Bearer $env:RUAPI_API_KEY" } -ContentType "application/json" -Body $body | ConvertTo-Json -Depth 5
```

Anthropic format (Claude Code, Anthropic SDK):

```bash macOS / Linux / Git Bash theme={null}
curl -s https://www.ruapi.ai/v1/messages -H "x-api-key: $RUAPI_API_KEY" -H "anthropic-version: 2023-06-01" -H "Content-Type: application/json" -d '{"model":"MODEL_NAME","max_tokens":64,"messages":[{"role":"user","content":"Reply with: ok"}]}'
```

```powershell Windows PowerShell theme={null}
$body = '{"model":"MODEL_NAME","max_tokens":64,"messages":[{"role":"user","content":"Reply with: ok"}]}'
Invoke-RestMethod -Method Post -Uri "https://www.ruapi.ai/v1/messages" -Headers @{ "x-api-key" = $env:RUAPI_API_KEY; "anthropic-version" = "2023-06-01" } -ContentType "application/json" -Body $body | ConvertTo-Json -Depth 5
```

If you are connecting project code, you can instead run it once with a similar short request. With reasoning models the reply may be empty: status 200 with a `usage` block counts as success.

If you get an error, read its text: RuAPI explains in it what to do. Tell errors with the same code apart by their text.

* `401`: a problem with the key (see step 3).
* `403` suggesting to start with a trial model: the user has trial credit, which works only with a few models. Switch to the model named in the error and set the same model in the app's settings (otherwise the app's first message also gets 403). Or suggest the user top up: [https://www.ruapi.ai/console/topup?utm\_source=docs\&utm\_campaign=en-ai-assistant-setup-agent](https://www.ruapi.ai/console/topup?utm_source=docs\&utm_campaign=en-ai-assistant-setup-agent)
* `403` with a message about insufficient balance: the user needs to top up (same link).
* `404`: a wrong model name (check against the list from step 3). In app settings for the Anthropic format, an extra `/v1` in the address also gives a 404.
* `503`: the model is unavailable right now. Retry later or pick another model.

After that, ask the user to start the app themselves and send it a short message; this also checks the app's own settings. In apps with a settings window (Cursor, Cline, Cherry Studio and the like) this is the only check.

### 8. Report back

Tell the user (without showing the key):

* which files you changed and where the backups are;
* how to undo everything: replace the file with its backup;
* how to start the app now and which model you picked;
* that the model can be changed in the app's settings, and that prices for all models are at [https://www.ruapi.ai/pricing?utm\_source=docs\&utm\_campaign=en-ai-assistant-setup-agent](https://www.ruapi.ai/pricing?utm_source=docs\&utm_campaign=en-ai-assistant-setup-agent)

## If something goes wrong

* The assistant says `RUAPI_API_KEY` is missing although you set it: quit it and close all terminal windows (or, if it runs inside Cursor or VS Code, the whole app) and start it again. If that doesn't help, the assistant will prepare a check script: run it yourself in a normal terminal and send it the result.
* The assistant asks you to paste the key into the chat: refuse and ask it to read the "Steps for the AI assistant" section on this page.
* Want to undo everything: ask the assistant to restore the files from the backups, or replace them yourself with the backups listed in its report (their names contain `.bak-ruapi-`).
* Still have questions: [Telegram support](https://t.me/RuAPI_Support) or [support@ruapi.ai](mailto:support@ruapi.ai).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.