Перейти к содержанию

Чат, совместимый с OpenAI

Направьте OpenAI SDK на NeuronAI и получайте ответы чата от моделей, доступных вашей организации.

Как это работает

  1. 01

    Укажите базовый URL клиента: https://my.neuronai.uz/api/v1.

  2. 02

    Получите список идентификаторов моделей через GET /models.

  3. 03

    Отправьте массив messages в POST /chat/completions, а для потокового ответа добавьте stream: true.

Аутентификация

OpenAI SDK передают ключ как Authorization: Bearer, поэтому укажите ключ NeuronAI как API ключ SDK. Для списка моделей нужно право llm:read, для чата — llm:write.

Пример

Запросы и ответы сохраняют формат chat completions, поэтому для перехода приложению достаточно сменить настройки. Ошибки приходят в объекте ошибки OpenAI с добавленным request_id.

cURL
curl -X POST "https://my.neuronai.uz/api/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your-api-key>" \
  -d '{
    "model": "gemma-4-26b-a4b",
    "messages": [
      {"role": "user", "content": "Salom! Bugun ob-havo qanday?"}
    ]
  }'

Справочник API

Поля запросов, ответы, цены и примеры кода для каждого эндпоинта, а также форма, которая отправляет настоящий запрос.

Хранится только в вашем браузере.

LLM

OpenAI-compatible chat completions. Point any OpenAI SDK at this base URL and authenticate with your API key.

POST
/v1/chat/completions

Bearer

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
Тело запроса
application/json
ПолеОписание
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[]
Ответы
200
The completion: one choice holding the assistant's message, and `usage` counting the tokens billed. With `stream: true`, the completion comes as Server-Sent Events instead (`text/event-stream`).
application/json
text/event-stream
ЗаголовокОписание
X-CostnumberThe price billed, in credits. Sent with the JSON completion; a stream is billed when it ends, so it carries none.
X-Accel-BufferingstringSent as `no` with a stream: it tells a proxy such as nginx not to hold back the events.
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
ПолеОписание
idОбязательноstring
objectОбязательноstring
createdОбязательноinteger
modelОбязательноstring
choicesОбязательноobject[]
usageОбязательноobject
401
The API key is missing or not recognized (`invalid_api_key`), revoked (`api_key_revoked`), disabled (`api_key_disabled`) or expired (`api_key_expired`).
application/json
ЗаголовокX-Request-Id: string
ПолеОписание
errorОбязательноobject
request_idОбязательноstring

The same ID as the `X-Request-Id` header.

format: uuid

402
Not enough balance for the most this request can cost (`insufficient_balance`), or that cost would pass this key's monthly spend limit (`spend_limit_exceeded`). Nothing is charged.
application/json
ЗаголовокОписание
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
ПолеОписание
errorОбязательноobject
request_idОбязательноstring

The same ID as the `X-Request-Id` header.

format: uuid

403
The key lacks the permission this endpoint needs (`insufficient_permissions`), or the client IP is not in its allowlist (`ip_not_allowed`).
application/json
ЗаголовокОписание
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
ПолеОписание
errorОбязательноobject
request_idОбязательноstring

The same ID as the `X-Request-Id` header.

format: uuid

404
`model` is not one of the models `GET /api/v1/models` lists: `model_not_found`.
application/json
ЗаголовокОписание
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
ПолеОписание
errorОбязательноobject
request_idОбязательноstring

The same ID as the `X-Request-Id` header.

format: uuid

422
The request failed validation (`invalid_request`: `error.param` names the first invalid field and `error.fields` maps each one to its message), or the prompt, with room for `max_tokens` (the server's cap when it is left out), does not fit the model's context window (`context_length_exceeded`).
application/json
ЗаголовокОписание
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
ПолеОписание
errorОбязательноobject
request_idОбязательноstring

The same ID as the `X-Request-Id` header.

format: uuid

429
Too many requests: the per-minute rate limit is used up (`rate_limit_exceeded`), or this key or its organization already has as many requests in flight as it may (`concurrency_limit_exceeded`). Wait `Retry-After` seconds, then retry.
application/json
ЗаголовокОписание
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
Retry-AfterintegerSeconds to wait before retrying.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
X-RateLimit-ResetintegerWhen 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

502
Without `stream`: the model failed or could not be reached, `upstream_error`. Nothing is charged. A stream reports a failure as an event instead.
application/json
ЗаголовокОписание
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
ПолеОписание
errorОбязательноobject
request_idОбязательноstring

The same ID as the `X-Request-Id` header.

format: uuid

default
Any other error, in the same envelope. For example `server_error` (500) when something fails unexpectedly, `service_unavailable` (503) while the API is down for maintenance, or `input_too_large` (413) when the request body is larger than the server accepts.
application/json
ЗаголовокОписание
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
Retry-AfterintegerSeconds to wait before retrying. Sent with a 503 during maintenance, when a retry time was set.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
ПолеОписание
errorОбязательноobject
request_idОбязательноstring

The same ID as the `X-Request-Id` header.

format: uuid

Примеры
cURL
curl -X POST "https://my.neuronai.uz/api/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your-api-key>" \
  -d '{
    "model": "gemma-4-26b-a4b",
    "messages": [
      {"role": "user", "content": "Salom! Bugun ob-havo qanday?"}
    ]
  }'

Попробовать

Укажите API-ключ в панели выше, чтобы отправлять запросы с ключом.

application/json

GET
/v1/models

Bearer

List models

Lists the chat models available to your account.

Ответы
200
The chat models, in OpenAI's list shape. Send a model's `id` as `model`. `created` is always `0`.
application/json
ЗаголовокОписание
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
ПолеОписание
objectОбязательноstring
dataОбязательноobject[]
401
The API key is missing or not recognized (`invalid_api_key`), revoked (`api_key_revoked`), disabled (`api_key_disabled`) or expired (`api_key_expired`).
application/json
ЗаголовокX-Request-Id: string
ПолеОписание
errorОбязательноobject
request_idОбязательноstring

The same ID as the `X-Request-Id` header.

format: uuid

403
The key lacks the permission this endpoint needs (`insufficient_permissions`), or the client IP is not in its allowlist (`ip_not_allowed`).
application/json
ЗаголовокX-Request-Id: string
ПолеОписание
errorОбязательноobject
request_idОбязательноstring

The same ID as the `X-Request-Id` header.

format: uuid

429
Too many requests: the per-minute rate limit is used up (`rate_limit_exceeded`). Wait `Retry-After` seconds, then retry.
application/json
ЗаголовокОписание
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
Retry-AfterintegerSeconds to wait before retrying.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
X-RateLimit-ResetintegerWhen 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

default
Any other error, in the same envelope. For example `server_error` (500) when something fails unexpectedly, or `service_unavailable` (503) while the API is down for maintenance.
application/json
ЗаголовокОписание
X-Request-IdstringIdentifies this request. A JSON body carries it as `request_id` too; quote it to support.
Retry-AfterintegerSeconds to wait before retrying. Sent with a 503 during maintenance, when a retry time was set.
X-RateLimit-LimitintegerThe 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-RemainingintegerHow many of them are left this minute.
ПолеОписание
errorОбязательноobject
request_idОбязательноstring

The same ID as the `X-Request-Id` header.

format: uuid

Примеры
TypeScript SDK
import {NeuronAI} from "@naiuz/sdk";

const client = new NeuronAI();

const models = await client.models.list();

for (const model of models.data) {
    console.log(model.id);
}

Попробовать

Укажите API-ключ в панели выше, чтобы отправлять запросы с ключом.