# HaryAI API: images (Seedream 5.5, Nano Banana 2)

Image generation is synchronous: one request returns the image. Use the same
API key as for chat and video. Get the key from
https://haryai.com/en/dashboard

## Models

| Model name | Model | Sizes | Formats |
|---|---|---|---|
| `dola-seedream-5-5-261028` | Seedream 5.5 (ByteDance) | `1K`, `1.5K`, `2K` (default), or `WIDTHxHEIGHT` | OpenAI Images |
| `gemini-3.1-flash-image` | Nano Banana 2 (Google) | `1K`, `2K`, `4K` | Gemini generateContent, OpenAI Chat Completions |

Images are paid from the balance only; a Coding Plan does not cover them.
A request that fails is not charged.

## Seedream 5.5: OpenAI Images format

```sh
curl https://api.haryai.com/v1/images/generations \
  -H "Authorization: Bearer $HARYAI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dola-seedream-5-5-261028",
    "prompt": "A cup of green tea on a wooden table by a window, morning light",
    "size": "1.5K",
    "watermark": false,
    "response_format": "b64_json"
  }'
```

Reply: `{"data": [{"b64_json": "…", "size": "1872x1248"}], "usage": {"generated_images": 1, …}}`

- `size`: `1K` or `1.5K` (same price; 1.5K is sharper), `2K` (the default,
  higher price), or explicit pixels such as `2048x1152`. Pixels up to
  2,610,000 are billed at the lower price. Describe the aspect ratio in the
  prompt when you use a tier name.
- `image`: reference images, a URL or an array of URLs (or
  `data:image/png;base64,…`). Refer to them in the prompt as "Image 1",
  "Image 2". Each reference image is billed.
- `watermark`: `false` for no watermark. The upstream default is `true`.
- `response_format`: `url` (the default; the link expires after about 24
  hours) or `b64_json`.
- `n`: images per request; each is billed. Image sets
  (`sequential_image_generation`) are not supported by this model.

## Nano Banana 2: Gemini format

Base URL: `https://api.haryai.com/v1beta`. The key goes in `x-goog-api-key`
(or `Authorization: Bearer`).

```sh
curl https://api.haryai.com/v1beta/models/gemini-3.1-flash-image:generateContent \
  -H "x-goog-api-key: $HARYAI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"role": "user", "parts": [{"text": "A cup of green tea on a wooden table by a window, morning light"}]}],
    "generationConfig": {"responseModalities": ["IMAGE"], "imageConfig": {"aspectRatio": "16:9", "imageSize": "2K"}}
  }'
```

The image is the part of `candidates[0].content.parts` with `inlineData`
(`mimeType`, base64 `data`). To edit an image, add it as another part:
`{"inlineData": {"mimeType": "image/png", "data": "<base64>"}}`.

## Nano Banana 2: OpenAI Chat Completions format

```sh
curl https://api.haryai.com/v1/chat/completions \
  -H "Authorization: Bearer $HARYAI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gemini-3.1-flash-image", "messages": [{"role": "user", "content": "Generate an image: a cup of green tea on a wooden table"}]}'
```

The image comes back in `choices[0].message.content` as a markdown image
with a data URI: `![image](data:image/png;base64,…)`.

`POST /v1/images/generations` does not serve this model.

## Billing

- Seedream 5.5: a price per output image (lower up to 2.61 MP, higher above)
  plus a price per reference image.
- Nano Banana 2: per token. An output image is a fixed number of tokens per
  size (1K 1,120, 2K 1,680, 4K 2,520); input text and images are billed as
  input tokens.
- Prices: https://haryai.com/en/pricing

## Errors

Key, model and balance errors use the chat shape
`{"error":{"message":"…","type":"new_api_error","code":"…"}}`:

| Status | Code | Meaning |
|---|---|---|
| 401 | (empty) | Missing or invalid key |
| 400 / 503 | `model_not_found` | Model not available to your account / not available now |
| 403 | `insufficient_user_quota` | Balance too low |

Upstream refusals (a bad field, a prompt or image the model's content
moderation blocks) come back with the upstream message and are not charged.
