Перейти к основному содержанию
POST
/
v1
/
responses
Создать response (Responses API)
curl --request POST \
  --url https://polza.ai/api/v1/responses \
  --header 'Content-Type: application/json' \
  --data '
{
  "input": "Hello, how are you?",
  "model": "openai/gpt-4",
  "instructions": "You are a helpful assistant",
  "metadata": {},
  "tools": [
    "<unknown>"
  ],
  "tool_choice": "auto",
  "parallel_tool_calls": false,
  "models": [
    "<string>"
  ],
  "text": {
    "format": "text",
    "verbosity": "medium"
  },
  "reasoning": {
    "effort": "medium",
    "summary": "auto",
    "max_tokens": 5000,
    "enabled": true
  },
  "max_output_tokens": 1000,
  "temperature": 0.7,
  "top_p": 1,
  "top_logprobs": 5,
  "max_tool_calls": 5,
  "presence_penalty": 0,
  "frequency_penalty": 0,
  "top_k": 40,
  "image_config": {},
  "modalities": [
    "text"
  ],
  "prompt_cache_key": "<string>",
  "previous_response_id": "<string>",
  "stream": false,
  "provider": {
    "allow_fallbacks": true,
    "order": [
      "OpenAI",
      "Anthropic"
    ],
    "only": [
      "OpenAI",
      "Google"
    ],
    "ignore": [
      "DeepInfra"
    ],
    "sort": "price",
    "max_price": {
      "prompt": 10,
      "completion": 20,
      "image": 5,
      "audio": 15,
      "request": 1
    }
  },
  "user": "user-123",
  "session_id": "<string>"
}
'
{
  "id": "gen_581761234567890123",
  "object": "response",
  "created_at": 1234567890,
  "model": "openai/gpt-4",
  "status": "completed",
  "output_text": "Hello! How can I help you today?",
  "output": "<array>",
  "completed_at": {},
  "error": {
    "code": "invalid_request",
    "message": "Invalid input format",
    "metadata": {}
  },
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 20,
    "total_tokens": 30,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 100,
      "audio_tokens": 0,
      "image_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    },
    "cost_rub": 0.04131306,
    "cost": 0.04131306
  },
  "metadata": {}
}

О Responses API

Responses API находится в бета-версии. API может измениться без предварительного уведомления.
Responses API — альтернативный формат, совместимый с OpenAI Responses API. Автоматически трансформируется в Chat Completions формат внутри.

Основные параметры

ПараметрТипОписание
modelstringID модели
inputstring / arrayТекст или массив сообщений
instructionsstringСистемные инструкции
streambooleanПотоковая передача через SSE

Дополнительные параметры

ПараметрТипОписание
toolsarrayОпределения инструментов
tool_choicestring/objectВыбор инструмента: none, auto, required
reasoningobjectНастройки reasoning (effort: xhigh/high/medium/low/minimal/none)
max_output_tokensintegerМаксимум выходных токенов
temperaturefloat (0-2)Температура генерации
top_pfloat (0-1)Nucleus sampling
top_logprobsinteger (0-20)Количество log probabilities
previous_response_idstringID предыдущего ответа для продолжения
modelsarrayМассив fallback-моделей
textobjectФормат текста: text, json_object, json_schema
metadataobjectПроизвольные key-value данные

Примеры

curl -X POST "https://polza.ai/api/v1/responses" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o",
    "input": "Расскажи о квантовых компьютерах"
  }'

Streaming

При stream: true ответ приходит в формате SSE с типами событий:
СобытиеОписание
response.createdОтвет создан
response.output_item.addedНовый элемент вывода
response.content_part.deltaИнкрементальный контент
response.content_part.doneЧасть контента завершена
response.doneОтвет завершён

Тело

application/json
input
обязательно

Input for response - can be string or array of messages

Пример:

"Hello, how are you?"

model
string
обязательно

Model to use

Пример:

"openai/gpt-4"

instructions
string

System instructions

Пример:

"You are a helpful assistant"

metadata
object

Metadata key-value pairs

tools
any[]

Tools available for the model

tool_choice

Tool choice strategy

Доступные опции:
none,
auto,
required
Пример:

"auto"

parallel_tool_calls
boolean
по умолчанию:false

Enable parallel tool calls

models
string[]

Alternative models to try

text
object

Text output configuration

reasoning
object

Reasoning configuration

max_output_tokens
number

Maximum output tokens

Пример:

1000

temperature
number

Temperature (0-2)

Требуемый диапазон: 0 <= x <= 2
Пример:

0.7

top_p
number

Top P (nucleus sampling)

Требуемый диапазон: 0 <= x <= 1
Пример:

1

top_logprobs
number

Top logprobs

Требуемый диапазон: 0 <= x <= 20
Пример:

5

max_tool_calls
number

Maximum tool calls

Пример:

5

presence_penalty
number

Presence penalty (-2 to 2)

Требуемый диапазон: -2 <= x <= 2
frequency_penalty
number

Frequency penalty (-2 to 2)

Требуемый диапазон: -2 <= x <= 2
top_k
number

Top K sampling

Пример:

40

image_config
object

Image configuration options

modalities
enum<string>[]

Output modalities

Доступные опции:
text,
image
prompt_cache_key
string

Prompt cache key

previous_response_id
string

Previous response ID

stream
boolean
по умолчанию:false

Enable streaming

provider
object

Provider preferences

user
string

Уникальный идентификатор конечного пользователя для отслеживания и предотвращения злоупотреблений

Пример:

"user-123"

session_id
string

Session identifier (max 128 chars)

Ответ

id
string
обязательно

Response ID

Пример:

"gen_581761234567890123"

object
enum<string>
обязательно
Доступные опции:
response
Пример:

"response"

created_at
number
обязательно

Created timestamp

Пример:

1234567890

model
string
обязательно

Model used

Пример:

"openai/gpt-4"

status
enum<string>
обязательно
Доступные опции:
completed,
in_progress,
failed,
cancelled
Пример:

"completed"

output_text
string
обязательно

Full output text (convenience field)

Пример:

"Hello! How can I help you today?"

output
array
обязательно

Output items array

completed_at
object

Completed timestamp

error
object

Error information

usage
object

Usage information

metadata
object

Metadata key-value pairs