Prompt engineering
celeris-1 is a fast, general purpose diffusion model. It performs best when prompts define the task, allowed output format, and an appropriate token limit.
Specify the output format exactly
State the required output format explicitly:
- ✅ "Reply with one word: positive, negative, or neutral."
- ✅ "Reply with JSON only:
{name, company, intent}." - ✅ "Reply with the number only."
- ❌ "What do you think the sentiment is?"
Constrained outputs are easier to validate and generally require fewer completion tokens. Avoid open-ended wording when the caller expects a fixed schema or label.
Enumerate the answer space
When the output is a label, list the valid labels and close the set:
{
"model": "celeris-1",
"messages": [
{"role": "system", "content": "Choose exactly one tool: search, calculator, email, or none. Reply with that tool name only, without reasoning."},
{"role": "user", "content": "what is 2 + 2?"},
{"role": "assistant", "content": "calculator"},
{"role": "user", "content": "what is 14% of 2,300,000?"}
],
"max_tokens": 256
}
- Include an escape hatch (
none,unknown,other) so the model has a valid answer for inputs outside the set. Otherwise, it may choose the closest label. - Specify the number of labels when the response must contain exactly one value.
Put the task in the system message
Use the system message for the standing instruction and the user message
for input data. This keeps the instruction stable and makes it easier to
version and evaluate independently from the payload:
{
"messages": [
{"role": "system", "content": "Score how well the passage answers the question, 0-10. Reply with the number only."},
{"role": "user", "content": "Question: ...\nPassage: ..."}
]
}
Message roles help distinguish instructions from data, but they do not by themselves prevent prompt injection. Treat untrusted input as untrusted data, constrain available actions, and validate model output before using it.
Set an explicit token budget
- Leave headroom in
max_tokens. Reasoning counts toward it, so a budget close to the expected answer can cut the answer off. - Keep variable prompt content concise. Shorter prompts reduce input-token volume and leave more room for data within the context window. Put reusable instructions first so repeated prefixes can use the cached input token rate.
- Use
stopsequences when the format has a clear delimiter, such as a newline.
Add examples when needed
For unusual JSON shapes or domain-specific labels, add one or two compact examples to the system message:
Extract fields as JSON only: {items: [{name, qty}], pickup_time}.
Example: "two flat whites for 8am" -> {"items": [{"name": "flat white", "qty": 2}], "pickup_time": "8:00am"}
Keep examples minimal because they count toward the context window. Omit them when the instruction is sufficient.
Validate the output, and retry with feedback
For a strict JSON contract, set
response_format rather than asking for JSON in the
prompt. {"type": "json_object"} guarantees only that the reply is a JSON
object, so validate it below either way. Step 1's code-fence mitigation applies
only to prompt-only JSON.
Validate every structured response:
- Validate the response against your schema (JSON parse, enum check, range check). If an expected JSON response has a code-fence-shaped wrapper, apply the narrow mitigation in Known issues before parsing.
- On failure, retry once with the error appended, e.g. a second
usermessage:Your last reply was not valid JSON. Reply with JSON only. - On a second failure, fall back. Route to your default branch rather than looping.
Bound retries and define a deterministic fallback for invalid output.
Iterate in the Playground first
Use the Console Playground to test prompts and response formats against the live model. The Use it from code panel provides an equivalent API example.
Next steps
- Agentic workloads: worked request patterns for classify, extract, judge, and rewrite.
- Making requests: the full parameter guidance.
- Going to production: hardening the calls around the prompt.