Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.rkat.ai/llms.txt

Use this file to discover all available pages before exploring further.

For the full guide, see Structured output.
This page works best after Examples: Sessions. Start there if you have not already seen the basic create/turn/result flow.

Basic extraction

Provide an output_schema and the agent will extract validated JSON after the agentic loop completes.
rkat run --schema '{
  "type": "object",
  "properties": {
    "city": {"type": "string"},
    "country": {"type": "string"},
    "population": {"type": "integer"}
  },
  "required": ["city", "country", "population"]
}' "Tell me about Tokyo"

Next step

Schema from file

The CLI can load a schema from a JSON file instead of inline.
rkat run --schema ./schemas/city.json "Tell me about Tokyo"
The CLI detects files by checking if the value is an existing path. The file can contain a raw JSON Schema or the wrapper format with explicit name, strict, compat, and format fields.

Retries

When validation fails, the agent retries the extraction turn with error feedback. The default is 2 retries (3 total attempts).
rkat run --schema ./schema.json "Extract entities"

Compatibility mode

Schemas are normalized across providers. The compat setting controls how unsupported JSON Schema features are handled during provider-specific lowering.
# Lossy (default): unsupported features are dropped with warnings
rkat run --schema ./schema.json "Extract data"

# For explicit `compat` control, use a wrapper schema file or a non-CLI surface
ModeBehavior
lossyBest-effort lowering; unsupported features are dropped with warnings
strictReject schemas with unsupported features for the target provider
Warnings are included in the response as schema_warnings. The same schema works with Anthropic, OpenAI, and Gemini — provider-specific lowering is handled transparently.

Read the result

The structured output appears in the response alongside the raw text.
# --output json returns the full result including structured_output
rkat run --output json --schema '{"type":"object","properties":{"answer":{"type":"string"}},"required":["answer"]}' "What is 2+2?"
# stdout: {"session_id":"...","text":"...","structured_output":{"answer":"4"}}