> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dottxt.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Run your first structured-output extraction in minutes.

Get from zero to your first validated JSON object in about five minutes. [Request API access here.](https://h1xbpbfsf0w.typeform.com/to/fwQNWmS8?typeform-source=docs.quickstart)

## dottxt CLI

The fastest way to see structured output using the dottxt CLI:

<CodeGroup>
  ```bash dottxt CLI theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  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"
  ```

  ```bash curl theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  export DOTTXT_API_KEY="your-api-key"

  curl https://api.dottxt.ai/v1/chat/completions \
    -H "Authorization: Bearer $DOTTXT_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "openai/gpt-oss-20b",
      "messages": [{ "role": "user", "content": "Extract: John Smith <john@acme.com>, VP Engineering" }],
      "response_format": {
        "type": "json_schema",
        "json_schema": {
          "name": "contact",
          "schema": {
            "type": "object",
            "properties": {
              "name": { "type": "string", "minLength": 1 },
              "email": { "type": "string", "pattern": "^[^@]+@[^@]+$" },
              "role": { "type": "string" }
            },
            "required": ["name", "email"],
            "additionalProperties": false
          }
        }
      }
    }'
  ```
</CodeGroup>

Ready to wire it into code? Follow the steps below.

## 1. Install

<CodeGroup>
  ```shellscript Python (dottxt) theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  pip install dottxt
  ```

  ```shellscript Python (OpenAI) theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  pip install openai pydantic
  ```

  ```shellscript TypeScript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  npm install ai @ai-sdk/openai
  ```
</CodeGroup>

## 2. Set your API key

<CodeGroup>
  ```shellscript macOS/Linux theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  export DOTTXT_API_KEY="your-api-key"
  ```

  ```powershell Windows (PowerShell) theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  $env:DOTTXT_API_KEY="your-api-key"
  ```
</CodeGroup>

## 3. Run your first extraction

<CodeGroup>
  ```python Python (dottxt) theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  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())
  ```

  ```python Python (OpenAI) theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  import os
  from openai import OpenAI
  from pydantic import BaseModel, Field

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

  client = OpenAI(
      base_url="https://api.dottxt.ai/v1",
      api_key=os.environ["DOTTXT_API_KEY"],
  )

  response = client.chat.completions.create(
      model="openai/gpt-oss-20b",
      messages=[
          {"role": "user", "content": "Extract: John Smith <john@acme.com>, VP Engineering"}
      ],
      response_format={
          "type": "json_schema",
          "json_schema": {
              "name": "contact",
              "strict": True,
              "schema": Contact.model_json_schema(),
          },
      },
  )

  result = Contact.model_validate_json(response.choices[0].message.content)

  print(result.model_dump())
  ```

  ```typescript TypeScript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  import { createOpenAI } from "@ai-sdk/openai";
  import { generateObject, jsonSchema } from "ai";

  const dottxt = createOpenAI({
    baseURL: "https://api.dottxt.ai/v1",
    apiKey: process.env.DOTTXT_API_KEY!,
  });

  const { object } = await generateObject({
    model: dottxt.chat("openai/gpt-oss-20b"),
    schemaName: "contact",
    schema: jsonSchema({
      type: "object",
      properties: {
        name: { type: "string", minLength: 1 },
        email: { type: "string", pattern: "^[^@]+@[^@]+$" },
        role: { type: "string" },
      },
      required: ["name", "email"],
      additionalProperties: false,
    }),
    prompt: "Extract: John Smith <john@acme.com>, VP Engineering",
  });

  console.log(object);
  ```
</CodeGroup>

Expected output:

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "name": "John Smith",
  "email": "john@acme.com",
  "role": "VP Engineering"
}
```

## 4. Next steps

* Learn schema patterns: [JSON Schema overview](/json-schema/overview)
* Keep OpenAI-style code and switch providers: [Migrate from other providers](/migrate-from-other-providers)
* Browse endpoints and auth: [API overview](/api/overview)
* Send your schema for feedback before launch: [Schema audit](/audit)
