{
  "openapi": "3.1.0",
  "info": {
    "title": "FoxBee AI API Gateway",
    "version": "2026.12.02",
    "summary": "Unified Multimodal AI API Gateway for Chat, Responses, Messages, Image Generation/Editing, and Async Video Generation.",
    "description": "Official machine-readable OpenAPI 3.1 specification for FoxBee (https://foxbeeai.com). Full Markdown guide for AI agents: https://foxbeeai.com/llms-full.txt"
  },
  "servers": [
    {
      "url": "https://foxbeeai.com",
      "description": "FoxBee Global Primary Gateway"
    },
    {
      "url": "https://api.foxbeeai.com",
      "description": "FoxBee Dedicated API Gateway"
    },
    {
      "url": "https://api-cn.foxbeeai.com",
      "description": "FoxBee Mainland China Accelerated Gateway"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "FoxBee API Key bound to the target model group (create keys at https://foxbeeai.com/keys)."
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "ImageGenerationRequest": {
        "type": "object",
        "required": [
          "model",
          "prompt"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "Group #11 ($0.065/img): gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2 | Group #30 4K ($0.11/img): gpt-image-2.6-flare, gpt-image-2.6-sunburst, gpt-image-2 | Group #47 ($0.07/img): muse-image (alias gpt-image-muse).",
            "examples": [
              "gpt-image-2.6-flare",
              "gpt-image-2.5-flare",
              "muse-image"
            ]
          },
          "prompt": {
            "type": "string",
            "description": "Detailed visual description of the desired image."
          },
          "size": {
            "type": "string",
            "default": "1024x1024",
            "description": "1K/2K presets (1024x1024, 1536x1024, 1024x1536, 2048x2048, 2048x1152, auto, 2K) and ratio strings (16:9, 9:16, 3:2, 2:3, 1:1) on Muse Image (#47, native 2K output), plus 4K presets on Group #30 (3840x2160, 2160x3840, 2880x2880, 3456x2304, 3200x2400, 3840x1600, or custom WxH in multiples of 16 within 256..3840)."
          },
          "aspect_ratio": {
            "type": "string",
            "description": "Optional ratio alias (e.g. 16:9, 9:16, 3:2, 2:3, 1:1) supported by Muse Image (#47)."
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4,
            "default": 1,
            "description": "1..4 for GPT Image groups (#11/#30); 1 for Muse Image (#47) and GIF/SVG outputs."
          },
          "quality": {
            "type": "string",
            "enum": [
              "auto",
              "low",
              "medium",
              "high",
              "xhigh",
              "max"
            ],
            "default": "auto",
            "description": "Group #11 supports auto|low|medium|high; Group #30 additionally unlocks xhigh|max."
          },
          "background": {
            "type": "string",
            "enum": [
              "auto",
              "transparent",
              "opaque"
            ],
            "description": "Supported on Group #30 (transparent requires png or webp)."
          },
          "output_format": {
            "type": "string",
            "enum": [
              "png",
              "webp",
              "jpeg",
              "gif",
              "svg"
            ],
            "default": "png",
            "description": "gif and svg are unlocked on Group #30 with gpt-image-2.6-flare / gpt-image-2.6-sunburst."
          },
          "output_compression": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "frame_count": {
            "type": "integer",
            "minimum": 2,
            "maximum": 16,
            "description": "Native GIF frame count (#30 only)."
          },
          "frame_duration_ms": {
            "type": "integer",
            "minimum": 20,
            "maximum": 2000,
            "description": "Native GIF frame duration in ms (#30 only)."
          },
          "response_format": {
            "type": "string",
            "enum": [
              "b64_json"
            ],
            "default": "b64_json",
            "description": "Always pass b64_json explicitly (especially required for Muse Image #47)."
          }
        }
      },
      "ImageGenerationResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "integer"
          },
          "output_format": {
            "type": "string"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "b64_json": {
                  "type": "string",
                  "description": "Base64-encoded image bytes."
                },
                "revised_prompt": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "VideoImageRef": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Base64 Data URL (e.g. data:image/png;base64,...) for PNG, JPEG, or WebP."
          }
        }
      },
      "VideoGenerationRequest": {
        "type": "object",
        "required": [
          "model",
          "prompt"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "Recommended: grok-imagine-video-1.5-lite (#64, $0.04-$0.15/s, 1-15s), grok-imagine-video-1.5-preview / grok-imagine-video-1.5 (#64, $0.10-$0.20/s, 1-15s, supports last_frame and up to 14 refs at 480p/720p), muse-video (#48, $0.10/s, 1-10s). Do NOT auto-select seedance-2.0/2.5 (#56, $10-$12/req) without explicit user confirmation.",
            "examples": [
              "grok-imagine-video-1.5-lite",
              "grok-imagine-video-1.5-preview",
              "grok-imagine-video-1.5",
              "muse-video"
            ]
          },
          "prompt": {
            "type": "string",
            "description": "Shot description including subject, camera motion, lighting, and atmosphere."
          },
          "duration": {
            "type": "integer",
            "minimum": 1,
            "maximum": 15,
            "default": 5,
            "description": "1..15 seconds for Grok 1.5 (#64); 1..10 seconds for Muse Video (#48)."
          },
          "resolution": {
            "type": "string",
            "enum": [
              "auto",
              "480p",
              "720p",
              "1080p"
            ],
            "default": "720p",
            "description": "Grok 1.5 supports 480p|720p|1080p (capped at 480p|720p when last_frame or 2+ reference_images are supplied). Muse Video supports auto|480p|720p."
          },
          "aspect_ratio": {
            "type": "string",
            "enum": [
              "auto",
              "16:9",
              "9:16",
              "1:1",
              "4:3",
              "3:4",
              "3:2",
              "2:3",
              "21:9"
            ],
            "default": "16:9"
          },
          "image": {
            "$ref": "#/components/schemas/VideoImageRef",
            "description": "Single opening-frame image (1 image I2V; may pair with last_frame on Grok 1.5). Mutually exclusive with reference_images."
          },
          "last_frame": {
            "$ref": "#/components/schemas/VideoImageRef",
            "description": "Optional ending-frame image (supported on grok-imagine-video-1.5 and grok-imagine-video-1.5-preview at 480p|720p). Mutually exclusive with reference_images."
          },
          "reference_images": {
            "type": "array",
            "minItems": 2,
            "maxItems": 14,
            "items": {
              "$ref": "#/components/schemas/VideoImageRef"
            },
            "description": "2..14 reference images (supported on grok-imagine-video-1.5 / grok-imagine-video-1.5-preview, resolution 480p|720p). Mutually exclusive with image and last_frame."
          }
        }
      },
      "VideoCreateResponse": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string",
            "description": "Async video task identifier used for status polling and /content download."
          },
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        }
      },
      "VideoStatusResponse": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "description": "Pending: pending|queued|processing|running|in_progress. Succeeded: done|succeeded|completed|success. Failed: failed|expired|cancelled|error."
          },
          "progress": {
            "type": "number",
            "minimum": 0,
            "maximum": 100
          },
          "video": {
            "type": "object",
            "properties": {
              "duration": {
                "type": "number"
              }
            }
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/model-plaza": {
      "get": {
        "operationId": "getPublicModelPlaza",
        "security": [],
        "summary": "List public FoxBee model groups, exact model IDs, and live pricing",
        "responses": {
          "200": {
            "description": "Public model catalog and group pricing JSON."
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "operationId": "listKeyModels",
        "summary": "List models unlocked by the authenticated FoxBee API key",
        "responses": {
          "200": {
            "description": "OpenAI-compatible model list for this API key."
          },
          "401": {
            "description": "Invalid or missing API key."
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "operationId": "getKeyBalanceAndUsage",
        "summary": "Query wallet balance / key quota remaining and usage stats for the authenticated API key (used by Kelivo, CC Switch, and chat clients)",
        "responses": {
          "200": {
            "description": "JSON object containing balance, remaining, unit, and usage summaries."
          },
          "401": {
            "description": "Invalid or missing API key."
          }
        }
      }
    },
    "/v1/images/generations": {
      "post": {
        "operationId": "createImageGeneration",
        "summary": "Generate images from text prompt (#11 GPT Image, #30 GPT 4K Image, #47 Muse Image)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageGenerationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated image(s) as b64_json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageGenerationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/images/edits": {
      "post": {
        "operationId": "createImageEdit",
        "summary": "Edit or inpaint images with 1..5 reference images and optional PNG mask",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt"
                ],
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "size": {
                    "type": "string",
                    "default": "1024x1024"
                  },
                  "n": {
                    "type": "integer",
                    "default": 1
                  },
                  "quality": {
                    "type": "string"
                  },
                  "background": {
                    "type": "string"
                  },
                  "output_format": {
                    "type": "string",
                    "default": "png"
                  },
                  "response_format": {
                    "type": "string",
                    "default": "b64_json"
                  },
                  "image": {
                    "type": "string",
                    "format": "binary",
                    "description": "Single reference image (PNG/JPEG/WebP). Use image[] when uploading 2+ images."
                  },
                  "image[]": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    },
                    "description": "Multiple reference images (2..4 on #11/#47, 2..5 on #30)."
                  },
                  "mask": {
                    "type": "string",
                    "format": "binary",
                    "description": "Optional PNG alpha mask (#30 GPT 4K Image only)."
                  },
                  "markup": {
                    "type": "string",
                    "format": "binary",
                    "description": "Optional PNG sketch guide (#30 GPT 4K Image only)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Edited image(s) as b64_json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageGenerationResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/videos/generations": {
      "post": {
        "operationId": "createVideoGeneration",
        "summary": "Step 1 of 3: Submit an async video generation task (#64 Grok 1.5 or #48 Muse Video)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoGenerationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted async video job with request_id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VideoCreateResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/videos/edits": {
      "post": {
        "operationId": "createVideoEdit",
        "summary": "Submit an async Muse video edit job (#48 muse-video: source video + optional appearance reference_image or reference_video)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt",
                  "video"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "muse-video"
                    ],
                    "default": "muse-video"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "duration": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10,
                    "default": 5
                  },
                  "resolution": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "480p",
                      "720p"
                    ],
                    "default": "auto"
                  },
                  "aspect_ratio": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "16:9",
                      "9:16",
                      "1:1",
                      "4:3",
                      "3:4"
                    ]
                  },
                  "video": {
                    "description": "Source MP4/MOV/WebM (<= 10 MiB, 1-15s) as Base64 data URL, HTTPS URL, or {url} object."
                  },
                  "reference_image": {
                    "type": "string",
                    "description": "Optional appearance reference image data URL (mutually exclusive with reference_video and first-frame image)."
                  },
                  "reference_video": {
                    "description": "Optional appearance reference video data URL or {url} (mutually exclusive with reference_image)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted async video edit job with request_id (poll /v1/videos/{request_id} and download /v1/videos/{request_id}/content with same API key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VideoCreateResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/videos/{request_id}": {
      "get": {
        "operationId": "getVideoStatus",
        "summary": "Step 2 of 3: Poll async video job status using the EXACT SAME API key",
        "parameters": [
          {
            "name": "request_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current video job status and optional progress.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VideoStatusResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/videos/{request_id}/content": {
      "get": {
        "operationId": "downloadVideoContent",
        "summary": "Step 3 of 3: Stream rendered MP4 video with Bearer authentication",
        "parameters": [
          {
            "name": "request_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rendered MP4 binary stream.",
            "content": {
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          }
        }
      }
    },
    "/v1/responses": {
      "post": {
        "operationId": "createResponse",
        "summary": "OpenAI Responses API endpoint",
        "responses": {
          "200": {
            "description": "Responses JSON or SSE stream."
          }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "OpenAI Chat Completions API endpoint",
        "responses": {
          "200": {
            "description": "Chat completion JSON or SSE stream."
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "operationId": "createAnthropicMessage",
        "summary": "Anthropic Messages API endpoint",
        "responses": {
          "200": {
            "description": "Anthropic Message JSON or SSE stream."
          }
        }
      }
    }
  }
}
