> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mynth.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Images

> Create image tasks with the Mynth SDK or the REST API.

Mynth image generation starts with a request to `POST /image/generate`. You can call it through the official SDK or directly over HTTP.

## Use the JavaScript SDK

```ts theme={"theme":"kanagawa-dragon"}
import Mynth from "@mynthio/sdk";

const mynth = new Mynth();

const task = await mynth.image.generate({
  prompt: "Architectural photograph of a brutalist library at golden hour",
  model: "google/gemini-3.1-flash-image",
  size: "landscape",
  count: 1,
});

console.log(task.urls);
```

## Use the REST API

```bash theme={"theme":"kanagawa-dragon"}
curl https://api.mynth.io/image/generate \
  -X POST \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Architectural photograph of a brutalist library at golden hour",
    "model": "google/gemini-3.1-flash-image",
    "size": "landscape",
    "count": 1
  }'
```

Example response:

```json theme={"theme":"kanagawa-dragon"}
{
  "data": {
    "taskId": "tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP",
    "access": {
      "publicAccessToken": "pat_eyJhbGciOi..."
    }
  }
}
```

## What happens next

Creating a task does not return final images immediately. Mynth creates a task first, then you retrieve the result in one of two ways:

* wait for completion in the SDK
* poll task endpoints or receive webhooks

Read [Async and polling](/guides/async-and-polling) for the decision.

## Common request fields

| Field             | Purpose                                                                |
| ----------------- | ---------------------------------------------------------------------- |
| `prompt`          | The prompt text.                                                       |
| `model`           | A specific model ID, or `"auto"` to let Mynth choose.                  |
| `size`            | Preset, aspect ratio, or `"auto"`.                                     |
| `count`           | Number of images to generate. Maximum: `20`.                           |
| `negative_prompt` | Text to discourage in the generated image.                             |
| `magic_prompt`    | Set to `true` to let Mynth rewrite your prompt for better results.     |
| `inputs`          | Optional input images by URL or structured input objects.              |
| `output`          | Output format and quality.                                             |
| `webhook`         | Task-level webhook controls and extra custom endpoints.                |
| `rating`          | Optional content classification settings.                              |
| `metadata`        | Application-specific data returned with the task and webhook payloads. |

## Choose a model

Set `model` explicitly in production. `model: "auto"` is an early preview feature. Browse models at [mynth.io/models](https://mynth.io/models).
