Skip to main content
POST
Generate Chat Completions

Authorizations

Authorization
string
header
required

Your Nugen API key, sent as a Bearer token

Headers

X-Session-ID
string | null

Session identifier for multi-turn conversation tracking

Body

application/json

A chat completion request in the OpenAI format.

model
string
required

Use your aligned model id (e.g. model_01kmqm4nrn9fw6r). The same aligned id serves chat completions, embeddings and reranking.

Example:

"model_01kmqm4nrn9fw6r"

messages
ChatCompletionRequestMessage · object[]
required

A list of messages comprising the conversation so far.

Minimum array length: 1
max_tokens
integer | null
default:200

The maximum number of tokens to generate in the completion.

prompt_truncate_len
integer | null
default:1500

The size to which to truncate chat prompts.

temperature
number | null
default:0.75

What sampling temperature to use, between 0 and 2.

Required range: 0 <= x <= 2
stream
boolean | null
default:true

Stream partial progress as server-sent events. Defaults to true; null means true. Set false for one JSON response, which must complete within 50 seconds or the call answers 504. Use true for long generations.

tools
Tools · object[] | null

List of tools/functions

tool_choice

'auto', 'none', or specific tool

top_p
number | null

Nucleus sampling

top_k
integer | null

Top-k sampling

n
integer | null
default:1

Number of completions

reasoning
ChatCompletionReasoning · object | null

Reasoning configuration for the model

stream_options
Stream Options · object | null

Options for streaming responses, e.g., {'include_usage': true}

Response

Streaming chat completion responses or complete response depending on stream parameter

A chat completion response in the OpenAI format, with a confidence score on aligned models.

id
string
required

A unique identifier of the response.

created
number
required

The Unix time in seconds when the response was generated.

model
string
required

The model used for the chat completion.

choices
ChatCompletionChoice · object[]
required

The list of chat completion choices.

confidence_score
number | null
required

Confidence Score from Domain-Aligned AI

object
string
default:chat.completion

The object type, which is always "chat.completion".

Allowed value: "chat.completion"
usage
ChatCompletionUsage · object | null

Usage statistics.

For streaming responses, usage field is included in the very last response chunk returned.

Note that returning usage for streaming requests is a popular LLM API extension. If you use any popular LLM SDK, you might access the field directly even if it's not present in the type signature in the SDK.