# MAI Image 2.6 Flash

> 微软面向快速出图的图片生成与编辑模型

- 模型页: https://yir.ai/zh/models/mai-image-2-6-flash
- 模型 ID: `microsoft/mai-image-2.6-flash`
- 计费：按实际执行渠道的上游计费收取；上游未计费的尝试不收费。

## 价格

同一输出规格下各渠道的当前公开价；官方价为参考。实际按执行渠道计费，故障转移时可能切换渠道。

| 输出规格 | 渠道 | 公开价 |
|---|---|---|
| 1K | Microsoft (官方) | ≈$0.0195 / 张 |
| 1K | APIMart | ≈$0.0156 / 张 |
| 2K | Microsoft (官方) | ≈$0.0438 / 张 |
| 2K | APIMart | ≈$0.035 / 张 |
| auto | Microsoft (官方) | ≈$0.022 / 张 |
| auto | APIMart | ≈$0.0176 / 张 |

## 参数

- 操作: `generate_image`

| 参数 | 可选值 | 默认值 |
|---|---|---|
| `input` | text / image | text |
| `resolution` | 1K / 2K | 1K |
| `aspect_ratio` | 1:1 / 4:3 / 3:4 / 16:9 / 9:16 | 1:1 |

## 接入

两种方式任选：新项目用官方 SDK；已按 OpenAI 协议对接的项目换 Base URL 即可。

### 官方 SDK（TypeScript）

SDK 调用 Standard API（https://gateway.yir.ai），支持提交、等待和获取结果，另有 Go SDK。 https://yir.ai/zh/docs/integrations/sdk

```bash
pnpm add @yir-ai/sdk
```

```ts
import { createNodeYirClient } from "@yir-ai/sdk/server";

// Reads YIR_API_KEY from the environment by default: process.env.YIR_API_KEY
const client = createNodeYirClient();

// 1. Submit an image generation job
const job = await client.submitImage({
  model: "microsoft/mai-image-2.6-flash",
  input: {
    type: "text",
    prompt: "为一款柑橘气泡水设计产品海报：透明玻璃瓶与鲜橙，奶油色背景，柔和自然光，清晰的产品标签",
  },
  parameters: {
    resolution: "1K",
    aspect_ratio: "1:1",
    n: 1,
  },
});

// 2. Wait for the job to finish and deliver its result
const result = await client.waitForJob(job.id);
console.log("Delivered files:", result.result);
if (result.result && "files" in result.result) {
  for (const file of result.result.files) {
    console.log("->", file.url);
  }
}
```

### OpenAI 兼容 API

OpenAI Images 与 Sora Videos 协议，适用于 OpenAI SDK 和 new-api 等网关；不支持对话。 https://yir.ai/zh/docs/integrations/openai-compatibility

- OpenAI SDK base_url: `https://gateway.yir.ai/openai/v1`
- new-api 渠道 Base URL（渠道类型 OpenAI）: `https://gateway.yir.ai/openai`
- 模型 ID: `microsoft/mai-image-2.6-flash`

```bash
curl https://gateway.yir.ai/openai/v1/images/generations \
  -H "Authorization: Bearer $YIR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "microsoft/mai-image-2.6-flash",
    "prompt": "为一款柑橘气泡水设计产品海报：透明玻璃瓶与鲜橙，奶油色背景，柔和自然光，清晰的产品标签",
    "resolution": "1K",
    "aspect_ratio": "1:1"
  }'
```

## 常见问题

### MAI Image 2.6 Flash 有官方 API 吗？

有。Microsoft 通过自己的官方 API 提供 MAI Image 2.6 Flash，上表把它的刊例价列为官方参考价。通过 Yir 用一个 API Key 即可调用 MAI Image 2.6 Flash，并与各渠道的公开价对比。

## 接入须知

- 使用 Authorization: Bearer $YIR_API_KEY 鉴权；Key 只放服务端环境变量，不进浏览器代码、仓库、提示词或日志。
- 任务是异步的：提交后保存 Job ID，等待终态再读取结果；处理失败与取消。
- 安全重试时复用同一个幂等键和请求，不要在结果未知时盲目重新提交。
- 结果链接是临时的，需要长期保存请自行转存。

## 链接

- [快速开始](https://yir.ai/zh/docs/getting-started/quickstart)
- [API 参考](https://yir.ai/zh/docs/reference)
- [llms.txt](https://yir.ai/llms.txt)
