From zero to a live request
Sign up, grab a key, and point your client at Mordiem. Your first key starts with mr_sk_ and includes free credit to try it.
Get a key
Continue with GitHub, Google, an email code or a wallet. Your first key is created for you.
Set the base URL
Use the same OpenAI client you already have. Only the endpoint and key change.
OPENAI_API_KEY=mr_sk_…
Send a chat
Streaming, tools, images and embeddings all work through the same key. Or set model: "auto" and let the router choose.
Copy a working example
Python, JavaScript, curl or env vars. Swap in your key and run.
from openai import OpenAI
client = OpenAI(
base_url="https://api.mordiem.com/api/v1",
api_key="mr_sk_…",
)
r = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Say hello."}],
)
print(r.choices[0].message.content)base_url to https://api.mordiem.com/api/v1 and use your mr_sk_ key. Model ids follow the Venice catalog. List them with GET https://api.mordiem.com/api/v1/models or browse Models.Let Mordiem pick the model
Set model to auto and the router sends each request to the cheapest model that can do it well. You pay that model's price; the response tells you which one answered.
auto
Balanced routing for everyday prompts. Small models for quick questions, stronger ones for hard code and reasoning.
auto:cheap · auto:best
Bias toward savings or toward the strongest models. Response model and x-mordiem-router-* headers show the choice.
client.chat.completions.create(model="auto", messages=[...])
Ask for anything
POST /generations takes a plain request and works out the rest: modality, model and a prompt shaped for that model. It answers in milliseconds with a job id.
One endpoint, every media
Text, image, video, speech or music. Poll the job or pass a webhook_url. model: "auto" works on image, video and audio endpoints too.
Add "enhance_prompt": false to send your prompt exactly as written. Video and music lengths snap to what the chosen model supports.
curl https://api.mordiem.com/api/v1/generations \
-H "Authorization: Bearer mr_sk_..." -H "Content-Type: application/json" \
-d '{"prompt": "a 5 second anime clip of a fox running through snow"}'
# → {"id": "…", "status": "queued", …}
curl https://api.mordiem.com/api/v1/generations/<id> -H "Authorization: Bearer mr_sk_..."
# → {"status": "succeeded", "type": "video", "model": "…", "outputs": ["…/content"]}"likeness_consent": true to each request to confirm that any person shown is you or has given explicit consent. We keep a hash of the media, never the media.How you're billed
Each request spends credit in this order. See Pricing for plans and top-ups.
MCU daily credit
From staked MCU. Renews every day at 00:00 UTC.
MOR daily credit
From staked MOR, when available on your account.
Plan & free credit
Membership plan credit and free trial credit.
Prepaid balance
Card, Apple Pay, USDC, Zcash and other top-ups.
Common status codes
Failures return an OpenAI-shaped error body with a code you can branch on.
| Status | error.code | Meaning |
|---|---|---|
| 401 | invalid_key | Key missing, revoked or paused. |
| 429* | insufficient_credits | No credit left. The body includes topup_url. (*402 if your admin prefers.) |
| 429 | daily_limit_reached | The key's daily spend limit is used up. Resets at midnight UTC. |
| 429 | credit_contention | Concurrent requests are holding your credit. Retry after a few seconds. |
| 400 | model_not_found | Unknown model id. List models with GET /models. |
| 403 | likeness_notice_required | The request sends your own image or video to a generation model. Accept the likeness notice once in Settings → General. |
| 400 | likeness_consent_required | Add "likeness_consent": true (or header x-mordiem-likeness-consent: true) to confirm any person shown is you or has consented. |
| 502 | upstream_unavailable | Every provider for this model is busy or failing. Retry shortly, or use model auto to fail over to another model. |
Build on Mordiem
Sign in from a terminal, or let your users bring their own Mordiem key with PKCE.
From the terminal
Sign in with your browser and export env vars without copying the key around.
npx mordiem login eval "$(npx mordiem env)"
Sign in with Mordiem
Send users to Mordiem to approve a key for your app. They pay for their own usage. PKCE, same shape as OpenRouter's flow.
// 1. Send the user to Mordiem
const verifier = base64url(crypto.getRandomValues(new Uint8Array(32)));
const challenge = base64url(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier)));
location.href = `https://mordiem.com/auth?callback_url=${encodeURIComponent(CALLBACK)}&code_challenge=${challenge}&code_challenge_method=S256&name=My%20App`;
// 2. Back on CALLBACK?code=…, exchange the code for the user's key
const r = await fetch("https://api.mordiem.com/api/v1/auth/keys", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ code, code_verifier: verifier, code_challenge_method: "S256" }),
});
const { key } = await r.json();