When to use an AI gateway (and when not to)
Mafdet AI is a hosted, OpenAI-compatible AI gateway: one API key and one base URL reach models from several providers, billed by usage. This page is the honest version of "should you use it" — including the cases where the answer is no.
Which approach fits your situation
There are three ways to call models from an application. None is best in all cases.
| Direct provider SDKs | Self-hosted gateway | Hosted gateway (Mafdet AI) | |
|---|---|---|---|
| Setup | One SDK and account per provider | Deploy and operate a service | Change base URL and key |
| Adding a provider | New SDK, new billing relationship | Config change, you still hold every provider key | Already in the catalogue |
| Billing | One invoice per provider | One invoice per provider, plus your hosting | One prepaid balance |
| Per-key spend limits | Provider-dependent | You build it | Built in |
| Who holds provider keys | You | You | Mafdet |
| Ops burden | None beyond your app | Yours: uptime, upgrades, secrets | None |
| Data path | You → provider | You → your server → provider | You → Mafdet → provider |
When a hosted gateway is the wrong choice
Pick something else if any of these apply. Getting this wrong wastes your time and ours.
- You need OpenAI or Anthropic models. Mafdet AI does not carry them. The catalogue is Google (Gemini), Kimi (Moonshot), Qwen and DeepSeek — see Models overview. If you want GPT or Claude behind one key, another gateway is the right tool.
- You need a compliance certification. There is no SOC 2, ISO 27001 or HIPAA attestation. Procurement processes that require one should stop here.
- Your data may not transit a third party. Requests pass through Mafdet AI before reaching the provider. If that is disallowed, self-host a gateway or call providers directly. See Data handling.
- You already use exactly one provider and are happy. A gateway adds a hop and solves a problem you do not have.
When it does fit
- You want several providers behind one key and one balance, without opening an account and a billing relationship with each.
- You need spend limits per key — for example one key per environment, or per customer, each with its own cap.
- You are pointing an existing OpenAI-compatible tool somewhere new. Claude Code, Cline, Continue, Codex CLI and opencode all take a base URL; see OpenAI-compatible tools.
- You want multimodal work under the same key: image generation, image and video embeddings, and text to speech are all on the same account.
Does switching require code changes?
No, if your code already uses the OpenAI API format. Three settings change:
from openai import OpenAI
client = OpenAI(
base_url="https://api.mafdet.ai/v1", # was the provider's URL
api_key="sk-mafdet-xxxxxxxxxxxxxxxx", # was the provider's key
)
resp = client.chat.completions.create(
model="gemini-3-flash-lite", # was the provider's model ID
messages=[{"role": "user", "content": "Hello"}],
)
Model IDs do not carry over from other platforms — a name like gpt-4o or a
gateway-specific ID will return a model-not-found error. Pick an ID from
Models overview.
What does it cost to try?
Signing up gives a Playground allowance and access to free-tier models, so the
first call costs nothing. Paid models are billed per usage on each model's own
billed dimensions — per 1M tokens for text, per image for image embedding, per
second for video embedding. Current prices for every model are in the
price table, and machine-readable at
models.json.
One limit worth knowing before you plan around it: on the Starter plan an API
key reaches free models only. Calling paid models from an API key starts at
Pro. The Playground and API keys have separate model access — see
What your plan can use.