Output format

The response_format stored on a version — null, a JSON object mode, or a named JSON schema — passed through unchanged by compile for you to hand to your provider.

response_format constrains the model's output. A version stores one of three shapes, edited as raw JSON in the dashboard. compile() passes it through unchanged on the response_format field — you hand it to whichever provider supports structured outputs.

The three shapes

Text — no constraint. Stored as null:

response_format
null

JSON object — the provider's JSON mode; valid JSON, no fixed shape:

response_format
{ "type": "json_object" }

JSON schema — output must conform to a named schema:

response_format
{
  "type": "json_schema",
  "json_schema": {
    "name": "refund_decision",
    "schema": {
      "type": "object",
      "properties": {
        "approved": { "type": "boolean" },
        "reason": { "type": "string" }
      },
      "required": ["approved", "reason"]
    },
    "strict": true
  }
}

The strict flag is optional.

Reading it back

const { messages, model, response_format } = prompt.compile({ question: 'refund status?' });

const answer = await openai.chat.completions.create({
  model: model.model ?? 'gpt-4o',
  messages,
  response_format: response_format ?? undefined,
});
compiled = prompt.compile(question="refund status?")

answer = openai.chat.completions.create(
    model=compiled.model.get("model", "gpt-4o"),
    messages=compiled.messages,
    response_format=compiled.response_format,
)

Like model config and tools, response_format is stored and handed back — never applied by Trodo. Pass it to a provider that supports structured outputs.

On this page