Skip to main content
POST
/
chat
/
completions
curl -X POST 'https://ws.gumloop.com/api/v1/chat/completions' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "claude-sonnet-4-5",
    "messages": [{"role": "user", "content": "Capital of Canada?"}]
  }'
{
  "id": "chatcmpl-9a3f8c2b14d6e7",
  "object": "chat.completion",
  "created": 1747315920,
  "model": "claude-sonnet-4-5",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "Ottawa."
      }
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 1,
    "total_tokens": 13
  }
}

Authorizations

Authorization
string
header
required

A personal API key or an OAuth 2.0 access token. Personal API keys also require the x-auth-key header with your user ID.

Body

application/json
model
string
required

Model slug. Use the id from GET /models or one of Gumloop's preset routes.

Example:

"claude-sonnet-4-5"

messages
object[]
required

Conversation history. Roles system, user, assistant. Multipart content (text + image) is supported on the user role.

Example:
[
{
"role": "user",
"content": "Capital of Canada?"
}
]
stream
boolean
default:false

When true, the response is text/event-stream carrying one chat.completion.chunk per delta and terminating with data: [DONE]. Otherwise a unary JSON chat.completion is returned.

temperature
number

Sampling temperature.

max_completion_tokens
integer

Cap on completion tokens. Replaces the deprecated max_tokens field.

modalities
enum<string>[]

Output modalities. Include "image" to route to an image-generation model.

Available options:
text,
image
image_config
object

Image-generation parameters (size, quality, aspect_ratio, background, output_format, partial_images). Optional. Image-generation models accept either modalities: ["image"] or image_config (or both); chat models ignore this field.

response_format
object

Constrain the response. {type: "json_object"} returns a JSON object; {type: "json_schema", json_schema: {name, strict, schema}} returns JSON matching the supplied schema.

tools
array

OpenAI-shape tool definitions ({type: "function", function: {name, description, parameters}}). Pass tool_choice to constrain selection.

tool_choice

Force a specific tool, leave unset for the model to choose, or pass "none" to disable tool calls.

provider
object

OpenRouter provider routing config. Caller fields like sort and order are honored; ZDR/data_collection policy is server-enforced.

Response

Chat completion. When stream is false (or omitted), the response is the chat.completion envelope below. When stream: true, the response is text/event-stream; each event carries one chat.completion.chunk and the terminator is data: [DONE].

id
string
Example:

"chatcmpl-9a3f8c2b14d6e7"

object
string
Example:

"chat.completion"

created
integer
Example:

1747315920

model
string
Example:

"claude-sonnet-4-5"

choices
object[]
usage
object