Prompting basics
Write prompts for canto, saga, and epos: what the gateway adds to every turn, where your instructions go, how to size max_tokens, and how to test a prompt.
A prompt to a Cruxy tier is an OpenAI-style messages array, but the model
reads more than the messages you send, and some of it depends on the key and
the request. This page covers what to control and how to check that a prompt
works. Each point traces to the API's documented behavior; none of it is a
benchmark.
curl https://api.cruxy.ai/api/v1/chat \
-H "Authorization: Bearer $CRUXY_API_KEY" \
-H "Content-Type: application/json" \
-H "Cruxy-Version: 2026-10-18" \
-d '{
"model": "epos",
"reasoning_effort": "none",
"max_tokens": 200,
"memory": { "recall": false, "capture": false },
"rules": false,
"messages": [
{ "role": "system", "content": "You label support tickets. Reply with one word: billing, bug, or other." },
{ "role": "user", "content": "I was charged twice for one order." }
]
}'const res = await fetch('https://api.cruxy.ai/api/v1/chat', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CRUXY_API_KEY}`,
'Content-Type': 'application/json',
'Cruxy-Version': '2026-10-18',
},
body: JSON.stringify({
model: 'epos',
// A one-word label needs no deliberation.
reasoning_effort: 'none',
max_tokens: 200,
// Nothing from memory or standing rules: the turn is exactly these messages.
memory: { recall: false, capture: false },
rules: false,
messages: [
{
role: 'system',
content: 'You label support tickets. Reply with one word: billing, bug, or other.',
},
{ role: 'user', content: 'I was charged twice for one order.' },
],
}),
})
if (!res.ok) throw new Error(`chat failed: ${res.status} ${await res.text()}`)
const completion = await res.json()
if (completion.finish_reason === 'length' && !completion.message.content) {
throw new Error(`max_tokens ran out before an answer (request_id ${completion.cruxy.request_id})`)
}
console.log(completion.message.content)What the model reads
Every chat turn carries more than your messages:
- The tier's own prompt. The gateway adds a per-tier system prompt and the tier's chat-template scaffolding. You cannot see or change them, and they are billed input.
- Standing rules, when they apply. They go in as defaults that the user's own message overrides, never as constraints that outrank it. See Standing rules.
- Recalled memory, when recall runs: the stored memories most relevant to the turn, as background context. See Memory.
- Attached files, each placed as a framed block before the message that
names it in
file_ids.
On a developer API key, rules and memory are off unless a request opts in. Send
memory: {"recall": false, "capture": false} and rules: false anyway when you
write and test a prompt, so the turn is exactly what you sent whichever key
sends it.
Put instructions in a system message
messages takes four roles: system, user, assistant, and tool. Put the
standing instructions for a task, such as the format, the audience, and what
to refuse, in a system message, and the input for this call in a user
message. OpenAI's developer role is not one of the four; send its content as
system.
Do not rely on standing rules for an instruction that must hold: a user's
message overrides them by design. Put it in your own system message.
Size max_tokens for the thinking
A tier that thinks writes its thinking inside the same max_tokens budget as
the answer, and POST /api/v1/chat returns it beside the answer as
cruxy.reasoning, never as content. canto
thinks by default, so a small max_tokens on canto can end the turn with
finish_reason: "length" and empty content, as the sample checks.
- For a short, direct answer, send
reasoning_effort: "none". - To keep the thinking, leave
max_tokensunset, which gives the tier's output cap, or set it large. - On
model: "auto", sendreasoning_effortwhenever you set a smallmax_tokens: the router may pickcanto.
See Reasoning effort.
Ask for structured output
To get JSON back, send response_format with a JSON schema instead of
describing the shape in prose:
{
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "ticket_label",
"strict": true,
"schema": {
"type": "object",
"properties": { "label": { "type": "string" } },
"required": ["label"]
}
}
}
}Which tiers support it
Only a tier that does constrained decoding honours json_object and
json_schema. Each catalog entry on GET /api/v1/models says so in
supports_structured_output; read it at runtime rather than hardcoding a tier.
As shipped:
| Tier | supports_structured_output |
|---|---|
canto | Yes |
saga | Yes |
epos | Yes |
- A named tier is never moved. A structured request that names a tier
without support is
422structured_output_unsupported. model: "auto"routes only to a supporting tier. When the router picks a tier without support, the request moves to the nearest tier that has it and that your key may use, and health substitution stays among those tiers. Only a key none of whose allowed tiers supports it gets the same422.
Structured output turns reasoning off for the request.
Schema rules
A json_schema request's schema is checked before any model call:
- At most 131072 bytes, nested at most 8 levels deep, and at most 400 schema objects in all.
- Every key in every schema object is one of the supported keywords:
$schema,additionalProperties,allOf,anyOf,const,default,description,enum,exclusiveMaximum,exclusiveMinimum,format,items,maxItems,maxLength,maximum,minItems,minLength,minimum,nullable,oneOf,pattern,properties,required,title,type,uniqueItems. additionalPropertiesistrueorfalse, not a schema, anditemsis a single schema.patternis a regular expression in Go's RE2 syntax.$refand$defsare not supported, so a recursive schema cannot be expressed.strictis accepted and has no effect: the schema is always enforced.
A schema outside these rules is 400 invalid_schema.
When the output does not match
On a non-streaming request, the gateway re-validates the returned JSON against
your schema. Output that does not conform is 422
structured_output_unsatisfied; the request is billed, and it may pass on a
retry. A stream is constrained upstream but not re-validated, so parse and
validate the JSON in your own code either way.
Describe tools for the model
A tool's description and its parameters' descriptions are rendered into the
prompt the model reads, and billed as input on every request that sends them.
Say what the function does and when to call it, as you would brief a
colleague, and no longer. To make a call happen, force it with
tool_choice: {"type": "function", "function": {"name": "…"}}: it is the only
form that makes a tool call deterministic. See
Define tools.
Expect variation between runs
The same request can return different text:
temperatureis forwarded to the model unchanged. Omit it for the model's default.POST /api/v1/chathas noseedfield, andPOST /v1/chat/completionsacceptsseedbut does not apply it.- With
model: "auto", two similar requests can be served by different tiers.
So test a prompt by checking properties of the answer, such as the label is one of three values, or the JSON validates, rather than comparing exact strings. Name a tier while you test.
Test on the tier you ship
A tier's profile is a qualitative descriptor, not a performance number. Before
you ship a prompt, run it on the tier you plan to use with inputs from your own
product. To size it first, POST /api/v1/tokens/count returns the input tokens
it would bill on a tier, the tier's own prompt included, without calling a
model. For repeated checks, an eval suite under /api/v1/evals/suites runs the
same cases against the tier you name; each case is billed as a chat completion.
See Evals.
Next steps
- Tier and effort for cost and latency: choose the tier and effort the prompt runs on.
- Chat: every request field.
- OpenAI SDK compatibility: the
response_formatforms and what the compatible route ignores. - Indic languages: prompts in Indic scripts.