Skip to content

Getting started

Install

pip install sora-agent
pip install 'sora-agent[yaml]'   # if you want YAML rule files

sora uses OpenCode as its default model gateway, so you never paste provider API keys into your code. Install OpenCode and sign in once:

opencode auth login

The first time sora needs a model it starts a private opencode serve on a free localhost port, in an empty temporary directory, with every tool permission denied for image sessions. It stops the server when the client is closed or the interpreter exits.

No OpenCode?

Use any OpenAI-compatible endpoint instead: sora_agent.Extractor(sora_agent.OpenAICompatibleClient("model-id", base_url=..., api_key=...)).

Your first extraction

from datetime import date
from decimal import Decimal
from pydantic import BaseModel
import sora_agent
from sora_agent import field

class Invoice(BaseModel):
    """the tax invoice"""
    number: str = field("Invoice number", verbatim=True, critical=True)
    issued: date | None = field("Invoice date")
    total: Decimal | None = field("Grand total", critical=True)

result = sora_agent.extract("invoice.pdf", Invoice, gate=sora_agent.Gate(field=80, average=90))
print(result.data)
print(result.verdict.decision, result.verdict.field_confidence, result.verdict.blockers)

result is an ExtractionResult:

Attribute Meaning
data the validated model (None if a required field is invalid)
values grounded, normalized values before validation
notes what grounding changed or could not verify, per field
pages, mode pages shown to the model; text or vision
verdict the decision, when rules or a gate were given

Choosing a model

sora_agent.OpenCodeClient("opencode-go/kimi-k3.1-pro")   # provider/model as OpenCode lists it
sora_agent.OpenCodeClient("openai/gpt-6.2-sol#high")     # optional #variant (reasoning effort)

Set SORA_MODEL to change the default everywhere. The judge can use a different model: sora_agent.Judge(model="opencode-go/qwen4-max").

From the command line

sora text policy.pdf
sora extract invoice.pdf --schema myapp.schemas:Invoice --gate 80,90 --rules rules.yaml