Skip to main content
The API follows the OpenAI chat completions format. If you have existing code that calls OpenAI, you can point it at dottxt by changing base_url and api_key. See the migration guide for details. This documentation covers the OpenAI-compatible chat/completions API surface. If an SDK defaults to the newer OpenAI Responses API, configure it to use chat completions instead.

Base URL

https://api.dottxt.ai/v1

Required headers

Authorization: Bearer <DOTTXT_API_KEY>
Content-Type: application/json

Structured output request

Pass your JSON Schema in response_format
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
        }
      }
    }
  }'
The schema is compiled and enforced:
Response
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1703187200,
  "model": "openai/gpt-oss-20b",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "{\"name\": \"John Smith\", \"email\": \"john@acme.com\", \"role\": \"VP Engineering\"}"
      }
    }
  ]
}
name is guaranteed non-empty via minLength. email matches the pattern. role is not in required, so the model may omit it entirely when the input doesn’t contain a job title. See endpoint-specific details in: For migration and integration workflows, see Integrations overview.