Create chat completion
Run one chat completion on any model Gumloop supports (Anthropic, OpenAI, Google Gemini, OpenRouter routes). The request and response use the OpenRouter chat completions schema, which extends OpenAI’s. An OpenAI-style client works unchanged.
Which models and fields are supported?
Which models and fields are supported?
reasoning, plugins, provider, modalities and image_config fields are accepted too.Image-generation models (gpt-image-*, gemini-*-image-preview) run when modalities includes
"image" and return image attachments on choices[0].message.images. Decision models
(typesafe/jev-*) are not chat models. Send those to POST /decisions.Which host serves this endpoint, and how does streaming work?
Which host serves this endpoint, and how does streaming work?
POST https://ws.gumloop.com/api/v1/chat/completions,
for both stream: true and stream: false. api.gumloop.com does not serve this endpoint. The Python SDK
routes there automatically.With stream: true the response is text/event-stream (Server-Sent Events). Each event carries one
chat.completion.chunk and the stream ends with data: [DONE]. client.chat.completions.create(..., stream=True)
yields parsed ChatStreamChunk objects.How do I send tool calls and images?
How do I send tool calls and images?
- Tool-result turns: after the model replies with
finish_reason: "tool_calls", append its assistant message (withtool_calls) and one{"role": "tool", "tool_call_id": ..., "content": ...}message per call, then send the conversation again. Every tool call needs a matching tool message, and every tool message must match a tool call in an earlier assistant message. - Images: user messages accept
image_urlcontent parts alongsidetextparts. The URL can be anhttp(s)URL or a base64 data URL (data:image/png;base64,...). Images must be JPEG, PNG, GIF, or WebP and at most 20 MB. Redirects are not followed when downloading an image. tool_choice:"auto"(the default whentoolsare sent),"none","required", or{"type": "function", "function": {"name": "..."}}to force one tool.developermessages are treated likesystemmessages.
400 invalid_request with param set to the field at fault (for example messages[3].tool_call_id). When the provider itself rejects the request (HTTP 400, 404, 413, or 422), the error message relays the provider’s reason, prefixed with The provider rejected the request:.How are chat completions billed?
How are chat completions billed?
402 credit_limit_exceeded. A provider call whose cost is fully waived because you use your own API key is exempt from this preflight.Authorizations
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
Reasoning settings. effort accepts minimal, low, medium, high, xhigh, max, or none.
On Claude models, an unknown effort returns HTTP 400 with param set to reasoning.effort. Claude models return
their thinking summary in the response's reasoning; none turns thinking off on Claude models
that support disabling it. Only effort and summary are read from this object; other fields
are ignored.
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].