Chat Completions
POST /v1/chat/completions — OpenAI-compatible.
curl https://api.doodbrain.com/v1/chat/completions \
-H "Authorization: Bearer $DOODBRAIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"doodbrain","messages":[{"role":"user","content":"Hello"}]}' import os, requests
r = requests.post(
"https://api.doodbrain.com/v1/chat/completions",
headers={"Authorization": f"Bearer {os.environ['DOODBRAIN_API_KEY']}"},
json={"model":"doodbrain","messages":[{"role":"user","content":"Hello"}]},
)
print(r.json())const r = await fetch("https://api.doodbrain.com/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DOODBRAIN_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ model: "doodbrain", messages: [{ role: "user", content: "Hello" }] }),
});
console.log(await r.json());$payload = json_encode(["model"=>"doodbrain","messages"=>[["role"=>"user","content"=>"Hello"]]]);
$ch = curl_init("https://api.doodbrain.com/v1/chat/completions");
curl_setopt_array($ch, [CURLOPT_HTTPHEADER=>["Authorization: Bearer ".getenv("DOODBRAIN_API_KEY"),"Content-Type: application/json"], CURLOPT_POST=>true, CURLOPT_POSTFIELDS=>$payload, CURLOPT_RETURNTRANSFER=>true]);
echo curl_exec($ch);Example response shape
{
"id": "chatcmpl-...",
"object": "chat.completion",
"model": "doodbrain",
"choices": [{"index": 0, "message": {"role": "assistant", "content": "..."}, "finish_reason": "stop"}],
"usage": {"prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0}
}
Streaming is supported when stream: true is set (SSE chunks).