close
Skip to main content
Get from zero to your first validated JSON object in about five minutes. Request API access here.

dottxt CLI

The fastest way to see structured output using the dottxt CLI:
pip install dottxt
export DOTTXT_API_KEY="your-api-key"

cat > contact.schema.json <<'JSON'
{
  "type": "object",
  "properties": {
    "name": { "type": "string", "minLength": 1 },
    "email": { "type": "string", "pattern": "^[^@]+@[^@]+$" },
    "role": { "type": "string" }
  },
  "required": ["name", "email"],
  "additionalProperties": false
}
JSON

dottxt generate \
  --model openai/gpt-oss-20b \
  --schema contact.schema.json \
  "Extract: John Smith <john@acme.com>, VP Engineering"
Ready to wire it into code? Follow the steps below.

1. Install

pip install dottxt

2. Set your API key

export DOTTXT_API_KEY="your-api-key"

3. Run your first extraction

from pydantic import BaseModel, Field

from dottxt import DotTxt


class Contact(BaseModel):
    name: str = Field(min_length=1)
    email: str = Field(pattern=r"^[^@]+@[^@]+$")
    role: str | None = None


client = DotTxt()

result = client.generate(
    model="openai/gpt-oss-20b",
    input="Extract: John Smith <john@acme.com>, VP Engineering",
    response_format=Contact,
)

print(result.model_dump())
Expected output:
{
  "name": "John Smith",
  "email": "john@acme.com",
  "role": "VP Engineering"
}

4. Next steps