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

Create chat completion

POSThttps://my.neuronai.uz/api/v1/chat/completions

Generates the assistant's next message in a conversation.

It works with OpenAI's SDKs: set their base URL to https://my.neuronai.uz/api/v1 and use your NeuronAI key. Set stream: true to receive the reply as it is written. Billed per token, for the prompt and the reply.

Нужен API-ключ с llm:write.

Стоимость
за 1000 токенов
Input
1,5 кредита
Output
6 кредитов

Тело запроса

application/json

JSON-объект.

  • modelstringОбязательно

    Макс. длина: 128

  • max_tokensinteger | nullНеобязательный

    Минимум: 1

  • temperaturenumber | nullНеобязательный

    Минимум: 0 · Максимум: 2

  • top_pnumber | nullНеобязательный

    Минимум: 0 · Максимум: 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Необязательный
  • messagesobject[]Обязательно

Ответ

200application/jsontext/event-stream

The reply, and the tokens billed in usage. With stream: true, server-sent events instead.

  • idstringОбязательно
  • objectstringОбязательно
  • createdintegerОбязательно
  • modelstringОбязательно
  • choicesobject[]Обязательно
  • usageobjectОбязательно

Заголовки

  • 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.

    Формат: uuid

  • 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.

Ошибки

  • 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).

  • 402

    Not enough balance (insufficient_balance), or over the key's monthly spend limit (spend_limit_exceeded). Nothing is charged.

  • 403

    The key lacks the permission this endpoint needs (insufficient_permissions), or the client IP is not in its allowlist (ip_not_allowed).

  • 404

    model is not one of the models GET /api/v1/models lists: model_not_found.

  • 422

    The request failed validation (invalid_request), or the prompt with room for max_tokens does not fit the model's context (context_length_exceeded).

  • 429

    A rate or concurrency limit was reached (rate_limit_exceeded, concurrency_limit_exceeded). Retry after Retry-After seconds.

  • 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.

  • default

    Any other error, in the same shape, such as server_error (500) or service_unavailable (503).