Skip to main content

Structured extraction

Use structured outputs to extract typed data from unstructured text. Instead of parsing free-form prose, you get a validated JSON object that maps directly to your application code.
client.beta.chat.completions.parse() is a beta OpenAI SDK method that enables Pydantic-native structured output. Confirm with Engineering that Radium supports the underlying response_format schema-constraint behaviour used by this method.

With Pydantic and OpenAI SDK

extract.py

Output

With JSON mode (no Pydantic)

If you prefer not to use the beta parser, use response_format={"type": "json_object"}:
extract_json.py

Extracting from a batch of documents

Process many documents and collect structured results:
batch_extract.py

Tips

  • Use clarke-1.0 for extraction — it balances instruction-following with speed and cost.
  • Use tycho-1.0 for high-volume, simple extraction tasks like classification or entity tagging.
  • Include a system message that instructs the model to respond with JSON only.
  • Set max_tokens conservatively to avoid runaway generations.

Next steps

Batch processing

Process thousands of documents in parallel

Tool calling agent

Use extraction inside an agent loop