# MAI-Image-2.7 (https://reapi.ai/docs/mai-image-2-7)

import { Tab, Tabs } from 'fumadocs-ui/components/tabs';

MAI-Image-2.7 generates high-resolution images from text prompts and performs multi-image reference editing up to 4.19 megapixels (`2048×2048`). See the [model page](/models/mai-image-2-7) for current token rates and the interactive playground.

## Quick example

<Tabs items={['cURL', 'Python', 'Node.js', 'Go']}>
  <Tab value="cURL">
    ```bash
    curl https://api.reapi.ai/v1/images/generations \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      -H 'Content-Type: application/json' \
      -d '{"model":"mai-image-2.7","prompt":"A matte ivory ceramic pour-over kettle on pale slate, soft morning light","size":"1:1","resolution":"1K","n":1}'
    ```
  </Tab>

  <Tab value="Python">
    ```python
    import requests

    response = requests.post(
        "https://api.reapi.ai/v1/images/generations",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
        json={
            "model": "mai-image-2.7",
            "prompt": "A matte ivory ceramic pour-over kettle on pale slate, soft morning light",
            "size": "1:1",
            "resolution": "1K",
            "n": 1,
        },
        timeout=60,
    )
    response.raise_for_status()
    task_id = response.json()["id"]
    ```
  </Tab>

  <Tab value="Node.js">
    ```javascript
    const response = await fetch('https://api.reapi.ai/v1/images/generations', {
      method: 'POST',
      headers: {
        Authorization: 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        model: 'mai-image-2.7',
        prompt: 'A matte ivory ceramic pour-over kettle on pale slate, soft morning light',
        size: '1:1',
        resolution: '1K',
        n: 1,
      }),
    });
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    const { id: taskId } = await response.json();
    ```
  </Tab>

  <Tab value="Go">
    ```go
    package main

    import (
        "encoding/json"
        "fmt"
        "net/http"
        "strings"
        "time"
    )

    func main() {
        body := strings.NewReader(`{"model":"mai-image-2.7","prompt":"A matte ivory ceramic pour-over kettle on pale slate, soft morning light","size":"1:1","resolution":"1K","n":1}`)
        req, err := http.NewRequest("POST", "https://api.reapi.ai/v1/images/generations", body)
        if err != nil { panic(err) }
        req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
        req.Header.Set("Content-Type", "application/json")
        client := &http.Client{Timeout: 60 * time.Second}
        res, err := client.Do(req)
        if err != nil { panic(err) }
        defer res.Body.Close()
        if res.StatusCode != http.StatusOK { panic(res.Status) }
        var task struct { ID string `json:"id"` }
        if err := json.NewDecoder(res.Body).Decode(&task); err != nil { panic(err) }
        fmt.Println(task.ID)
    }
    ```
  </Tab>
</Tabs>

## Endpoint

`POST https://api.reapi.ai/v1/images/generations`

Send `Authorization: Bearer YOUR_API_KEY` and `Content-Type: application/json`.
An accepted request returns an asynchronous task `id` and `status: "processing"`. Poll `GET https://api.reapi.ai/v1/tasks/TASK_ID` with the same key until the task reaches `completed` or `failed`.
Each POST creates a separate generation. If a submission times out on the client, check your task list before resubmitting.

## Parameters

| Parameter    | Type       | Default  | Documented behavior                                                                                                                                                                                          |
| ------------ | ---------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `model`      | `string`   | —        | Required. Set to `"mai-image-2.7"`.                                                                                                                                                                          |
| `prompt`     | `string`   | —        | Required. 1–20,000 Unicode characters after trimming.                                                                                                                                                        |
| `n`          | `integer`  | `1`      | Number of images per request. Must be `1`.                                                                                                                                                                   |
| `size`       | `string`   | `"1:1"`  | Text-to-image only. Integer aspect ratio between `1:4` and `4:1` (`1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `16:9`, `9:16`, `2:1`, `1:2`, `21:9`, `9:21`, `4:1`, `1:4`) or `WIDTHxHEIGHT`. `auto` is not supported. |
| `resolution` | `string`   | `"1K"`   | `"1K"` or `"2K"` (case-insensitive). Applies only when `size` is an aspect ratio. `4K` is rejected.                                                                                                          |
| `width`      | `integer`  | —        | Optional custom width in pixels (at least `768`). Must be paired with `height`; overrides `size` and `resolution` for text-to-image.                                                                         |
| `height`     | `integer`  | —        | Optional custom height in pixels (at least `768`). Must be paired with `width`; `width × height` must be at most `4,194,304`. Sides are rounded down to multiples of `32`.                                   |
| `image_urls` | `string[]` | —        | Optional array of 1–5 public HTTP(S) reference image URLs without embedded credentials (JPEG, PNG, WebP, or GIF; base64 data URIs are rejected).                                                             |
| `background` | `string`   | `"auto"` | `"auto"` or `"opaque"`. Transparent backgrounds are not supported.                                                                                                                                           |

## Reference image editing

Pass 1–5 public HTTP(S) URLs in `image_urls` for single-image editing or multi-image composition. When `image_urls` is supplied, the model derives output dimensions from the reference images; `size`, `resolution`, `width`, and `height` do not control image-to-image output dimensions.

```json
{
  "model": "mai-image-2.7",
  "prompt": "Change the ceramic glaze to matte cobalt blue while keeping the lighting and table surface unchanged",
  "image_urls": [
    "https://example.com/kettle.png"
  ]
}
```

## Billing

MAI-Image-2.7 is billed across three token categories: text input, image input, and image output. Admission reserves an estimate; completion settles on the measured usage returned for each category. Failed requests are not charged. See [live pricing](/models/mai-image-2-7#pricing).

## Related pages

* [MAI-Image-2.7 model page and playground](/models/mai-image-2-7)
* [MAI-Image-2.7 Flash API docs](/docs/mai-image-2-7-flash)
