GETAPIdocs
Войти
Создать аккаунт
GETAPI/Документация/Генерация текста

Генерация текста

Базовый сценарий — отправить список сообщений и получить ответ модели. Поддерживаются оба способа: классический chat/completions и новый responses с отдельным reasoning-блоком.

Chat Completions

curl https://api.getapi.ru/openai/v1/chat/completions \
  -H "Authorization: Bearer $GETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "Ты помощник по русскому языку."},
      {"role": "user", "content": "Напиши синонимы к слову '\''быстрый'\''."}
    ],
    "temperature": 0.4,
    "max_tokens": 200
  }'

Responses API

Удобен для агентов и моделей с reasoning — поддерживает «мысленные» блоки, которые модель может скрывать от пользователя. Принимает input любого формата: строка, массив, мультимодальный список.

curl https://api.getapi.ru/openai/v1/responses \
  -H "Authorization: Bearer $GETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "o4-mini",
    "input": [{"role": "user", "content": "Реши уравнение x^2 - 5x + 6 = 0"}],
    "reasoning": {"effort": "medium"}
  }'

Streaming

curl https://api.getapi.ru/openai/v1/chat/completions \
  -H "Authorization: Bearer $GETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Расскажи короткую сказку"}],
    "stream": true
  }'

JSON и Structured outputs

curl https://api.getapi.ru/openai/v1/chat/completions \
  -H "Authorization: Bearer $GETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Извлеки имя и возраст из текста: Анне 28 лет."}],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "person",
        "schema": {
          "type": "object",
          "properties": {
            "name": {"type": "string"},
            "age": {"type": "integer"}
          },
          "required": ["name", "age"]
        },
        "strict": true
      }
    }
  }'

Function calling

curl https://api.getapi.ru/openai/v1/chat/completions \
  -H "Authorization: Bearer $GETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Какая погода в Москве?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Получить текущую погоду",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string"}},
          "required": ["city"]
        }
      }
    }]
  }'
Назад
Поддержка API OpenAI
Далее
Запрос по изображению