Mordiem
Docs · Quickstart

Two lines.
Every model.

Mordiem speaks the OpenAI API. Keep your SDK, point it here, and ship text, image, video and audio behind one key.

Free credit on sign-up OpenAI-compatible Python, JS, curl
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mordiem.com/api/v1",
    api_key="mr_sk_…",
)

stream = client.chat.completions.create(
    model="deepseek-v4-flash",
    messages=[{"role": "user", "content": "Say hello."}],
    stream=True,
)
Change base_url and api_key. Keep everything else.
01 · Setup

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.

1

Get a key

Continue with GitHub, Google, an email code or a wallet. Your first key is created for you.

mr_sk_••••••••••••7Qx2
2

Set the base URL

Use the same OpenAI client you already have. Only the endpoint and key change.

OPENAI_BASE_URL=https://api.mordiem.com/api/v1
OPENAI_API_KEY=mr_sk_…
3

Send a chat

Streaming, tools, images and embeddings all work through the same key. Or set model: "auto" and let the router choose.

model = "deepseek-v4-flash"
02 · Code

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)
Coming from OpenRouter or Venice? Change 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.
03 · Smart routing

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=[...])
04 · Generations

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"]}
Sending your own image or video (image-to-video, reference images, edits)? Accept the likeness notice once in Settings → General, then add "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.
05 · Billing

How you're billed

Each request spends credit in this order. See Pricing for plans and top-ups.

1

MCU daily credit

From staked MCU. Renews every day at 00:00 UTC.

2

MOR daily credit

From staked MOR, when available on your account.

3

Plan & free credit

Membership plan credit and free trial credit.

4

Prepaid balance

Card, Apple Pay, USDC, Zcash and other top-ups.

06 · Errors

Common status codes

Failures return an OpenAI-shaped error body with a code you can branch on.

Statuserror.codeMeaning
401invalid_keyKey missing, revoked or paused.
429*insufficient_creditsNo credit left. The body includes topup_url. (*402 if your admin prefers.)
429daily_limit_reachedThe key's daily spend limit is used up. Resets at midnight UTC.
429credit_contentionConcurrent requests are holding your credit. Retry after a few seconds.
400model_not_foundUnknown model id. List models with GET /models.
403likeness_notice_requiredThe request sends your own image or video to a generation model. Accept the likeness notice once in Settings → General.
400likeness_consent_requiredAdd "likeness_consent": true (or header x-mordiem-likeness-consent: true) to confirm any person shown is you or has consented.
502upstream_unavailableEvery provider for this model is busy or failing. Retry shortly, or use model auto to fail over to another model.
07 · Apps & CLI

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();
Next

Keep going