{
  "openapi": "3.1.0",
  "info": {
    "title": "MAI-Image-2.7",
    "version": "1.0.0",
    "description": "Asynchronous image generation and editing with up to 5 reference URLs, 1K/2K or exact pixel dimensions, PNG output, and token-based billing."
  },
  "servers": [
    {
      "url": "https://api.seedrouter.ai"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/v1/images/generations": {
      "post": {
        "operationId": "createMaiImage27",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$schema": "https://json-schema.org/draft/2020-12/schema",
                "type": "object",
                "properties": {
                  "model": {
                    "type": "string",
                    "const": "mai-image-2.7"
                  },
                  "prompt": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20000,
                    "pattern": "\\S",
                    "description": "Image description or editing instruction; 1–20000 Unicode characters after trimming."
                  },
                  "n": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1,
                    "default": 1,
                    "description": "Number of images to generate. Only 1 is supported; submit separate tasks for multiple images."
                  },
                  "size": {
                    "type": "string",
                    "default": "1:1",
                    "description": "Text-to-image only. Either an integer aspect ratio from 1:4 to 4:1 (e.g. 16:9) paired with resolution, or pixel dimensions WIDTHxHEIGHT (* and × also accepted) with each side >= 768 and width × height <= 4,194,304. auto is not supported."
                  },
                  "resolution": {
                    "type": "string",
                    "default": "1K",
                    "enum": [
                      "1K",
                      "2K"
                    ],
                    "description": "Output resolution tier (1K or 2K, case-insensitive). Applies only when size is an aspect ratio. 4K is not supported."
                  },
                  "width": {
                    "type": "integer",
                    "minimum": 768,
                    "maximum": 4194304,
                    "description": "Exact pixel width (>= 768). Must be paired with height; overrides size and resolution. Text-to-image only."
                  },
                  "height": {
                    "type": "integer",
                    "minimum": 768,
                    "maximum": 4194304,
                    "description": "Exact pixel height (>= 768). Must be paired with width; width × height <= 4,194,304 (2048×2048). Text-to-image only."
                  },
                  "image_urls": {
                    "minItems": 1,
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uri"
                    },
                    "description": "1–5 public HTTP(S) image URLs without credentials for single-image editing or multi-image composition (JPEG, PNG, WebP, GIF). Output dimensions are determined from reference images."
                  },
                  "background": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "opaque"
                    ],
                    "default": "auto",
                    "description": "Background type: auto or opaque. Transparent background is not supported."
                  }
                },
                "required": [
                  "model",
                  "prompt"
                ],
                "additionalProperties": false,
                "description": "9 fields. Only model and prompt are required. No field accepts null. Use image_urls for editing or multi-image composition. Output is always PNG via asynchronous task polling."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted task",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "model",
                    "status"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "model": {
                      "const": "mai-image-2.7"
                    },
                    "status": {
                      "const": "processing"
                    },
                    "created_at": {
                      "type": "integer",
                      "description": "Unix seconds"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Request or task error; see the shared error directory.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Request or task error; see the shared error directory.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Request or task error; see the shared error directory.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks/{id}": {
      "get": {
        "operationId": "getMaiImage27Task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Task status; output exists only after completion",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "model": {
                      "type": "string"
                    },
                    "status": {
                      "enum": [
                        "processing",
                        "completed",
                        "failed"
                      ]
                    },
                    "output": {
                      "type": "object",
                      "properties": {
                        "created": {
                          "type": "integer",
                          "description": "Creation time in Unix seconds"
                        },
                        "output_format": {
                          "enum": [
                            "png"
                          ]
                        },
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "url"
                            ],
                            "properties": {
                              "url": {
                                "type": "string",
                                "format": "uri"
                              },
                              "size": {
                                "type": "string",
                                "pattern": "^[1-9][0-9]*x[1-9][0-9]*$"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "usage": {
                          "type": "object",
                          "properties": {
                            "generated_images": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "input_tokens": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "output_tokens": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "total_tokens": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "input_tokens_details": {
                              "type": "object",
                              "properties": {
                                "text_tokens": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "image_tokens": {
                                  "type": "integer",
                                  "minimum": 0
                                }
                              }
                            },
                            "output_tokens_details": {
                              "type": "object",
                              "properties": {
                                "image_tokens": {
                                  "type": "integer",
                                  "minimum": 0
                                }
                              }
                            }
                          }
                        }
                      },
                      "additionalProperties": false
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Request or task error; see the shared error directory.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
