Chat Completions
POST https://api.mafdet.ai/v1/chat/completions
The OpenAI-compatible chat completion endpoint — the core way to call Mafdet AI.
Request fields
Response fields
Node.js example
const res = await fetch("https://api.mafdet.ai/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MAFDET_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gemini-3-flash-lite",
messages: [
{ role: "system", content: "You are a concise assistant." },
{ role: "user", content: "Hello" },
],
}),
});
const data = await res.json();
console.log(data.choices[0].message.content);
Python example
from openai import OpenAI
client = OpenAI(
base_url="https://api.mafdet.ai/v1",
api_key="sk-mafdet-xxxxxxxxxxxxxxxx",
)
resp = client.chat.completions.create(
model="gemini-3-flash-lite",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
Next steps