This is the full technical reference. New here? Start with the Molixa API platform.
Get access
The API is for approved B2B partners. Activate instantly at /console — no application, no waiting. Enable the AI Inference API from your dashboard to mint a scoped key (shown once). It bills the same shared credit balance as the Object Removal and AI Content Writer APIs — one account, one key per product, one bill.
Base URL & auth
All requests are HTTPS. Authenticate with your secret key in the X-Api-Key header (or Authorization: Bearer — either works, matching OpenAI SDK conventions). Send X-Owns-Content: true to accept the AI Inference Acceptable Use Policy for the request (required). Use your secret key for any server-side call — the publishable key is browser-only and will always fail with no browser Origin, which is exactly the case for a backend integration.
POST https://molixa.app/api/v1/ai/chat/completions
X-Api-Key: mlx_your_secret_key
X-Owns-Content: true
Content-Type: application/jsonModels
You never name a raw provider model. model is always one of molixa-fast, molixa-quality — a Molixa tier, not a specific upstream model. This keeps our provider/model choice swappable, and gives you automatic multi-provider failover for free.
- molixa-fast — routes to DeepSeek (OpenAI fallback). Default. Cheap, fast, good for most tasks, and about 11x cheaper on output than the quality tier.
- molixa-quality — routes to OpenAI (DeepSeek fallback). Harder reasoning, higher-stakes output, and priced accordingly. Pick it when the task needs it, not by default.
The endpoint
POST /api/v1/ai/chat/completions — OpenAI-compatible chat completions:
- model (required):
molixa-fastormolixa-quality. - messages (required):
[{ role, content }], rolessystem/user/assistant. Must end on auserturn. Up to 50 messages, 32,000 combined characters. - max_tokens: output budget, clamped 1–4096. Default 800.
- temperature: default 0.7.
- stream: not supported yet — omit or send
false.
Send an Idempotency-Key header to make retries safe — a repeat with the same key replays the first result instead of generating (and charging) again.
curl -X POST https://molixa.app/api/v1/ai/chat/completions \
-H "X-Api-Key: $MOLIXA_AI_KEY" -H "X-Owns-Content: true" \
-H "Content-Type: application/json" -H "Idempotency-Key: req-4821" \
-d '{
"model": "molixa-fast",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Write one sentence about the ocean." }
],
"max_tokens": 100
}'Or with the official OpenAI SDK, unmodified
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.MOLIXA_AI_KEY,
baseURL: "https://molixa.app/api/v1/ai",
});
const completion = await client.chat.completions.create({
model: "molixa-fast",
messages: [{ role: "user", content: "Write one sentence about the ocean." }],
});
console.log(completion.choices[0].message.content);Response — 200 OK
OpenAI's exact chat.completion shape, plus a molixa extension key:
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1735900000,
"model": "molixa-fast",
"choices": [
{ "index": 0, "message": { "role": "assistant", "content": "..." }, "finish_reason": "stop" }
],
"usage": { "prompt_tokens": 24, "completion_tokens": 9, "total_tokens": 33 },
"molixa": { "jobId": "...", "provider": "deepseek", "creditsCharged": 1, "creditsRemaining": 49999 }
}Billing — tokens in, tokens out
One prepaid credit balance powers this API and both others. Input and output tokens are priced separately, per tier:
| Tier | Input / 1K | Output / 1K |
|---|---|---|
molixa-fast | 0.9 credits | 1.8 credits |
molixa-quality | 6 credits | 20 credits |
You are billed for the model that actually answered. If a molixa-quality request is served by the DeepSeek fallback, it is charged the molixa-fast rate, and if our own fallback sends a molixa-fast request up to OpenAI, you still pay the fast rate. The provider on every response, and the model on every row of your console Usage tab, shows which one ran.
We authorize the worst case (max_tokens) up front, generate, then refund the unused remainder — you are charged for the tokens you actually used, never more. That is why the billing ledger shows a large reservation and a matching return for each call; the Usage tab shows the single net charge instead. A failed or policy-blocked call is fully refunded. When your balance runs out the API returns insufficient_quota until you top up.
Errors
OpenAI's error envelope — { error: { message, type, code } } — with a real OpenAI type wherever one exists, so existing OpenAI-SDK error handling keeps working:
| Status | type | code | Meaning |
|---|---|---|---|
| 422 | content_policy_violation | BLOCKED | Prompt or output refused by the content policy (not charged). |
| 500 | api_error | GENERATION_FAILED | All providers failed (credits refunded). |
| 429 | rate_limit_error | RATE_LIMITED | Too many requests this minute — back off. |
| 402 | insufficient_quota | INSUFFICIENT_CREDITS | Out of credits — top up. |
| 403 | permission_error | SCOPE_FORBIDDEN | Key not enabled for this API. |
| 401 | authentication_error | NO_KEY · INVALID_KEY | Missing or invalid key. |
| 400 | invalid_request_error | AFFIRMATION_REQUIRED · BAD_INPUT · STREAM_NOT_SUPPORTED | Missing X-Owns-Content / bad field / streaming requested. |
Compliance
Your terms must bind users to an Acceptable Use Policy that forbids generating spam, deceptive or illegal content, disinformation, harassment, or unauthorized impersonation. Only send X-Owns-Content: true for requests you accept responsibility for. Every prompt and completion is run through moderation; flagged content is blocked and not charged.
Pricing
Prepaid credits — one balance for all three APIs. Bigger packs cost less per credit:
| Pack | Price | Credits |
|---|---|---|
| Starter | $50 | 50,000 |
| Growth | $90 | 99,000 |
| Scale | $230 | 276,000 |
| Enterprise | custom | — |
Ready to integrate? Activate your developer console →