Чат, совместимый с OpenAI
Направьте OpenAI SDK на NeuronAI и получайте ответы чата от моделей, доступных вашей организации.
Как это работает
- 01
Укажите базовый URL клиента:
https://my.neuronai.uz/api/v1. - 02
Получите список идентификаторов моделей через
GET /models. - 03
Отправьте массив
messagesвPOST /chat/completions, а для потокового ответа добавьтеstream: true.
Аутентификация
OpenAI SDK передают ключ как Authorization: Bearer, поэтому укажите ключ NeuronAI как API ключ SDK. Для списка моделей нужно право llm:read, для чата — llm:write.
Пример
Запросы и ответы сохраняют формат chat completions, поэтому для перехода приложению достаточно сменить настройки. Ошибки приходят в объекте ошибки OpenAI с добавленным request_id.
Справочник API
Поля запросов, ответы, цены и примеры кода для каждого эндпоинта, а также форма, которая отправляет настоящий запрос.
Хранится только в вашем браузере.
LLM
OpenAI-compatible chat completions. Point any OpenAI SDK at this base URL and authenticate with your API key.
POST /v1/chat/completions
Create chat completion
Generates a model response for a chat conversation. OpenAI-compatible — set your OpenAI SDK's base URL to `{app}/api/v1` and use your API key. Set `stream: true` for a Server-Sent Events stream of `chat.completion.chunk` objects ending with `[DONE]` (the chunk before it carries `usage` when the model reports its token counts). Billed per token (prompt + completion).
Pricing
per 1K tokens- Input
- 1.5 credits
- Output
- 6 credits
Тело запроса
| Поле | Описание |
|---|---|
modelОбязательноstring | maxLen: 128 |
max_tokensinteger | null | min: 1 |
temperaturenumber | null | min: 0 · max: 2 |
top_pnumber | null | min: 0 · max: 1 |
stopobject | Text at which the model stops: one string, or a list of strings (OpenAI's `stop`). Sent to the model exactly as given, byte for byte, including a string of only whitespace such as `\n`. |
streamboolean | null | |
messagesОбязательноobject[] |
Ответы
| Заголовок | Описание |
|---|---|
X-Costnumber | The price billed, in credits. Sent with the JSON completion; a stream is billed when it ends, so it carries none. |
X-Accel-Bufferingstring | Sent as `no` with a stream: it tells a proxy such as nginx not to hold back the events. |
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
| Поле | Описание |
|---|---|
idОбязательноstring | |
objectОбязательноstring | |
createdОбязательноinteger | |
modelОбязательноstring | |
choicesОбязательноobject[] | |
usageОбязательноobject |
X-Request-Id: string| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
| Заголовок | Описание |
|---|---|
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
| Заголовок | Описание |
|---|---|
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
| Заголовок | Описание |
|---|---|
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
| Заголовок | Описание |
|---|---|
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
| Заголовок | Описание |
|---|---|
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
Retry-Afterinteger | Seconds to wait before retrying. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
X-RateLimit-Resetinteger | When the rate limit lets requests through again, as a Unix time in seconds. Sent with a 429 for `rate_limit_exceeded`. |
| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
| Заголовок | Описание |
|---|---|
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
| Заголовок | Описание |
|---|---|
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
Retry-Afterinteger | Seconds to wait before retrying. Sent with a 503 during maintenance, when a retry time was set. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
Примеры
Попробовать
Укажите API-ключ в панели выше, чтобы отправлять запросы с ключом.
GET /v1/models
List models
Lists the chat models available to your account.
Ответы
| Заголовок | Описание |
|---|---|
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
| Поле | Описание |
|---|---|
objectОбязательноstring | |
dataОбязательноobject[] |
X-Request-Id: string| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
X-Request-Id: string| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
| Заголовок | Описание |
|---|---|
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
Retry-Afterinteger | Seconds to wait before retrying. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
X-RateLimit-Resetinteger | When the rate limit lets requests through again, as a Unix time in seconds. Sent with a 429 for `rate_limit_exceeded`. |
| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
| Заголовок | Описание |
|---|---|
X-Request-Idstring | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
Retry-Afterinteger | Seconds to wait before retrying. Sent with a 503 during maintenance, when a retry time was set. |
X-RateLimit-Limitinteger | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
X-RateLimit-Remaininginteger | How many of them are left this minute. |
| Поле | Описание |
|---|---|
errorОбязательноobject | |
request_idОбязательноstring | The same ID as the `X-Request-Id` header. format: uuid |
Примеры
Попробовать
Укажите API-ключ в панели выше, чтобы отправлять запросы с ключом.