Prerequisites
- An API token. See Backoffice Developer Console.
- Your Zylon hostname (replace
{BASE_URL}in the examples).
PrivateGPT.Read.All permits synchronous POST /messages, POST /messages/validate, and the other endpoints in the ZylonGPT read-only allowlist. Read.All permits the same calls only when the account token carries gateway_id; without gateway context, it cannot call ZylonGPT. Effective access also depends on the token owner’s role permissions.
Basic request and response
Send one user message and get back one assistant message.- Single message
- Content blocks
Example response
Example response
text values from any blocks where type is "text".
Messages shape
The same message body is used by ZylonGPT and by thepgpt field in Workspace chat/interaction requests. Send conversation content; the selected model or gateway determines which optional settings it supports. model and max_tokens are nullable options, rather than universally required fields. Keeping them explicit makes model selection and output limits predictable; validate requests against your gateway.
Request body
Request body
Nullable fields can be omitted. A non-nullable option with a default can be omitted but should not be sent as
null.System, tool choice, and structured output
System, tool choice, and structured output
response_format is deprecated; use output_config.format. Move deprecated thinking.effort to output_config.effort. Replace system.use_default_prompt with the individual system.prompt flags; setting the old flag to true enables all prompt categories.Message response fields
Message response fields
usage may include cache_creation_input_tokens, cache_read_input_tokens, inference_geo, service_tier, cache_creation (ephemeral_1m_input_tokens, ephemeral_1h_input_tokens, ephemeral_5m_input_tokens), and server_tool_use (web_fetch_requests, web_search_requests). Counts in the nested usage objects default to 0. Nullable response fields may be omitted. There is no top-level stop_sequence field; use stop_reason: "stop_sequence". See Handling stop reasons.Validate a request
Use/messages/validate to check payload shape before sending a real request. It returns valid: true or a list of validation errors.
Multi-turn conversations
To continue a conversation, include the prior turns inmessages:
Example response
Example response
System prompts
Use the top-levelsystem field to control assistant behavior (instead of a "system" role message):
Prefer the top-level
system field for system instructions so they are applied consistently across the whole request.Example response
Example response
Structured JSON output (json_schema)
If you need machine-readable output, setoutput_config.format.type to json_schema and provide output_config.format.schema. Zylon returns JSON as text in a text content block.
Example response
Example response
Streaming (SSE)
Setstream: true to receive a text/event-stream response containing events like content_block_delta (token deltas).
Example streamed events
Example streamed events
Async messages
Async messages use the same request body as sync messages—you just call a different endpoint. The main difference is the response shape: sync returns a full message, async returns amessage_id you can stream or poll later.
Sync vs async response shape
Sync vs async response shape
- Sync response
- Async response
Start an async message
Stream or poll status
Stream events:Cancel or delete
- Cancel:
POST /messages/async/{message_id}/cancel - Delete:
DELETE /messages/async/{message_id}/delete
Common mistakes
- Wrong method:
/messagesisPOST, notGET. - Missing auth header: include
Authorization: Bearer .... - Wrong base URL: use
https://{BASE_URL}/api/gpt/v1/. - Invalid request body: use
POST /messages/validateto catch schema mistakes early. - Unexpected stops or errors: see Handling stop reasons for causes and fixes.
Next steps
Tools
Let Zylon use built-in and custom tools during a message.
Artifacts
Ingest text, files, or URIs into collections for retrieval.