Skip to main content
POST

Guide: Completions

Choosing a model, model family or auto-routing, and migrating from V1.

Error Reference: Completions V2

Common errors: invalid routing configuration, missing messages, context window exceeded, provider timeout, provider unavailable.

Authorizations

Authorization
string
header
default:Bearer <api-key>
required

Bearer authentication header of the form Bearer <api-key>, where <api-key> is your API key.

Headers

X-Cache-TTL
enum<string>

Enables Anthropic prompt caching. When set, system messages are automatically wrapped with cache_control blocks. '5m' bills cache writes at 1.25x input rate, '1h' bills at 2x input rate. Only effective for Anthropic models.

Available options:
5m,
1h

Body

application/json

Request body for the completions v2 endpoint. Exactly one routing mechanism (auto_routing, model, or model_family) must be specified. Messages are optional when omitted and default to a single user message of "Hello world!". An explicit empty messages array is invalid and returns 400.

messages
LlmMessage · object[]

Chat message history with role and content fields. If omitted, the current service defaults to one user message with content "Hello world!". Explicitly passing an empty array is invalid.

auto_routing
boolean
default:false

Opt-in. When true, Gloo selects the model for each request (balancing speed and capability), so the model can change between calls. Cannot be combined with model or model_family. Default: false.

model
string

Specific Gloo model identifier (e.g., gloo-anthropic-claude-opus-5.5). Provides full control and reproducibility. Mutually exclusive with auto_routing and model_family.

model_family
enum<string>

Provider family for model selection. Gloo chooses a model within that family. Mutually exclusive with auto_routing and model.

Available options:
openai,
anthropic,
google,
open source
tradition
enum<string>

Theological perspective to apply. Options: evangelical, catholic, mainline. Omit for general Christian perspective.

Available options:
evangelical,
catholic,
mainline,
not_faith_specific
stream
boolean
default:false

Enables streaming responses. When true, responses are sent as server-sent events as tokens are generated.

temperature
number

Sampling temperature controlling randomness, from 0 to 1; a value above 1 returns 422. Lower values (e.g., 0.2) make output more focused, higher values (e.g., 0.9) more varied. If you don't set it, the model's own default applies. A model that does not take one (Claude 5 models, and OpenAI GPT-5 and later models while they reason) does not get it, and it is listed in ignored_params (X-Ignored-Params on a stream).

Required range: 0 <= x <= 1
max_tokens
integer

Maximum output, in tokens. It holds the reasoning as well as the answer. When the model is reasoning, a value below 8,192 is raised to 8,192; a larger one is sent as you set it, up to the model's maximum output. With reasoning_effort 'none' on a model that can turn reasoning off (can_disable: true in the model catalog), from any provider, the value is sent as you set it, up to the model's maximum output. With no value, a reasoning model gets its full output allowance (up to 65,536) and other models get 2,048. A value of 0 or less counts as no value. See Set your output limit for reasoning models.

max_completion_tokens
integer

OpenAI's name for max_tokens. If you send both, max_completion_tokens is used.

reasoning_effort
string | null

How much a reasoning model thinks: 'none', 'minimal', 'low', 'medium', 'high', 'xhigh' or 'max'. The nested form reasoning: {effort, summary} is accepted too; this field wins if both are sent. An effort other than 'none' also returns the model's reasoning: on a non-streamed answer as message.reasoning_content, and on a stream as delta.reasoning_content chunks before the answer. The reasoning is not moderated. A level the model does not run as sent (a model that does not reason, or a level it does not have) is not refused: it runs at the nearest level the model has, or without an effort, and is listed in ignored_params (X-Ignored-Params on a stream). See the Reasoning guide (/api-guides/reasoning).

reasoning
Reasoning · object | null

The nested OpenAI form of reasoning_effort: {"effort": "high"}. reasoning_effort wins if both are sent; a different nested effort it overrode is listed in ignored_params. Fields that cannot be read are listed in ignored_params and never cause an error.

tools
Tool · object[]

Function calling definitions. Each tool includes type, name, description, and parameters schema.

tool_choice
default:none

Controls which tool (if any) the model should use.

Available options:
none,
auto,
required
prompt_cache_key
string

OpenAI Responses API cache key for persistent prompt caching. When set, the prompt prefix is cached and reused across requests with the same key, reducing cost and latency. Cache TTL is 5 minutes (server-side). Only effective for OpenAI models. Ignored for other providers.

stream_options
Stream Options · object

Streaming options. Use include_usage=true with stream=true to receive a final usage event.

Response

Successful completion response. If stream is false or omitted, the response is JSON. If stream=true, the response is a Server-Sent Events stream. Once streaming has started, failures are delivered as stream events rather than non-2xx HTTP responses. Content moderation ends the stream with a content_filter event.

Response from the completions v2 endpoint.

id
string

Unique completion identifier.

object
string
default:chat.completion

Object type, always 'chat.completion'.

created
integer

Unix timestamp of when the completion was created.

model
string

The model that was selected and used for the completion.

routing_mechanism
enum<string>

How the model was chosen: auto_routing (Gloo picked the model), model_family (Gloo picked a model within the family you named), or direct_model_selection (you named the model).

Available options:
auto_routing,
model_family,
direct_model_selection
routing_tier
string

The performance tier assigned by the routing system. Present when routing_mechanism is auto_routing or model_family.

routing_confidence
number

Confidence score for the routing decision (0.0 to 1.0, rounded to three decimals). Present when routing_mechanism is auto_routing or model_family.

tradition
string

The theological perspective that was applied to the response.

provider
string

The model provider name (e.g., openai, anthropic, google).

choices
CompletionsV2Choice · object[]

List of completion choices.

usage
CompletionsV2Usage · object

Token consumption metrics.

system_fingerprint
null
model_family
string
auto_routing
boolean