Generate text from models using the Agent SDK's callModel() primitive.
Not yet available. The Agent SDK is tracked to be built — today, use the Client SDKs against the live chat completions API. The docs below describe the intended design.
Text generation is the foundation of every agent turn. callModel() sends a message list to the model and returns the generated text in result.output. This page covers the generation-specific knobs: temperature, token limits, and practical patterns for consistent output.
temperature (0–2) controls randomness. Lower values produce more deterministic output; higher values introduce more variation.
| Task | Recommended range |
|---|---|
| Structured extraction, classification | 0–0.3 |
| Technical writing, summarisation | 0.3–0.7 |
| Creative writing, brainstorming | 0.7–1.2 |
| Exploratory / unexpected output | 1.2–2.0 |
Set maxTokens to cap the length of the response. Useful to control cost on bulk generation tasks.
If the model hits the token limit before finishing, result.stopReason will be "max_tokens". The output is still returned as-is — truncated but usable.
For multi-turn conversations without tool calls, pass the previous turn's item list as inputItems:
Each TurnResult includes usage.costMicroDA — the exact DA cost of that turn in micro-DA (bigint). 1 DA = 1,000,000 micro-DA. Log it to build per-task cost tracking.