{
  "openapi": "3.1.0",
  "info": {
    "title": "rawroute Unified AI API",
    "version": "1.0.0",
    "description": "OpenAI-, Anthropic-, and Gemini-compatible unified API gateway for frontier chat, image, video, and audio models with automatic multi-provider failover and 0% top-up fee.",
    "termsOfService": "https://rawroute.dev/terms",
    "contact": {
      "name": "rawroute",
      "url": "https://rawroute.dev/"
    }
  },
  "externalDocs": {
    "description": "Documentation & llms.txt",
    "url": "https://rawroute.dev/docs"
  },
  "servers": [
    {
      "url": "https://api.rawroute.dev",
      "description": "rawroute production API gateway"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key"
      },
      "AnthropicKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      },
      "GeminiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-goog-api-key"
      }
    }
  },
  "paths": {
    "/v1/chat/completions": {
      "post": {
        "summary": "OpenAI-compatible chat completions",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "gemini-4-carbon",
                      "gemini-4-argon",
                      "gemini-4-neon",
                      "gemini-4-hydrogen",
                      "gemini-3.8-flash",
                      "claude-fable-5-2",
                      "claude-opus-5-5",
                      "claude-sonnet-5-5",
                      "claude-haiku-5-5",
                      "gpt-6.2-astra",
                      "gpt-6.2-sol",
                      "gpt-6.1-terra",
                      "grok-4.7",
                      "kimi-k3.1-pro"
                    ]
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "stream": {
                    "type": "boolean",
                    "default": false
                  },
                  "reasoning_effort": {
                    "type": "string",
                    "description": "For supported models. See thinking_levels.openai_chat in /models.json."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion or SSE stream"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "All upstream providers failed (not billed)"
          }
        }
      }
    },
    "/v1/responses": {
      "post": {
        "summary": "OpenAI Responses API for GPT models",
        "description": "Set reasoning.effort where supported. See thinking_levels.openai_responses in /models.json.",
        "responses": {
          "200": {
            "description": "Model response"
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "summary": "Native Anthropic Messages API for Claude models",
        "description": "Use adaptive thinking with output_config.effort. See thinking_levels.anthropic in /models.json.",
        "security": [
          {
            "AnthropicKey": []
          },
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Anthropic message response"
          }
        }
      }
    },
    "/v1beta/models/{model}:generateContent": {
      "post": {
        "summary": "Native Google Gemini REST API",
        "description": "For chat, set generationConfig.thinkingConfig.thinkingLevel where supported. For Gemini speech and transcription, see audio_inputs in /models.json.",
        "security": [
          {
            "GeminiKey": []
          },
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Gemini generateContent response"
          }
        }
      }
    },
    "/v1/images/generations": {
      "post": {
        "summary": "Image generation across Nano Banana 2/2.1, GPT Image 2.6, and Grok Imagine Image",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "gemini-3.1-flash-image",
                      "gemini-nano-banana-2.1",
                      "gpt-image-2.6",
                      "gpt-image-2.6-flare",
                      "gpt-image-2.6-sunburst",
                      "grok-imagine-image-2.0",
                      "grok-imagine-image-quality"
                    ]
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "n": {
                    "type": "integer",
                    "default": 1,
                    "description": "Up to image_inputs.max_images of the model (models.json)"
                  },
                  "size": {
                    "type": "string",
                    "description": "One of image_inputs.sizes, e.g. 1376x768; Nano Banana also takes 16:9 or auto"
                  },
                  "quality": {
                    "type": "string",
                    "description": "Only where image_inputs.qualities lists it"
                  },
                  "response_format": {
                    "type": "string",
                    "enum": [
                      "b64_json",
                      "url"
                    ],
                    "default": "b64_json"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated image payload"
          }
        }
      }
    },
    "/v1/images/edits": {
      "post": {
        "summary": "Image editing with reference images; per model see image_inputs.reference_images and edit_body",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt",
                  "image"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "gemini-3.1-flash-image",
                      "gemini-nano-banana-2.1",
                      "gpt-image-2.6",
                      "gpt-image-2.6-flare",
                      "gpt-image-2.6-sunburst",
                      "grok-imagine-image-2.0",
                      "grok-imagine-image-quality"
                    ]
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "image": {
                    "type": "string",
                    "format": "binary",
                    "description": "One file as image, several as image[] (PNG, JPEG or WebP)"
                  },
                  "size": {
                    "type": "string"
                  },
                  "n": {
                    "type": "integer",
                    "default": 1
                  },
                  "response_format": {
                    "type": "string",
                    "enum": [
                      "b64_json",
                      "url"
                    ],
                    "default": "b64_json"
                  }
                }
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "gemini-3.1-flash-image",
                      "gemini-nano-banana-2.1",
                      "gpt-image-2.6",
                      "gpt-image-2.6-flare",
                      "gpt-image-2.6-sunburst",
                      "grok-imagine-image-2.0",
                      "grok-imagine-image-quality"
                    ]
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "image": {
                    "type": "string",
                    "description": "One reference as a base64 data URL"
                  },
                  "images": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Several references as base64 data URLs"
                  },
                  "size": {
                    "type": "string"
                  },
                  "n": {
                    "type": "integer",
                    "default": 1
                  },
                  "response_format": {
                    "type": "string",
                    "enum": [
                      "b64_json",
                      "url"
                    ],
                    "default": "b64_json"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Edited image payload, billed per image like a generation"
          }
        }
      }
    },
    "/v1/videos": {
      "post": {
        "summary": "Submit per-second video generation task (all video models)",
        "description": "Supported resolutions, durations and advanced inputs are listed per model in /models.json. An input may be available only on the primary provider. Workflows labeled Preview only in a model playground cannot be submitted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "veo-3.1",
                      "veo-3.1-fast",
                      "gemini-omni-1.2-flash",
                      "grok-imagine-video-1.5",
                      "MiniMax-H3",
                      "wan3.0-video",
                      "wan3.0-video-prime",
                      "kling-4.0",
                      "kling-4.0-flash",
                      "seedance-2.5"
                    ]
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "seconds": {
                    "oneOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "string",
                        "pattern": "^[0-9]+$"
                      }
                    ]
                  },
                  "resolution": {
                    "type": "string"
                  },
                  "aspect_ratio": {
                    "type": "string"
                  },
                  "first_frame": {
                    "type": "string",
                    "description": "First frame URL or image data URL where allowed by the model."
                  },
                  "last_frame": {
                    "type": "string",
                    "description": "Last frame URL. A first frame is required unless the model allows a last frame alone."
                  },
                  "reference_images": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Image sources according to the model profile. Some models require data URLs or cannot combine them with frames."
                  },
                  "reference_videos": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Public video URLs, only where listed for the model."
                  },
                  "reference_audios": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Audio sources where supported. Some models require a reference image."
                  },
                  "reference_voices": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Voice preset names, not audio URLs."
                  },
                  "keyframes": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "image",
                        "timestamp_s"
                      ],
                      "properties": {
                        "image": {
                          "type": "string"
                        },
                        "timestamp_s": {
                          "type": "number",
                          "exclusiveMinimum": 0
                        }
                      }
                    }
                  },
                  "generate_audio": {
                    "type": "boolean",
                    "description": "Veo 3.1 and Veo 3.1 Fast only. Defaults to true."
                  },
                  "negative_prompt": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "seed": {
                    "type": "integer",
                    "minimum": -1,
                    "maximum": 4294967295,
                    "description": "Bounds vary by model."
                  },
                  "temperature": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 2
                  },
                  "top_p": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "prompt_extend": {
                    "type": "boolean",
                    "description": "Automatic prompt rewrite where supported."
                  },
                  "watermark": {
                    "type": "boolean",
                    "description": "Add a watermark where supported."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Video task ID"
          },
          "400": {
            "description": "Unsupported model or input combination"
          }
        }
      }
    },
    "/v1/audio/speech": {
      "post": {
        "summary": "Generate spoken audio from text (ElevenLabs v4 & Grok TTS)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "input"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "grok-tts"
                    ]
                  },
                  "input": {
                    "type": "string"
                  },
                  "voice": {
                    "type": "string",
                    "default": "alloy"
                  },
                  "response_format": {
                    "type": "string",
                    "default": "mp3"
                  },
                  "language": {
                    "type": "string",
                    "description": "Optional language hint for Grok TTS."
                  },
                  "speed": {
                    "type": "number",
                    "description": "Output speed multiplier. Grok TTS accepts 0.7 through 1.5."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audio binary stream"
          }
        }
      }
    },
    "/v1/audio/transcriptions": {
      "post": {
        "summary": "Transcribe audio files to text (ElevenLabs Scribe v3 & Grok STT)",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "file"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "grok-stt"
                    ]
                  },
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "language": {
                    "type": "string"
                  },
                  "response_format": {
                    "type": "string",
                    "enum": [
                      "json",
                      "text",
                      "verbose_json"
                    ]
                  },
                  "keyterm": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Grok STT: repeat the field for multiple terms."
                  },
                  "format": {
                    "type": "boolean",
                    "description": "Grok STT: format spoken numbers. Requires language."
                  },
                  "filler_words": {
                    "type": "boolean",
                    "description": "Grok STT: preserve filler words."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON transcript payload"
          }
        }
      }
    },
    "/v1/videos/{task_id}": {
      "get": {
        "summary": "Poll async video task status and output URL",
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Task status and result"
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "summary": "List models permitted for the authenticated API key",
        "responses": {
          "200": {
            "description": "Model list"
          }
        }
      }
    }
  }
}