Quickstart
Four steps: create a key, fund your balance, pick a model, send a request with any OpenAI-compatible SDK.
1. Create an API key
Sign in with Google, GitHub or an Ethereum wallet, then create a key from your account. Keys start with
sk-hd-v1- and are shown once — store yours in a secret manager or an environment variable:
export HEIMDALL_API_KEY="sk-hd-v1-..."
2. Fund your balance
Heimdallm is prepaid: every request is settled against your credit balance. Add credits from the
Credits tab of your account; Deposits covers
stablecoins, cards and x402. A request whose cost estimate exceeds what your balance can spend is
refused with 402 and the message Insufficient credits to run this request. before any provider is
contacted — see Credits.
3. Pick a model
Browse the model list and copy the id of the model you want, for example
deepseek/deepseek-v4.1-flash. Every model page shows the providers serving it, their prices
and measured performance.
4. Send a request
curl https://api-staging.heimdallm.com/api/v1/chat/completions \ -H "Authorization: Bearer $HEIMDALL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek/deepseek-v4.1-flash", "messages": [{ "role": "user", "content": "Hello" }] }'The response is a standard chat.completion object. Heimdallm adds two fields: provider — the
name of the provider that served the request — and usage.cost, the exact amount charged in USD:
{
"id": "gen-9f2c7e1a4b6d",
"object": "chat.completion",
"model": "deepseek/deepseek-v4.1-flash",
"provider": "ImpCC",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Hello! How can I help?" },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 34,
"total_tokens": 46,
"cost": 0.0000148
}
}
Every response also carries an X-Generation-Id header. That id is the id of the completion, and
you can look up the full billing record for it later with
GET /generation.
Streaming
Set "stream": true to receive server-sent events. Chunks follow the OpenAI streaming format; the
final chunk before data: [DONE] carries the usage totals, including cost.
curl -N https://api-staging.heimdallm.com/api/v1/chat/completions \
-H "Authorization: Bearer $HEIMDALL_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "deepseek/deepseek-v4.1-flash", "stream": true,
"messages": [{ "role": "user", "content": "Hello" }] }'
The OpenAI SDKs stream the same way they do against OpenAI:
stream = client.chat.completions.create(
model="deepseek/deepseek-v4.1-flash",
messages=[{"role": "user", "content": "Hello"}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
See the streaming guide for the frame-by-frame anatomy, keep-alives and how mid-stream errors are delivered.
Next steps
- How Heimdallm works — the marketplace's moving parts in one page.
- Choosing a model — reading prices and measurements to pick between endpoints.
- Models & routing — fall back across models, pin or exclude providers, route by price or speed.
- Pricing & billing — how requests are priced, credits and spend limits.
- Your account — balances, the ledger, keys and routing defaults.
- Errors & rate limits — what to expect when a request cannot be served.
- Chat playground — try any model from the browser, on an API key you hold; requests are billed to that key's workspace.
- Coding playground — build software with an AI agent on a machine of your own, billed by the minute from your credit.