API для PythonAPI for Python

Для своих скриптов, ботов и парсеров. Ключ хранится в переменной окружения — не в коде и не в Git. Вставь ключ в поле ниже — команды и сниппет соберутся под тебя.For your own scripts, bots and parsers. The key lives in an environment variable — not in code and not in Git. Paste your key below and the commands will be built for you.

Base URL
API KeyAPI Key

Ключ не отправляется с этой страницы: команды собираются локально в браузере. Без галочки выше ключ исчезнет после закрытия страницы. Ключ — как пароль: не показывай его на скриншотах, не отправляй в чаты и не добавляй в Git. Нет ключа — зарегистрируйся: личный ключ выпустится сам. Кнопки скачивания готовых файлов (settings.json, codex-setup.bat) — на странице «Подключение» — генератор конфигураций.Your key never leaves this page: commands are assembled locally in your browser. Without the checkbox above, the key disappears when you close the page. Treat the key like a password: never show it in screenshots, chats, or Git. No key yet? Register — a personal key is issued automatically. Download buttons for ready-made files are on the full connection page.

Как подключить

Какая у тебя система?Your operating system?

API для PythonAPI for Python

Ключ из поля выше автоматически подставляется в команды и конфиги.Your key from the field above is inserted into the commands and configs automatically.

1

Установи библиотеку

Официальный OpenAI SDK — он подходит для нашего API.

В терминале: pip install openai (если pip не найден — python -m pip install openai).

2

Ключ — в переменную окружения

Так ключ не попадёт в код и в Git.

Windows. PowerShell, вставь команду целиком:

macOS / Linux. Terminal, вставь блок целиком:

После команды обязательно перезапусти терминал (и редактор, если запускаешь код из него) — переменная действует только в новых окнах.

3

Запусти первый запрос

Сниппет читает ключ из переменной — в коде его нет.

Стриминг ответа: stream=True. Картинки (vision): файл передаётся в content. Все модели — в таблице, маршруты — в документации.

1

Install the library

The official OpenAI SDK — it works with our API.

In the terminal: pip install openai (if pip is not found — python -m pip install openai).

2

Put the key into an environment variable

This way the key never lands in code or Git.

Windows. PowerShell — paste the whole command:

macOS / Linux. Terminal — paste the whole block:

After the command, be sure to restart the terminal (and the editor, if you run code from it) — the variable only works in new windows.

3

Run the first request

The snippet reads the key from the variable — it's not in the code.

Response streaming: stream=True. Images (vision): the file goes into content. All models — in the table, routes — in the documentation.

Частые ошибки

KeyError: 'AIDOSTUP_API_KEY'
Переменная не видна текущему процессу. После setx (Windows) нужно полностью перезапустить терминал и редактор. Проверить: echo $env:AIDOSTUP_API_KEY (PowerShell) или echo $AIDOSTUP_API_KEY (macOS/Linux).
401 — ключ не принят
В переменную попал не тот ключ или с пробелом. Задай заново из карточки вверху страницы.
404 Not Found
Проверь base_url: он должен заканчиваться на /v1 — как в сниппете выше.
pip не найден
Выполни python -m pip install openai — так гарантированно используется pip твоего Python.
KeyError: 'AIDOSTUP_API_KEY'
The variable isn't visible to the current process. After setx (Windows) you must fully restart the terminal and the editor. Verify: echo $env:AIDOSTUP_API_KEY (PowerShell) or echo $AIDOSTUP_API_KEY (macOS/Linux).
401 — the key is not accepted
The wrong key got into the variable, or it came with a space. Set it again from the card at the top of the page.
404 Not Found
Check base_url: it must end with /v1 — as in the snippet above.
pip is not found
Run python -m pip install openai — this guarantees that the pip of your own Python is used.

Ограничения и совместимость

Сниппет рассчитан на официальный OpenAI SDK версии 1.x и новее; base_url указывается с /v1 на конце.

Если хранишь ключ в .env-файле — обязательно добавь .env в .gitignore: ключ не должен попадать в репозиторий.

Не вставляй ключ в код, который отправляешь кому-то или публикуешь.

The snippet targets the official OpenAI SDK version 1.x and newer; base_url is set with a trailing /v1.

If you keep the key in a .env file — be sure to add .env to .gitignore: the key must not land in the repository.

Never paste the key into code that you send to someone or publish.

Вопросы и ответы

Можно ли вписать ключ прямо в код?
Технически да, но это плохая привычка: ключ уедет в Git или скриншот. Переменная окружения надёжнее — сниппет выше так и делает.
Как включить стриминг ответа?
Добавь stream=True в вызов create() и читай части из цикла. Примеры — в документации.
Работает ли асинхронный клиент?
Да: AsyncOpenAI из того же пакета openai, параметры те же (base_url и api_key).
Какую модель взять для теста?
gpt-5.6-luna — дешёвая и быстрая. Для кода — gpt-5.6-terra. Коэффициенты расхода — в таблице моделей.
Can I put the key right into the code?
Technically yes, but it's a bad habit: the key will leak into Git or a screenshot. An environment variable is safer — the snippet above does exactly that.
How do I enable response streaming?
Add stream=True to the create() call and read the parts from the loop. Examples — in the documentation.
Does the async client work?
Yes: AsyncOpenAI from the same openai package, the same parameters (base_url and api_key).
Which model should I take for a test?
gpt-5.6-luna — cheap and fast. For code — gpt-5.6-terra. Spending coefficients — in the model table.