# Text generation

> The DiffusionGemma that answers System One reads also writes text. Any tool that talks to an OpenAI-style chat model can use it by changing the base URL.

Source: https://codiv.ai/docs/guides/text-generation

## Quick start

Use model `diffusiongemma-26b` at `https://api.codiv.ai/v1` with your Codiv key:

Python:

```python
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": "Summarize: 3 nonstop flights, cheapest $212 on Delta."}],
)
print(r.choices[0].message.content)
```

curl:

```bash
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": "Write a haiku about a GPU."}]}'
```

## How it differs from other chat models

DiffusionGemma is a diffusion model: it writes each 64-token block of the reply all at once and refines it over several denoising steps, instead of one token at a time. Some OpenAI fields don't apply, so Codiv adjusts requests rather than rejecting them:

- `temperature`, `seed`, `min_p`, `logit_bias`, the penalties and `reasoning` are ignored.
- `response_format` (`json_object` or `json_schema`) becomes an instruction to reply with JSON only, and the first JSON object in the reply is returned as `content`. A schema is passed to the model as guidance; it is not enforced.
- `max_tokens` defaults to 1024 and is capped at 8192.
- Thinking is off by default. Turn it on with `chat_template_kwargs: {"enable_thinking": true}`; the thought comes back in `message.reasoning`, never in `content`.
- `stream: true` streams server-sent events, ending with a usage chunk.
- `tools` and `tool_choice` are supported.

See the [Chat completions reference](https://codiv.ai/docs/api-reference/chat-completions.md) for every field.

## Quota and capacity

Text generation has its own free quota of **10M tokens**, input and output together, separate from your System One quota. Both are shown on the [dashboard](https://codiv.ai/dashboard).

Generation costs far more GPU time than a System One read, so at most 8 generations run at once. When they are all busy, requests return `529` with a `retry-after` header; retry with backoff. System One reads are never slowed by generation.

## Using it with jev-ultrafast

[browser-use/jev-ultrafast](https://github.com/browser-use/jev-ultrafast) pairs Jev with a fast text model. To run it entirely on Codiv, set these in its `.env`:

.env:


```bash
TYPESAFE_API_KEY=sk-codiv-...
TEXT_MODEL_API_KEY=sk-codiv-...
TEXT_MODEL_BASE_URL=https://api.codiv.ai/v1
TEXT_MODEL=diffusiongemma-26b
TEXT_MODEL_REASONING=none
```

jev-ultrafast calls `https://api.typesafe.ai/v1/systemone` directly instead of reading a base URL, so change that one line in `model.py` to point at Codiv:

model.py:


```python
result = post_json("https://api.codiv.ai/v1/systemone", os.environ["TYPESAFE_API_KEY"], body)
```

## Try it

The [Text playground](https://codiv.ai/playground?tab=text) is a chat box against `diffusiongemma-26b`, with JSON mode and thinking toggles.
