Skip to content
Developers // AI Inference API

AI Inference API reference

OpenAI-compatible chat completions, backed by DeepSeek and OpenAI with automatic failover. Point the official OpenAI SDK at this base URL and it works unmodified — wire intelligence into anything.

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/json

Models

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-fast or molixa-quality.
  • messages (required): [{ role, content }], roles system/user/assistant. Must end on a user turn. 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:

TierInput / 1KOutput / 1K
molixa-fast0.9 credits1.8 credits
molixa-quality6 credits20 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:

StatustypecodeMeaning
422content_policy_violationBLOCKEDPrompt or output refused by the content policy (not charged).
500api_errorGENERATION_FAILEDAll providers failed (credits refunded).
429rate_limit_errorRATE_LIMITEDToo many requests this minute — back off.
402insufficient_quotaINSUFFICIENT_CREDITSOut of credits — top up.
403permission_errorSCOPE_FORBIDDENKey not enabled for this API.
401authentication_errorNO_KEY · INVALID_KEYMissing or invalid key.
400invalid_request_errorAFFIRMATION_REQUIRED · BAD_INPUT · STREAM_NOT_SUPPORTEDMissing 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:

PackPriceCredits
Starter$5050,000
Growth$9099,000
Scale$230276,000
Enterprisecustom—

Ready to integrate? Activate your developer console →