Structured outputs

Parse and validate Olive's JSON before your code stores or acts on it.

Olive returns its answer as text in content. If your prompt asks for JSON, parse the answer and validate it before your code uses it.

When to use it

  • You extract codes or fields from a note into a form or a database row.
  • Your code reads the same keys from every answer.

The SDK samples assume the client from the Quickstart.

curl https://api.avey.ai/llm/chat/completions \
  -H "Authorization: Bearer $AVEY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "olive",
    "messages": [
      { "role": "system", "content": "Extract diagnoses as JSON with a diagnoses array. Return only the JSON." },
      { "role": "user", "content": "45-year-old woman, two days of dysuria and urinary frequency. No fever, no flank pain. Urinalysis positive for nitrites and leukocyte esterase." }
    ]
  }'

The Go samples reuse the Quickstart client. Add the imports each sample uses.

Limits

LimitValue
Output16,384 tokens at most, with reasoning included
Truncated answerfinish_reason is length on Chat Completions. On Responses, status is incomplete. A cut-off JSON answer is invalid.

Things to know

  • Validate every field. JSON that parses can still hold a wrong code or dose. A clinician checks the values before they affect care.
  • Reasoning uses the same output budget as the JSON. Leave room for both, or see Reasoning.
  • response_format is not covered on this page. Olive's support for its JSON modes is untested, so do not rely on it yet.
Last updated