Skip to main content
POST
Create chat completion

Authorizations

Authorization
string
header
required

Bearer token authentication using your Perceptron API key

Body

application/json
messages
(System · object | Developer · object | User · object | Assistant · object | Tool · object)[]
required

Conversation history listed in order. Supported roles: system, developer (treated as system), user, assistant, tool.

Author role of the message: system, developer, user, assistant, or tool.

model
string
required

The model to invoke. Use GET /v1/models to discover available model IDs. New Perceptron requests should use perceptron-mk1.5.

frequency_penalty
number<float> | null

Positive values discourage the model from repeating previously used tokens.

Required range: -2 <= x <= 2
max_completion_tokens
integer<int32> | null

Maximum number of completion tokens to generate. Must fit within the selected model's context and output limits.

Required range: x >= 0
n
integer<int32> | null

Number of completions to generate. Only 1 is supported; greater values are rejected.

Required range: 1 <= x <= 1
parallel_tool_calls
boolean | null

Whether the model may call several functions in one turn. Defaults to true. Ignored without functions in tools.

presence_penalty
number<float> | null

Positive values encourage the model to introduce new concepts.

Required range: -2 <= x <= 2
reasoning_effort
null | enum<string>

How much the model reasons before it answers: none, minimal, low, medium or high. A tier other than none turns reasoning on. vision_config.enable_thinking, when set, decides whether the model reasons; the tier then only applies while reasoning is on.

Available options:
none,
minimal,
low,
medium,
high
regex
string | null

Regex pattern for constrained generation.

response_format
object

An object specifying the format that the model must output. Setting to { "type": "json_schema", "json_schema": {...} } enables Structured Outputs which ensures the model will match your supplied JSON schema.

stream
boolean | null
default:false

Set to true for SSE streaming. When omitted, the API returns a single JSON response.

stream_options
null | object

Optional streaming flags. Token usage is always reported in the final chunk of a streaming response.

temperature
number<float> | null

Sampling temperature. Lower values yield deterministic replies; higher values explore more creative outputs.

Required range: 0 <= x <= 2
tool_choice

Whether the model may call the declared functions: auto (the default) or none. none is best effort and does not guarantee a response without tool calls. Forcing a call (required or a named function) is not supported and is rejected with a 400. Ignored without functions in tools.

Available options:
none,
auto,
required
tools
Function · object[] | null

Functions the model may call and the caller executes. Cannot be combined with a json_schema response_format or regex.

Functions require a model that supports tool calling: other models reject them, and tool calls or results in messages, with a 400. Generation stops at the first turn that calls functions, so a response carries at most one turn of tool_calls.

top_k
integer<int32> | null

Top-k sampling. The model samples from the top k most likely tokens.

Required range: x >= 0
top_p
number<float> | null

Nucleus sampling probability. The model samples from the smallest token set whose cumulative probability exceeds this threshold.

Required range: x <= 1
vision_config
null | object

Perceptron vision-model controls (thinking, spatial output format, video audio). Only supported on Perceptron-owned models.

Response

Chat completion generated successfully.

Non-streaming response body when stream=false.

choices
object[]
required
created
integer<int64>
required
Required range: x >= 0
id
string
required
model
string
required
object
string
required
usage
null | object

Token accounting emitted with every completion.