Structured Output

JSON mode with Meridian

Guarantee valid JSON from every completion. No parsing errors, no hallucinations — just structured data you can trust.

response_format

{
  "response_format": {
    "type": "json_object"
  }
}

Set response_format to json_object and Meridian guarantees the output is valid, parseable JSON.

System Prompt Requirement

The word “JSON” must appear in your system prompt or the first user message. Meridian uses this signal to lock the output grammar.

{
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant
designed to output JSON."
    },
    {
      "role": "user",
      "content": "List 3 planets."
    }
  ]
}

JSON Schema Variant

For strict structural guarantees, supply a JSON Schema. Meridian constrains token generation to match the schema exactly.

{
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "planet_list",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "planets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": { "type": "string" },
                "moons": { "type": "integer" }
              },
              "required": ["name", "moons"],
              "additionalProperties": false
            }
          }
        },
        "required": ["planets"],
        "additionalProperties": false
      }
    }
  }
}

Ready to build with structured outputs?

Open Playground
Meridian — structured inference for production.