Skip to main content
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, Codex, OpenCode, Cursor, Cline and others.
Claude Code, Codex and OpenCode are even easier to install and connect with one command from the Console, no assistant needed: Console → API Keys → Connect Claude Code, Cline & more. No assistant yet, or it won’t start? Use that method. Another option is KodaCode, 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, open API Keys in the Console, click Create API key and copy the sk-... key. Details are in the Quick Start. 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 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.
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:
The command prints nothing; that’s expected. On macOS it works as is. Linux usually uses bash, so replace ~/.zshrc with ~/.bashrc.
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:
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.
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”):
macOS Git Bash
Windows PowerShell
If the variable is missing, ask the user whether they did step 2 on https://docs.ruapi.ai/en/ai-assistant-setup 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)

macOS Git Bash
Windows PowerShell
  • 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
  • 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. If the app isn’t in the table, use the general rules: 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:
macOS Git Bash
Windows PowerShell
Anthropic format (Claude Code, Anthropic SDK):
macOS Git Bash
Windows PowerShell
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
  • 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):

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 or support@ruapi.ai.