curl https://api.snapgen.org/v1/chat/completions \
-H "Authorization: Bearer sk-xxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [
{
"role": "system",
"content": "You answer in one concise sentence."
},
{
"role": "user",
"content": "What is an API gateway?"
}
],
"temperature": 0.2,
"max_tokens": 100
}'
{
"id": "chatcmpl_01HXYZ",
"object": "chat.completion",
"created": 1730000000,
"model": "gpt-5.4-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "An API gateway is a service that provides one interface for routing requests to one or more APIs."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 19,
"total_tokens": 44
}
}
Endpoint Reference
Chat Completions protocol
Common OpenAI-compatible chat request, response, and streaming rules.
POST
/
v1
/
chat
/
completions
curl https://api.snapgen.org/v1/chat/completions \
-H "Authorization: Bearer sk-xxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [
{
"role": "system",
"content": "You answer in one concise sentence."
},
{
"role": "user",
"content": "What is an API gateway?"
}
],
"temperature": 0.2,
"max_tokens": 100
}'
{
"id": "chatcmpl_01HXYZ",
"object": "chat.completion",
"created": 1730000000,
"model": "gpt-5.4-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "An API gateway is a service that provides one interface for routing requests to one or more APIs."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 19,
"total_tokens": 44
}
}
Create a model response from a list of chat messages. Choose an exact model page under Text Series for pricing and the recommended model ID.
Each event begins with
string
required
A text model ID available to your API key. Use
GET /v1/models to discover IDs, then open its
individual model page for current pricing.array
required
Ordered chat messages. Each message includes a
role and content.boolean
default:"false"
Set to
true to receive server-sent events.number
Controls sampling variation. Lower values are more deterministic.
integer
Caps generated tokens when supported by the selected model.
Stream a response
Setstream to true. The response uses server-sent events (SSE).
curl -N https://api.snapgen.org/v1/chat/completions \
-H "Authorization: Bearer sk-xxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [
{"role": "user", "content": "Say hello in three words."}
],
"stream": true
}'
data:. Read events until the data: [DONE] marker.
data: {"id":"chatcmpl_01HXYZ","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl_01HXYZ","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" from SnapGen"},"finish_reason":null}]}
data: [DONE]
Concatenate
choices[0].delta.content values as they arrive. A delta can omit content, especially in the first or final event.curl https://api.snapgen.org/v1/chat/completions \
-H "Authorization: Bearer sk-xxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [
{
"role": "system",
"content": "You answer in one concise sentence."
},
{
"role": "user",
"content": "What is an API gateway?"
}
],
"temperature": 0.2,
"max_tokens": 100
}'
{
"id": "chatcmpl_01HXYZ",
"object": "chat.completion",
"created": 1730000000,
"model": "gpt-5.4-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "An API gateway is a service that provides one interface for routing requests to one or more APIs."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 19,
"total_tokens": 44
}
}