# generate

Canonical URL: https://developers.iagenify.com/sdk/agent/tools/generate/
Language: en

`generate({ prompt, model?, schema?, instructions? })`

Ask a second, cheaper model one question without carrying the material through the conversation. For volume: classify two hundred rows, extract a field from fifty pages.

Status: category: write · costs like any model call · schema for JSON

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `prompt` | string | required | The whole question, material included. |
| `model` | string |  | A fast cheap one by default. |
| `schema` | string |  | The shape of the answer, as JSON text. Gets an object back instead of prose. |
| `instructions` | string |  | A system instruction for it. |

## Why it exists {#why}

> **The material never enters the agent's own context**
>
> Fifty pages read into the conversation are paid for on every later turn. Sent to a second model, they are paid for once — and the agent gets back only the answer.

## It is for volume {#volume}

- Classify two hundred rows: one call each.
- Extract one field from fifty pages.
- Summarise twenty documents.

The instruction is explicit the other way too: never use it for something answerable in a sentence. A second model call to do what the agent can already do is pure cost.

## Structured answers {#schema}

```javascript
generate({
  prompt: "Classify this support message: …",
  schema: '{"type":"object","properties":{"sentiment":{"type":"string"},"urgent":{"type":"boolean"}}}',
})
```

## It is billed {#cost}

Like any model call, and it counts against the run's budget. Its category is `write`, so it is asked in ask mode and free in auto.

- [task](/sdk/agent/tools/task): Delegating a whole job instead of one question.
- [models.turn()](/sdk/ref/models/turn): Doing it yourself.
- [Agent tools](/sdk/agent/tools): The 35, by family.

```python
# The call the model makes:
generate = {
    "prompt": "Classify this support message: …",
    "schema": '{"type":"object","properties":{"sentiment":{"type":"string"},"urgent":{"type":"boolean"}}}',
}
```
