POST /v1/chat/completions
Creates a chat completion. This is the primary endpoint for generating AI responses. Requests are routed to the appropriate government cloud provider based on the model you specify.
Supports text, multi-turn conversations, tool use, and image input (vision).
Request
Headers
| Header | Required | Description |
|---|---|---|
x-api-key | Yes | Your API key |
Content-Type | Yes | application/json |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID to use (see Models) |
messages | array | Yes | List of messages (max 256) |
temperature | float | No | Sampling temperature, 0.0 to 2.0 |
max_tokens | integer | No | Maximum tokens to generate |
top_p | float | No | Nucleus sampling parameter, 0.0 to 1.0 |
stream | boolean | No | Whether to stream the response via SSE |
stream_options | object | No | Streaming options (e.g. {"include_usage": true}) |
stop | string or array | No | Stop sequence(s) to end generation |
tools | array | No | Tools the model may call (max 128). See Tool Use. |
tool_choice | string or object | No | Controls tool selection: auto, none, required, or a specific tool |
Message Object
| Field | Type | Required | Description |
|---|---|---|---|
role | string | Yes | One of system, user, assistant, or tool |
content | string or array | Yes | The message content. Can be a plain string (max 1 MB) or an array of content parts (text and image_url). See Image Input. |
tool_calls | array | No | Tool calls made by the assistant (on assistant messages, max 128) |
tool_call_id | string | No | ID of the tool call this message responds to (on tool messages, max 256 chars) |
Response
Non-Streaming
Streaming
Setstream: true to receive the response as Server-Sent Events (SSE). Each event is a JSON chunk prefixed with data: , ending with data: [DONE].
stream_options: {"include_usage": true} to receive token usage in the final chunk.
Finish Reasons
| Value | Meaning |
|---|---|
stop | Natural end of response or stop sequence hit |
length | Hit max_tokens limit |
tool_calls | The model is invoking one or more tools |
content_filter | Content was filtered by the provider’s safety system |
Tool Use
Pass atools array to let the model call functions. The model will respond with tool_calls when it wants to use a tool, and you send back the result in a tool message.
Tool Definition
Functionname must match ^[a-zA-Z0-9_-]{1,64}$ (ASCII letters, digits, underscore, hyphen; 1 to 64 characters), matching the OpenAI and Anthropic tool name specs. Names outside this pattern return 400 invalid_request_error. description is limited to 65,536 characters.
Tool Call Response
When the model calls a tool, the response includestool_calls instead of (or alongside) content:
Sending Tool Results
Include the tool call result in a follow-up message withrole: "tool":
Rejected Tool Schemas
The gateway rejects tool definitions whose parameter schemas include property names that clearly describe an outbound destination. These schemas are the shape of a data exfiltration tool, and accepting them at the gateway would be careless regardless of what the caller intends to do with the result. Rejected property names (case insensitive):- Destination names:
destination,destination_url,dest_url,dst_url - Webhook names:
webhook,webhook_url,webhooks - Callback names:
callback,callback_url - Send and forward names:
forward_to,forward_url,send_to,post_to,push_to - Target names:
target_url,target_host - Named sinks:
upload_url,ingest_url,notification_url,notify_url,report_url,sink_url - Obvious intent:
exfil_url,exfiltrate
items schema, a $defs entry, or a oneOf branch will not bypass it.
Ambiguous names that can legitimately read as well as write are not rejected. url, uri, endpoint, host, and hostname all pass at this layer. A database connection tool with host and port, or a tool that reads a record from an internal API by url, continues to work. The runtime check described in the next section handles what actually appears in the arguments.
A rejected request returns 400 invalid_request_error and identifies the offending tool and parameter:
Tool Call Governance Metadata
When a model returns tool calls, the gateway scans eacharguments payload for outbound destinations (URLs with a scheme like https://, ftp://, s3://, data:, mailto:, and raw IPv4 addresses). When any are found, the response includes an advisory field called x_consus_governance alongside the standard OpenAI body. The tool call itself is not modified. You still receive the real arguments so your application can run.
Response shape when destinations are detected:
finish_reason). Clients that already parse the final chunk for usage can pick up x_consus_governance from the same place.
Examples
Basic Completion
Streaming
With System Prompt and Parameters
Multi-Turn Conversation
Image Input (Vision)
All available models (claude-3-7-sonnet:il5, claude-sonnet-4-5:il5, gemini-2-5-pro:il5, gemini-2-5-flash:il5) accept images.
Supported formats: jpeg, png, gif, webp
How images are sent
To include an image, setcontent to an array instead of a plain string. Each element is a content part with a type field, either "text" or "image_url".
TheA base64 data URI looks like this:image_urlfield name is inherited from OpenAI’s API format. Despite the name, you do not pass a URL. You pass the raw image bytes encoded as a base64 data URI. External URLs (https://...) are rejected with400to prevent data exfiltration.
data:<mime-type>;base64,, and put the whole string in the url field.
Request Format
contentcan contain any number oftextandimage_urlparts in any order- Images are only valid in
usermessages.systemandassistantmessages must use a plain string forcontent. - Multiple images per message are supported (up to 20)
Size Limits
| Limit | Value |
|---|---|
| Per image (raw decoded) | 3.5 MB |
| Total image data per message (base64) | 4.5 MB |
| Max images per message | 20 |
400.
Integrations handle this for you
If you’re using an integration like OpenCode or Cline, you don’t need to do any of this manually. Those tools encode images automatically when you paste a screenshot. Just paste and send. The base64 encoding and data URI formatting is handled behind the scenes. If you’re calling the API directly, read on.Complete Examples
bash (curl)Document Input (PDF)
All Claude and Gemini models support PDF document inputs. Supported file types:application/pdf
How documents are sent
To include a PDF, add a content part with"type": "file" to the content array. The file_data field must be a base64 data URI. External URLs are rejected for the same no-egress reason as images.
- Documents are only valid in
usermessages.systemandassistantmessages must use plain strings. filenameis metadata passed to the model; it is treated as untrusted input and sanitized before use- Text, images, and files can be mixed in a single message’s
contentarray
Size Limits
| Limit | Value |
|---|---|
| Per file (raw decoded) | 3.5 MB |
| Total base64 content per message (images + files combined) | 4.5 MB |
| Max files per message | 5 |