Your first API call
Once you have an API key, send your first request with curl.
Request
curl https://api.mafdet.ai/v1/chat/completions \
-H "Authorization: Bearer sk-mafdet-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3-flash-lite",
"messages": [{ "role": "user", "content": "Describe Mafdet AI in one sentence" }]
}'
Replace sk-mafdet-xxxxxxxxxxxxxxxx with your own key.
Successful response
{
"id": "chatcmpl-...",
"model": "gemini-3-flash-lite",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Mafdet AI is a unified AI model gateway." },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 12, "completion_tokens": 18, "total_tokens": 30 }
}
The reply text is in choices[0].message.content.
Common failures
| Symptom | Meaning | Fix |
|---|---|---|
401 unauthorized | Wrong key or bad format | Check Authorization: Bearer sk-mafdet-... |
insufficient_credit | Out of balance | See Balance & usage |
MODEL_NOT_ALLOWED | Account/key lacks access to the model | See Permissions & model scope |
Full list at Errors & troubleshooting.