فارسی Docs For developers

API overview

Endpoints, authentication, streaming and ready-to-use examples for both formats.

DaLAi is a gateway compatible with the standard OpenAI API. If you have worked with that API, there is nothing new to learn here except the base URL.

Authentication

Send your key in the Authorization header:

Authorization: Bearer sk-YOUR-KEY

Do not send the key in the URL or in a query parameter. Keys are created and deleted in the Console, under API Keys.

Endpoints

EndpointPurpose
https://dalai.ir/v1Base URL; this is what you enter in your tools
https://dalai.ir/v1/chat/completionsChat, OpenAI format
https://dalai.ir/v1/messagesChat, Anthropic Messages format
https://dalai.ir/v1/modelsLive list of models

The OpenAI format works for all models. The Anthropic Messages format is available for the claude-* family.

Example, OpenAI format

curl https://dalai.ir/v1/chat/completions \
  -H "Authorization: Bearer sk-YOUR-KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-4-5",
    "messages": [
      {"role": "system", "content": "Keep your answers short."},
      {"role": "user",   "content": "Hello"}
    ]
  }'

With the official OpenAI library for Python:

from openai import OpenAI

client = OpenAI(api_key="sk-YOUR-KEY", base_url="https://dalai.ir/v1")

r = client.chat.completions.create(
    model="claude-haiku-4-5",
    messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)

Example, Anthropic format

curl https://dalai.ir/v1/messages \
  -H "Authorization: Bearer sk-YOUR-KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Streaming

Set stream to true to receive the response word by word. Most tools have this on by default.

-d '{"model": "claude-haiku-4-5", "stream": true, "messages": [...]}'

Recommended for long responses: the user sees text from the very first second.

Tool calling

Tool calling is supported and tested in both formats. The same structure described in the OpenAI or Anthropic documentation works unchanged.

Limits