[← Developer docs](https://aictrlx.ru/docs)

Integration

# LiteLLM with aictrlx

LiteLLM, the Python SDK and proxy for many LLM providers, treats aictrlx as a generic OpenAI-compatible provider: prefix the model name with `openai/` and set `api_base`.

## Setup

### Put the key in an environment variable

Every example below reads the key from `AICTRLX_API_KEY`, so it never ends up in your code.

Shell

```
export AICTRLX_API_KEY="aictrlx_live_..."
```

Prefix the model with `openai/` (generic OpenAI-compatible endpoint) and set `api_base`.

Install

```
pip install litellm
```

Python SDK

```
import os

import litellm

response = litellm.completion(
    model="openai/auto",  # "openai/" = any OpenAI-compatible endpoint
    api_base="https://aictrlx.ru/v1",
    api_key=os.environ["AICTRLX_API_KEY"],
    messages=[{"role": "user", "content": "Explain vector databases in two sentences."}],
)
print(response.choices[0].message.content)
```

LiteLLM proxy config.yaml

```
model_list:
  - model_name: aictrlx-auto
    litellm_params:
      model: openai/auto
      api_base: https://aictrlx.ru/v1
      api_key: os.environ/AICTRLX_API_KEY
  - model_name: aictrlx-coding
    litellm_params:
      model: openai/coding
      api_base: https://aictrlx.ru/v1
      api_key: os.environ/AICTRLX_API_KEY
```

## Which model to use

-   `openai/auto` (or `openai/coding`, `openai/smart`, `openai/fast`) for aictrlx routing.
-   `openai/<model id>` for a concrete model from the models page.

[Models and prices →](https://aictrlx.ru/models)

## What it costs

You pay for the tokens the model reads and writes, at the prices per 1M tokens on the models page, in roubles: from the plan's allowance first, then from the balance.

Every request, with its model, tokens and cost, is in the request log of the dashboard.

## If something does not work

-   `401` with `invalid_api_key` or `missing_api_key`: the tool does not send the key, or it is not an active `aictrlx_live_...` key. Create a new one on the API Keys page.
-   `404` with `model_not_found`: the model name is neither a routing mode (`auto`, `fast`, `smart`, `coding`) nor an id from the models page.
-   `403` with `model_not_allowed`: the key is limited to some models; allow this one in the key's settings.
-   `429`: too many requests per minute (`rate_limit_exceeded`), or a quota or budget ran out (`monthly_quota_exceeded` and others).

[All errors and limits →](https://aictrlx.ru/docs#errors)

## Other integrations

-   [Claude Code with aictrlx](https://aictrlx.ru/docs/claude-code)
-   [Cursor with aictrlx](https://aictrlx.ru/docs/cursor)
-   [Continue with aictrlx](https://aictrlx.ru/docs/continue)
-   [LangChain with aictrlx](https://aictrlx.ru/docs/langchain)
-   [Vercel AI SDK with aictrlx](https://aictrlx.ru/docs/vercel-ai-sdk)

## Need a key?

Sign up: the key is in the dashboard a minute later.

[Create a free account →](https://aictrlx.ru/register)

## What's new

New models, routing modes and API changes.

[Changelog →](https://aictrlx.ru/docs/changelog)
