Prerequisites
- An API token. See Backoffice Developer Console.
- Your Zylon hostname (replace
{BASE_URL}in the examples).
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
At minimum, send:
Each message has:
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, setresponse_format.type to json_schema and provide a 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.