{
  "openapi": "3.1.0",
  "info": {
    "title": "ClipRelay AI Unified Multimodal API & MCP Gateway",
    "version": "2.1.0",
    "description": "Unified OpenAI-compatible REST API and native Model Context Protocol (/mcp) gateway providing pay-as-you-go USD access to 64 video, image, and LLM models with $0 monthly subscription and 100% automatic refunds on failed tasks.",
    "contact": {
      "name": "ClipRelay AI Developer Support",
      "url": "https://cliprelayai.com/docs",
      "email": "support@cliprelayai.com"
    }
  },
  "servers": [
    {
      "url": "https://cliprelayai.com",
      "description": "ClipRelay AI Global Production Gateway"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sk-...",
        "description": "Create a unified sk- API key at https://cliprelayai.com/relay"
      }
    }
  },
  "paths": {
    "/v1/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List all enabled video, image, and LLM models",
        "tags": [
          "Models"
        ],
        "responses": {
          "200": {
            "description": "OpenAI-compatible model list"
          }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "Streaming & non-streaming chat, coding, reasoning, and tool calling",
        "tags": [
          "Chat & Reasoning LLMs"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "claude-sonnet-5-5",
                      "claude-opus-5-5",
                      "claude-fable-5-2",
                      "claude-haiku-5-5",
                      "gpt-6.2-astra",
                      "gpt-6.2-sol",
                      "gemini-4-neon",
                      "gemini-3.8-flash",
                      "deepseek-v4-pro",
                      "deepseek-v4.1-flash",
                      "kimi-k3.1-pro",
                      "kimi-k2.7-code",
                      "glm-5.3",
                      "qwen3.8-max",
                      "grok-4.7",
                      "gpt-6.1-sol",
                      "gpt-6.1-terra",
                      "gpt-6-astra",
                      "gpt-6-sol",
                      "claude-sonnet-5",
                      "claude-opus-5",
                      "claude-opus-4-8",
                      "claude-fable-5-1",
                      "claude-fable-5",
                      "gemini-4-carbon",
                      "gemini-4-hydrogen",
                      "grok-4.6",
                      "grok-4.5",
                      "glm-5.3-flashx",
                      "glm-5.3-flash",
                      "glm-5.2",
                      "glm-5.1",
                      "kimi-k3.1-pro-highspeed",
                      "kimi-k3",
                      "kimi-k2.6"
                    ],
                    "example": "deepseek-v4.1-flash"
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "stream": {
                    "type": "boolean",
                    "default": false
                  },
                  "max_tokens": {
                    "type": "integer"
                  },
                  "temperature": {
                    "type": "number"
                  },
                  "tools": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion or SSE token stream"
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "operationId": "createAnthropicMessage",
        "summary": "Native Anthropic Messages API (Claude Code, Anthropic SDK, Prompt Caching, Extended Thinking & tool use)",
        "tags": [
          "Chat & Reasoning LLMs"
        ],
        "parameters": [
          {
            "name": "anthropic-version",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "default": "2023-06-01"
            }
          },
          {
            "name": "anthropic-beta",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "max_tokens",
                  "messages"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "claude-sonnet-5-5",
                      "claude-opus-5-5",
                      "claude-fable-5-2",
                      "claude-haiku-5-5",
                      "claude-sonnet-5",
                      "claude-opus-5",
                      "claude-opus-4-8",
                      "claude-fable-5-1",
                      "claude-fable-5"
                    ],
                    "example": "claude-sonnet-5-5"
                  },
                  "max_tokens": {
                    "type": "integer",
                    "default": 1024
                  },
                  "system": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      }
                    ]
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "stream": {
                    "type": "boolean",
                    "default": false
                  },
                  "tools": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Anthropic Messages JSON or SSE event stream"
          }
        }
      }
    },
    "/v1/messages/count_tokens": {
      "post": {
        "operationId": "countAnthropicTokens",
        "summary": "Native Anthropic token count endpoint for Claude Code context estimation (free)",
        "tags": [
          "Chat & Reasoning LLMs"
        ],
        "responses": {
          "200": {
            "description": "Estimated input_tokens count"
          }
        }
      }
    },
    "/v1/images/generations": {
      "post": {
        "operationId": "createImageGeneration",
        "summary": "Generate 1K–4K commercial images with per-image USD metering",
        "tags": [
          "Image Generation"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "nano-banana-pro",
                      "nano-banana-2.1",
                      "seedream-5.5",
                      "gpt-image-2.6",
                      "grok-imagine-2.0",
                      "midjourney",
                      "nano-banana-2",
                      "nano-banana-2-lite",
                      "seedream-5.0-pro",
                      "seedream-5.0-flash",
                      "gpt-image-2.6-flare",
                      "gpt-image-2.6-sunburst",
                      "gpt-image-2.5-flare",
                      "gpt-image-2.5-sunburst",
                      "gpt-image-2"
                    ],
                    "example": "seedream-5.5"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "size": {
                    "type": "string",
                    "example": "1536x864"
                  },
                  "resolution": {
                    "type": "string",
                    "enum": [
                      "1k",
                      "2k",
                      "4k"
                    ]
                  },
                  "aspect_ratio": {
                    "type": "string",
                    "example": "16:9"
                  },
                  "n": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 4,
                    "default": 1
                  },
                  "image_urls": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated image URLs or base64 data"
          }
        }
      }
    },
    "/v1/video/generations": {
      "post": {
        "operationId": "createVideoGeneration",
        "summary": "Submit async text-to-video, image-to-video, or first/last-frame video job (100% auto-refund on failure)",
        "tags": [
          "Async Video Generation"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "seedance-2.5",
                      "seedance-2.5-flash",
                      "kling-4.0",
                      "grok-imagine-video-1.5",
                      "gemini-omni-1.2-flash",
                      "minimax-h3",
                      "wan-3.0",
                      "magi-2",
                      "seedance-2.0",
                      "seedance-2.0-fast",
                      "seedance-2.0-mini",
                      "kling-3.0",
                      "wan-3-prime",
                      "kling-4.0-flash"
                    ],
                    "example": "seedance-2.5"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "resolution": {
                    "type": "string",
                    "enum": [
                      "480p",
                      "720p",
                      "768p",
                      "1080p",
                      "2k",
                      "4k"
                    ],
                    "default": "720p"
                  },
                  "duration": {
                    "type": "integer",
                    "example": 5
                  },
                  "aspect_ratio": {
                    "type": "string",
                    "enum": [
                      "16:9",
                      "9:16",
                      "1:1",
                      "4:3",
                      "3:4",
                      "21:9"
                    ],
                    "default": "16:9"
                  },
                  "first_frame_url": {
                    "type": "string"
                  },
                  "last_frame_url": {
                    "type": "string"
                  },
                  "image_urls": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "generate_audio": {
                    "type": "boolean",
                    "default": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns async task_id for status polling"
          }
        }
      }
    },
    "/v1/video/generations/{task_id}": {
      "get": {
        "operationId": "getVideoGenerationStatus",
        "summary": "Poll async video task status and signed MP4 URL",
        "tags": [
          "Async Video Generation"
        ],
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Task status (queued, processing, succeeded, failed)"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpStreamableHttp",
        "summary": "Native Streamable HTTP Model Context Protocol (MCP) JSON-RPC endpoint",
        "tags": [
          "Model Context Protocol (MCP)"
        ],
        "responses": {
          "200": {
            "description": "JSON-RPC 2.0 response exposing generate_video, generate_image, upscale_image, get_task"
          }
        }
      }
    }
  }
}