# image

Canonical URL: https://developers.iagenify.com/sdk/ref/tools/image/
Language: en

`tools: { image: api.tools.image }, model: { main, image }`

Lets a run generate an image. It is a declaration resolved against a model session named image — so the model that writes is not the model that draws.

Status: declaration only · needs an image session · declared cost 26

Nothing to call. What produces the image is a [model session](/sdk/ref/models/create) you created and handed to the run under the name `image`.

## Declaring it {#declaring}

```javascript
const writer = await api.models.create({ model: "gemini-3.5-flash" });
const painter = await api.models.create({ model: "gemini-3.1-flash-image" });

const agent = api.agents.create({
  model: { main: writer, image: painter },     // the name matters
  tools: { image: api.tools.image },
  budget: 200,
});

const run = await agent.run({
  inputs: [{ type: "text", content: "Draw a logo for a tide-forecasting app, then describe it." }],
});
```

> **The session's name is image, not whatever you called the tool**
>
> You may rename the tool freely; the session is looked up by the builtin's own name. Without an image entry in model, the run answers that no image session was supplied — and it says so instead of generating with the writing model.

## What the model sends {#arguments}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `prompt` | string | required | What to create. The whole description, in one argument. |

## Where the image goes {#result}

It is attached to the run as an artifact, and it is in the run's result — not written anywhere. Saving it is yours, which is what lets the same run serve a page, a file on the machine or a bucket.

```javascript
const [picture] = run.artifacts.filter((a) => a.type === "image");

await pc.files.write("Assets/logo.png", Buffer.from(picture.content, "base64"));
// or
await api.files.create({ name: "logo.png", content: Buffer.from(picture.content, "base64"),
                         mimeType: picture.mime }).save();
```

## The declared cost is 26, and it over-estimates {#cost}

The budget guard decides **before** the call, on the declared number — so that number has to be at or above what the generation really costs. 26 is the default; raise it with `cost` if you work with a more expensive model, and never lower it to fit a budget.

```javascript
tools: {
  image: { run: api.tools.image, cost: 40, options: { aspectRatio: "16:9" } },
}
```

`options` is merged into the session's settings for that call, so a fixed aspect ratio or quality can be pinned without taking the subject away from the model.

## What is charged {#billing}

The generation is billed to the account like any other, and the run's own credit total carries it. Nothing is charged when the guard refuses, since the call never happens.

## It feeds the video tool {#sequel}

The most recent image artifact of a run is passed to [video](/sdk/ref/tools/video) as its starting picture. So « draw it, then animate it » is two calls with nothing of yours in between.

- [video](/sdk/ref/tools/video): The clip, which can start from this image.
- [create_image](/sdk/agent/tools/create-image): The local engine's version, which writes the file for you.
- [api.tools](/sdk/ref/tools): The fifteen, and the two ways to use them.

```python
writer = api.models.create(model="gemini-3.5-flash")
painter = api.models.create(model="gemini-3.1-flash-image")

agent = api.agents.create(
    model={"main": writer, "image": painter},   # the name matters
    tools={"image": api.tools.image},
    budget=200,
)

run = agent.run(inputs=[
    {"type": "text", "content": "Draw a logo for a tide-forecasting app, then describe it."},
])
```

```python
import base64

picture = next(a for a in run["artifacts"] if a["type"] == "image")

pc.files.write("Assets/logo.png", base64.b64decode(picture["content"]))
# or
api.files.create(name="logo.png", content=base64.b64decode(picture["content"]),
                 mime_type=picture.get("mime")).save()
```

```python
tools = {
    "image": {"run": api.tools.image, "cost": 40, "options": {"aspectRatio": "16:9"}},
}
```
