Loading the documentation…

Use the API

The DataMind Platform API lets your own applications call the pay-as-you-go models in the OpenAI request format, so existing OpenAI code works with a new base URL and one extra header. Kartlos Premium and Kartlos Standard work inside DataMind OS and cannot be called with an API key (Kartlos models).

Before you start

You need the company API key. An Administrator creates and manages it on the API key card in Settings, as described in Manage the API key. The examples below read it from the DATAMIND_API_KEY environment variable.

SettingValue
Base URLhttps://platform.datamind.ai/llm
Authenticationx-api-key: <api_key> header. An Authorization: Bearer header alone is not accepted.
Request bodyJSON, with Content-Type: application/json

Your company holds one active key, for your own applications. DataMind OS installs run on License Keys instead, one for each install (API keys and License Keys). A key that is rotated or revoked stops working at once, and a company that is no longer active stops serving requests (API authentication).

Step 1: Choose a model

List the models your key can use:

bash
curl https://platform.datamind.ai/llm/models \
  -H "x-api-key: $DATAMIND_API_KEY"

Pick an entry whose billing is payg and use its id as model in the next step. Each entry tells you what the model can do and what it costs; the fields are listed on Models API, and the Models page shows the same list.

A company set to EU sees only the models served in the EU, and a request for any other model is refused like an unknown one.

Step 2: Send a chat request

Send model and messages, as in the OpenAI Chat Completions API:

bash
curl https://platform.datamind.ai/llm/chat/completions \
  -H "x-api-key: $DATAMIND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model_id>",
    "messages": [
      { "role": "system", "content": "You answer in one short paragraph." },
      { "role": "user", "content": "What is a data lakehouse?" }
    ],
    "user": "customer-4821"
  }'

The answer is in choices[0].message.content, and usage holds the token counts. The response names the model you asked for. user is optional: send your end user's identifier there, and you can filter requests by it on Usage in the External ID column.

The full request and response reference is on Chat completions.

Call the API without an SDK

Any HTTP client works: send a POST with the x-api-key header and a JSON body.

python
import os
import requests

response = requests.post(
    "https://platform.datamind.ai/llm/chat/completions",
    headers={"x-api-key": os.environ["DATAMIND_API_KEY"]},
    json={
        "model": "<model_id>",
        "messages": [{"role": "user", "content": "Summarise the benefits of a lakehouse in two lines."}],
    },
    timeout=60,
)
response.raise_for_status()
print(response.json()["choices"][0]["message"]["content"])
javascript
const response = await fetch("https://platform.datamind.ai/llm/chat/completions", {
  method: "POST",
  headers: {
    "x-api-key": process.env.DATAMIND_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "<model_id>",
    messages: [{ role: "user", content: "Name three uses of embeddings." }],
  }),
});
if (!response.ok) throw new Error(await response.text());

const data = await response.json();
console.log(data.choices[0].message.content);

Use an OpenAI SDK

Instead of curl, you can use an OpenAI SDK. OpenAI SDKs send their key as Authorization: Bearer, so pass the DataMind key in the x-api-key header as well:

python
import os
from openai import OpenAI

api_key = os.environ["DATAMIND_API_KEY"]
client = OpenAI(
    base_url="https://platform.datamind.ai/llm",
    api_key=api_key,
    default_headers={"x-api-key": api_key},
)

completion = client.chat.completions.create(
    model="<model_id>",
    messages=[{"role": "user", "content": "Summarise the benefits of a lakehouse in two lines."}],
)
print(completion.choices[0].message.content)
javascript
import OpenAI from "openai";

const apiKey = process.env.DATAMIND_API_KEY;
const client = new OpenAI({
  baseURL: "https://platform.datamind.ai/llm",
  apiKey,
  defaultHeaders: { "x-api-key": apiKey },
});

const completion = await client.chat.completions.create({
  model: "<model_id>",
  messages: [{ role: "user", content: "Name three uses of embeddings." }],
});
console.log(completion.choices[0].message.content);

Tune a request

Stream the answer

Add "stream": true (stream=True in the SDK). The answer arrives as server-sent events, each carrying an OpenAI-style chunk with the new text in choices[0].delta.content; the last chunk carries usage. If the stream breaks after it starts, the last event is event: error with the code stream_interrupted: send the request again. Closing the connection stops the request; you pay for the tokens generated before it stopped. No stream_options is needed: usage is always included. The stream details are on Chat completions.

Control thinking

For a model with supports_thinking, send a reasoning object:

In the Python SDK, pass reasoning and provider through extra_body={...}. In the JavaScript SDK, add them to the request object.

Every model's thinking options, including its default effort, are on Models API; the full rules are on Chat completions.

Choose the provider order

Send "provider": { "sort": "price" } to override the company's Provider sort for one request. The values are throughput, latency, price and balanced; an unknown value is refused. The company default is set on Settings.

Embeddings and web tools

Embeddings

POST /llm/embeddings turns text into embedding vectors, with the same key and the OpenAI embeddings format. The one model is qwen/qwen3-embedding-8b, and the vectors come back in data. See Embeddings.

Web search and web read

GET /llm/web/search searches the web for q; POST /llm/web/read returns the content of the page at url. Each successful call uses Premium tokens, and a failed call costs nothing. See Web search and web read.

Handle errors

Errors use the OpenAI shape {"error": {"message": "...", "type": "...", "code": "..."}}. Act on code; every status and code, and what to retry, is on Errors and retries.

Zero data retention

Every request that reaches a model provider runs with zero data retention: your prompts and the answers are not stored and are not used for model training. The platform enforces this for every forwarded request, and no request setting can change it.

Questions, answered

Can I reuse my OpenAI client code?

Yes. The chat and embeddings endpoints speak the OpenAI formats, so an OpenAI client works once you point it at https://platform.datamind.ai/llm and pass the key in the x-api-key header, as in Use an OpenAI SDK.

Can I call the API without an OpenAI SDK?

Yes. Send a POST to https://platform.datamind.ai/llm/chat/completions with the x-api-key header and a JSON body, as in Call the API without an SDK.

Why does my OpenAI SDK get a 401 error?

The SDK sends the key only as Authorization: Bearer, and that header alone does not authenticate a request. Add the x-api-key header, as in Use an OpenAI SDK. Without a usable key, the request is refused with status 401, code invalid_api_key and the message Invalid or missing API key (API authentication).

Which endpoints can I call with my key?

Chat completions, embeddings, web search and web read, and the models list. Each has its own page: Chat completions, Embeddings, Web search and web read and Models API.

Which model should I send in my first request?

Any entry from GET /llm/models whose billing is payg; send its id as model. A company set to EU sees only the models served in the EU, and a request for any other model is refused like an unknown one (Models API).

Does the API support streaming?

Yes. Add "stream": true and the answer arrives as server-sent events, each carrying a chunk with the new text; the last chunk carries usage. See Stream the answer.

Where do I see what my API calls cost?

The Usage page lists every request with its tokens and cost, and the Dashboard shows the totals, including the Premium tokens your web searches and web reads used.

Is my data used for training?

No. Every request that reaches a model provider runs with zero data retention, and the platform enforces it for every forwarded request (Zero data retention).

What do EU Provider and Global Provider mean?

Kartlos names keep the model behind them private, so a request served under your plan shows the region that served it, EU Provider or Global Provider, in place of a provider name; the same labels appear on the Usage log. A pay-as-you-go request names the provider that served it.