Structured Output

Reka Research supports structured output, so you can define exactly how responses should be formatted. Use a JSON Schema to ensure responses are always parseable, typed, and ready for downstream use — no fragile post-processing required.

Structured outputs are useful for applications requiring predictable output, such as:

  • Enforcing contracts between systems
  • Validating results automatically
  • Integrating seamlessly with other systems

Supported format

Structured output is supported via JSON Schema. Use the response_format field to specify your expected structure.

JSON Schema

Define the fields and types your response must follow — the model will only return content that matches.

The schema must be a valid JSON Schema object.

How to use

We recommend using the OpenAI SDK helper to parse the agent’s output into your desired format.

Python
1import os
2
3from pydantic import BaseModel
4from openai import OpenAI
5
6client = OpenAI(
7 base_url="https://api.reka.ai/v1",
8 api_key=os.getenv("REKA_API_KEY")
9)
10
11class AnswerFormat(BaseModel):
12 country: str
13 date: str
14
15completion = client.chat.completions.parse(
16 model="reka-flash-research",
17 messages=[
18 {
19 "role": "user",
20 "content": "Who won the UEFA Nations League 2025?",
21 },
22 ],
23 response_format=AnswerFormat,
24)
25
26print(completion.choices[0].message.parsed)

What you get back

$country='Portugal' date='2025-06-09'

Tips and best practices

  • Be explicit — include a short note in your prompt that describes the expected structure. It helps the model stay on track and improves reliability.
  • Mistakes can still happen. If the output isn’t what you expect, refine your instructions, break down the task, or include structured examples.
  • Use Pydantic in Python to define your schema. It’s the easiest way to produce a valid JSON Schema from a class. Learn more.