Create chat completion (Mk1)
curl --request POST \
--url https://api.perceptron.inc/v1/chat/completions \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.perceptron.inc/v1/chat/completions"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.perceptron.inc/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.perceptron.inc/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.perceptron.inc/v1/chat/completions"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.perceptron.inc/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.perceptron.inc/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyChat completions
Create chat completion (Mk1)
Generate text-only and multimodal responses from Perceptron Mk1 with OpenAI-compatible request and response formats.
POST
/
v1
/
chat
/
completions
Create chat completion (Mk1)
curl --request POST \
--url https://api.perceptron.inc/v1/chat/completions \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.perceptron.inc/v1/chat/completions"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.perceptron.inc/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.perceptron.inc/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.perceptron.inc/v1/chat/completions"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.perceptron.inc/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.perceptron.inc/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyOverview
The Chat Completions API uses OpenAI-compatible request and response formats, with model-specific capabilities and limits. Use it to generate text-only and multimodal responses from Perceptron Mk1. Perceptron Mk1 triggers thinking and structured grounding through the typedvision_config body field.
This page documents the Mk1-specific request fields. The standard chat-completions fields (messages, model, max_completion_tokens, temperature, stream, stream_options, response_format) follow the OpenAI format. Mk1 does not accept tools, tool_choice or parallel_tool_calls; the full gateway request schema is in the Perceptron Mk1.5 reference.
Asking several independent questions about the same image or video? Use Multilook to send up to 16 prompts over one shared context in a single request and pay for the context once.
vision_config
For perceptron-mk1, pass a top-level vision_config object alongside messages:
| Field | Values | Purpose |
|---|---|---|
annotation_format | "point" / "box" / "polygon" / "clip" | Grounded output format. clip is video-only. |
enable_thinking | true / false | Chain-of-thought reasoning. |
When to enable_thinking
- On for text Q&A, captioning, OCR, and video clipping (
annotation_format: "clip"). - Off for spatial detection (
annotation_formatin"point","box","polygon").
Example: Grounded detection
curl https://api.perceptron.inc/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PERCEPTRON_API_KEY" \
-d '{
"model": "perceptron-mk1",
"messages": [
{ "role": "user",
"content": [
{ "type": "image_url",
"image_url": { "url": "<image-url>" } },
{ "type": "text",
"text": "Find every worker wearing PPE." }
]
}
],
"vision_config": { "annotation_format": "box" }
}'
Example: Video clipping
curl https://api.perceptron.inc/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PERCEPTRON_API_KEY" \
-d '{
"model": "perceptron-mk1",
"messages": [
{ "role": "user",
"content": [
{ "type": "video_url",
"video_url": { "url": "<video-url>" } },
{ "type": "text",
"text": "Clip the moment the worker scans the package." }
]
}
],
"vision_config": { "annotation_format": "clip", "enable_thinking": true }
}'
Example: Video from pre-decoded frames
If you’ve already sampled frames client-side, pass them inline with avideo_frames content part instead of a single video_url. Each frame carries an image_url (HTTP(S) URL or base64 data URL) and a timestamp_ms offset from the start of the clip. Provide between two and 256 frames, ordered by non-decreasing timestamp_ms. For optimal performance, follow a uniform sampling strategy aligned with the Video Token Counting guide.
curl https://api.perceptron.inc/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PERCEPTRON_API_KEY" \
-d '{
"model": "perceptron-mk1",
"messages": [
{ "role": "user",
"content": [
{ "type": "video_frames",
"video_frames": {
"frames": [
{ "image_url": { "url": "<frame-url>" }, "timestamp_ms": 0 },
{ "image_url": { "url": "<frame-url>" }, "timestamp_ms": 500 }
]
}
},
{ "type": "text",
"text": "What changes between these frames?" }
]
}
],
"vision_config": { "enable_thinking": true }
}'
Streaming
Set"stream": true to receive Server-Sent Events (SSE). Opt into token usage with stream_options.include_usage: true. Handle a trailing usage-only chunk with choices: [] before data: [DONE]; do not assume usage arrives on the chunk carrying finish_reason.
Inspect finish_reason: stop means normal completion, while length means the output was cut off. Clients shared with tool-capable models must also handle tool_calls. Treat error events and interrupted streams as failures or incomplete output; [DONE] alone does not prove a successful answer.
curl https://api.perceptron.inc/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PERCEPTRON_API_KEY" \
-d '{
"model": "perceptron-mk1",
"messages": [
{ "role": "user",
"content": [
{ "type": "image_url",
"image_url": { "url": "<image-url>" } },
{ "type": "text", "text": "Describe this scene in detail." }
]
}
],
"vision_config": { "enable_thinking": true },
"stream": true,
"stream_options": { "include_usage": true }
}'
Best Practices
- Thinking pairs well with text and clipping; not with spatial detection. Turn
enable_thinkingon for text Q&A, captioning, OCR, andannotation_format: "clip". Turn it off for"point","box", and"polygon". - Leave
temperatureunset. The default is0.0(deterministic). Only set a non-zero value if you want more varied outputs. - Image format: HTTP(S) URLs and base64 data URLs are both supported. MIME types:
image/png,image/jpeg,image/webp,video/mp4,video/webm. - Inline frames vs.
video_url: Send a whole clip withvideo_url, or — if you’ve already sampled frames — pass them inline withvideo_frames(two to 256 frames,timestamp_msnon-decreasing). Inline frames give you precise control over exactly which frames the model sees; for optimal performance, sample uniformly in line with the Video Token Counting guide. - Token limits: 32K context, 8K output.
- Many questions, one input: batch them with Multilook instead of repeating the media on every call. The shared context is prefilled once, and reused tokens are billed at the cache-read rate.
Limits
| Limit | Value |
|---|---|
| Requests | 300/min |
| Request body size | 20 MB |
| Media upload | 20 GB per 48 hours |
For large images, resize client-side before uploading. See the Tokenization guide for optimization tips.