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.
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.
| Endpoint | Purpose |
|---|---|
https://dalai.ir/v1 | Base URL; this is what you enter in your tools |
https://dalai.ir/v1/chat/completions | Chat, OpenAI format |
https://dalai.ir/v1/messages | Chat, Anthropic Messages format |
https://dalai.ir/v1/models | Live list of models |
The OpenAI format works for all models. The Anthropic Messages format is available for the claude-* family.
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)
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"}]
}'
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 is supported and tested in both formats. The same structure described in the OpenAI or Anthropic documentation works unchanged.