API reference
Chat completions
Generate text with DiffusionGemma 26B. The request and response follow OpenAI's chat completions format.
Create a chat completion
POST https://api.codiv.ai/v1/chat/completionsAuthenticate with Authorization: Bearer <key>. Usage counts toward your text-generation quota.
Request body
modelstringRequireddiffusiongemma-26b.
messagesarrayRequiredThe conversation, as OpenAI message objects (system, user, assistant, tool). User content can include image_url parts.
max_tokensintegerOptionalMost tokens to generate. Defaults to 1024, capped at 8192. max_completion_tokens is accepted too.
response_formatobjectOptional{"type": "json_object"} or {"type": "json_schema", "json_schema": {...}}. The model is told to reply with JSON only, and the first JSON object in its reply is returned as content. The schema guides the model but is not enforced.
streambooleanOptionalStream server-sent events. The last event before [DONE] carries usage.
toolsarrayOptionalFunction tools, with tool_choice "auto", "none" or a named function.
chat_template_kwargsobjectOptional{"enable_thinking": true} lets the model think before answering. Off by default.
Ignored: temperature, seed, min_p, logit_bias, presence_penalty, frequency_penalty and reasoning. A diffusion model has no per-token sampling for them to control.
Returns
A chat completion object. message.content is the reply; message.reasoning holds the thought when thinking is on. usage.prompt_tokens and usage.completion_tokens are what count toward your quota.
curl https://api.codiv.ai/v1/chat/completions \
-H "Authorization: Bearer $CODIV_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "diffusiongemma-26b",
"messages": [{"role": "user",
"content": "Name three fruits as JSON: {\"fruits\": [...]}"}],
"response_format": {"type": "json_object"},
"max_tokens": 256
}'from openai import OpenAI
client = OpenAI(base_url="https://api.codiv.ai/v1",
api_key="sk-codiv-...")
r = client.chat.completions.create(
model="diffusiongemma-26b",
messages=[{"role": "user",
"content": "Name three fruits as JSON: {\"fruits\": [...]}"}],
response_format={"type": "json_object"},
max_tokens=256,
)
print(r.choices[0].message.content){
"id": "chatcmpl-9f2c41",
"object": "chat.completion",
"model": "diffusiongemma-26b",
"choices": [{
"index": 0,
"message": {"role": "assistant",
"content": "{\"fruits\": [\"apple\", \"mango\", \"kiwi\"]}"},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 41, "completion_tokens": 64,
"total_tokens": 105}
}Errors
Errors use OpenAI's shape:
{"error": {"message": "...", "type": "rate_limit_error", "code": "rate_limit_exceeded"}}| Status | type | When |
|---|---|---|
| 400 | invalid_request_error | The request is malformed, or the model rejected it |
| 401 | authentication_error | Unknown or revoked key |
| 403 | authentication_error | No key sent |
| 403 | permission_error | The account is disabled or its email is not verified |
| 413 | invalid_request_error | Body larger than 8 MB |
| 429 | rate_limit_error | Too many requests per minute on one key |
| 429 | insufficient_quota | The text-generation quota is used up |
| 503 | api_error | The model failed on this request |
| 529 | overloaded_error | All generation slots are busy. Retry after retry-after. |
Generation denoises the reply in 64-token blocks, so a completion takes seconds, not milliseconds. Retry 429 rate_limit_error and 529 with backoff; don't retry insufficient_quota.