Open API (OpenAI-compatible)
Every Space — data mode and general mode alike — can be called programmatically through an OpenAI-compatible API. Mint an API key inside the Space, point any OpenAI SDK at Datyo, and your scripts, backends, or agents can chat with the Space's assistant (including SQL analysis over the Space's datasets).
Create an API key
- Open the Space → click the ⋮ menu (top right) → API access.
- Name the key and click Generate key.
- Copy the key immediately — it is shown exactly once. Only a prefix is kept for display afterwards.
Keys can be revoked at any time from the same dialog; revoked keys fail immediately. Usage is billed to the key owner's account like normal chat.
Call the API
Base URL: https://console.datyo.ai/v1 · Endpoint: POST /chat/completions
bash
curl https://console.datyo.ai/v1/chat/completions \
-H "Authorization: Bearer sk-df-..." \
-H "Content-Type: application/json" \
-d '{
"model": "standard",
"stream": false,
"messages": [{"role": "user", "content": "Top 5 products by revenue last week?"}]
}'python
from openai import OpenAI
client = OpenAI(base_url="https://console.datyo.ai/v1", api_key="sk-df-...")
stream = client.chat.completions.create(
model="standard",
messages=[{"role": "user", "content": "Hello"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")Parameters
| Field | Values | Notes |
|---|---|---|
model | flagship / standard / lite | Optional; defaults to the Space's model tier |
messages | OpenAI format | Calls are stateless — send the full history each request |
stream | true / false | SSE chunks (chat.completion.chunk + data: [DONE]) or a single JSON |
web_search | true / false | Datyo extension: ground the answer in live web search |
The response follows the OpenAI schema (choices[0].message.content, usage token counts). Data-mode Spaces run SQL over their attached datasets before answering; general-mode Spaces answer with their instructions and skills.
Notes
- Keep keys secret — anyone holding a key can spend your quota. Rotate by revoking and generating a new one.
- API calls do not appear in the Space's chat history; they are visible in usage/Monitor statistics.