API reference

Chat completions

Generate text with DiffusionGemma 26B. The request and response follow OpenAI's chat completions format.

Create a chat completion

Endpoint
POST https://api.codiv.ai/v1/chat/completions

Authenticate with Authorization: Bearer <key>. Usage counts toward your text-generation quota.

Request body

modelstringRequired

diffusiongemma-26b.

messagesarrayRequired

The conversation, as OpenAI message objects (system, user, assistant, tool). User content can include image_url parts.

max_tokensintegerOptional

Most 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.

streambooleanOptional

Stream server-sent events. The last event before [DONE] carries usage.

toolsarrayOptional

Function 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
  }'
Response
{
  "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
{"error": {"message": "...", "type": "rate_limit_error", "code": "rate_limit_exceeded"}}
StatustypeWhen
400invalid_request_errorThe request is malformed, or the model rejected it
401authentication_errorUnknown or revoked key
403authentication_errorNo key sent
403permission_errorThe account is disabled or its email is not verified
413invalid_request_errorBody larger than 8 MB
429rate_limit_errorToo many requests per minute on one key
429insufficient_quotaThe text-generation quota is used up
503api_errorThe model failed on this request
529overloaded_errorAll 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.