{
  "openapi": "3.1.0",
  "info": {
    "title": "RainDragon AI API",
    "version": "1.0.0",
    "description": "Public endpoints of the RainDragon AI inference API: OpenAI-compatible (base URL https://inference.raindragon.ai/v1) and Anthropic-compatible (base URL https://inference.raindragon.ai). Human-readable docs: https://inference.raindragon.ai/api-documentation (Markdown: https://inference.raindragon.ai/api-documentation.md, index: https://inference.raindragon.ai/llms.txt). Errors carry message, type and code under error (or under detail with a request_id for validation and auth errors); refused requests are not billed.",
    "contact": {
      "email": "engineering@raindragon.ai",
      "url": "https://inference.raindragon.ai/contact"
    }
  },
  "externalDocs": {
    "description": "API documentation",
    "url": "https://inference.raindragon.ai/api-documentation"
  },
  "servers": [
    {
      "url": "https://inference.raindragon.ai"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Inference"
    },
    {
      "name": "Models"
    },
    {
      "name": "Audio"
    },
    {
      "name": "Batch"
    },
    {
      "name": "Management",
      "description": "Requires a management key (rdm_...), not an inference key. Docs: https://inference.raindragon.ai/management-api"
    }
  ],
  "paths": {
    "/v1/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "tags": [
          "Inference"
        ],
        "summary": "Chat completion (OpenAI-compatible)",
        "description": "OpenAI-compatible chat completions. Streaming with \"stream\": true (Server-Sent Events). Unknown fields are ignored; prompt_logprobs, priority, chat_template, logits_processors and kv_transfer_params are refused with HTTP 400 unsupported_parameter. best_of is not supported. Docs: https://inference.raindragon.ai/api-documentation.md",
        "parameters": [
          {
            "name": "X-Fill-Or-Kill",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Fill-or-kill: start within the TTL or be refused without charge. See /api-documentation#fill-or-kill."
          },
          {
            "name": "X-Fok-Ttl-Ms",
            "in": "header",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 50,
              "maximum": 120000,
              "default": 2000
            }
          },
          {
            "name": "X-Fok-Bid-Usd",
            "in": "header",
            "required": false,
            "schema": {
              "type": "number"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages"
                ],
                "additionalProperties": true,
                "properties": {
                  "model": {
                    "type": "string",
                    "examples": [
                      "google/gemma-4-26B-A4B-it"
                    ]
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ChatMessage"
                    }
                  },
                  "max_tokens": {
                    "type": "integer"
                  },
                  "max_completion_tokens": {
                    "type": "integer"
                  },
                  "temperature": {
                    "type": "number"
                  },
                  "top_p": {
                    "type": "number"
                  },
                  "frequency_penalty": {
                    "type": "number"
                  },
                  "presence_penalty": {
                    "type": "number"
                  },
                  "stop": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "seed": {
                    "type": "integer"
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "stream_options": {
                    "type": "object",
                    "properties": {
                      "include_usage": {
                        "type": "boolean"
                      }
                    }
                  },
                  "n": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 16,
                    "description": "Independent choices; the prompt is billed once. Current limit: billing.max_n in GET /api/models."
                  },
                  "logprobs": {
                    "type": "boolean"
                  },
                  "top_logprobs": {
                    "type": "integer",
                    "maximum": 20
                  },
                  "logit_bias": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "response_format": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "text",
                          "json_object"
                        ]
                      }
                    }
                  },
                  "tools": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  },
                  "tool_choice": {},
                  "parallel_tool_calls": {
                    "type": "boolean"
                  },
                  "user": {
                    "type": "string",
                    "description": "Stable opaque id of your end user (helps keep cached prefixes together)."
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": true,
                    "properties": {
                      "session": {
                        "type": "string",
                        "description": "Stable opaque id of the conversation, for prompt caching. Never sent to the model."
                      }
                    }
                  },
                  "reasoning_effort": {
                    "type": "string",
                    "enum": [
                      "none",
                      "low",
                      "medium",
                      "high"
                    ],
                    "description": "Any value except none turns thinking on (off by default)."
                  },
                  "reasoning": {
                    "type": "object",
                    "properties": {
                      "enabled": {
                        "type": "boolean"
                      },
                      "exclude": {
                        "type": "boolean"
                      }
                    }
                  },
                  "chat_template_kwargs": {
                    "type": "object",
                    "properties": {
                      "enable_thinking": {
                        "type": "boolean"
                      }
                    }
                  },
                  "service_tier": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "default",
                      "flex"
                    ],
                    "description": "flex: spare capacity at the flex multiplier (currently 0.5x); may wait up to ~90 s; 429 resource_unavailable if none opens up."
                  },
                  "top_k": {
                    "type": "integer"
                  },
                  "min_p": {
                    "type": "number"
                  },
                  "repetition_penalty": {
                    "type": "number"
                  },
                  "min_tokens": {
                    "type": "integer"
                  },
                  "stop_token_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion, or an SSE stream of chat.completion.chunk objects when stream is true",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletion"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/responses": {
      "post": {
        "operationId": "createResponse",
        "tags": [
          "Inference"
        ],
        "summary": "OpenAI Responses API",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "input"
                ],
                "additionalProperties": true,
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "input": {},
                  "instructions": {
                    "type": "string"
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "tools": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  },
                  "max_output_tokens": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response object, or an SSE stream when stream is true",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "operationId": "createMessage",
        "tags": [
          "Inference"
        ],
        "summary": "Anthropic Messages API",
        "description": "Anthropic-compatible. Use base URL https://inference.raindragon.ai with the same RainDragon API key (Authorization: Bearer or x-api-key).",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "anthropicApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages",
                  "max_tokens"
                ],
                "additionalProperties": true,
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  },
                  "system": {},
                  "max_tokens": {
                    "type": "integer"
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "tools": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  },
                  "temperature": {
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Message object, or an SSE stream when stream is true",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "operationId": "listModels",
        "tags": [
          "Models"
        ],
        "summary": "List models with per-token prices and context_length",
        "security": [],
        "responses": {
          "200": {
            "description": "OpenAI-style model list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/v1/audio/transcriptions": {
      "post": {
        "operationId": "createTranscription",
        "tags": [
          "Audio"
        ],
        "summary": "Speech-to-text (Whisper)",
        "description": "Billed per second of audio. Supports mp3, mp4, wav, webm, flac and ogg.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "model": {
                    "type": "string",
                    "enum": [
                      "openai/whisper-large-v3",
                      "openai/whisper-large-v3-turbo",
                      "distil-whisper/distil-large-v3"
                    ],
                    "default": "openai/whisper-large-v3-turbo"
                  },
                  "language": {
                    "type": "string"
                  },
                  "response_format": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transcription",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "text": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/files": {
      "post": {
        "operationId": "uploadFile",
        "tags": [
          "Batch"
        ],
        "summary": "Upload a batch input file (JSONL)",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "purpose"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "purpose": {
                    "type": "string",
                    "enum": [
                      "batch"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "File object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/File"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/files/{file_id}": {
      "get": {
        "operationId": "retrieveFile",
        "tags": [
          "Batch"
        ],
        "summary": "Retrieve a file object",
        "parameters": [
          {
            "name": "file_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "File id"
          }
        ],
        "responses": {
          "200": {
            "description": "File object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/File"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/files/{file_id}/content": {
      "get": {
        "operationId": "downloadFileContent",
        "tags": [
          "Batch"
        ],
        "summary": "Download input, output or error JSONL",
        "parameters": [
          {
            "name": "file_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "File id"
          }
        ],
        "responses": {
          "200": {
            "description": "JSONL",
            "content": {
              "application/jsonl": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/batches": {
      "post": {
        "operationId": "createBatch",
        "tags": [
          "Batch"
        ],
        "summary": "Create a batch (15% off the per-token price)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input_file_id",
                  "endpoint"
                ],
                "properties": {
                  "input_file_id": {
                    "type": "string"
                  },
                  "endpoint": {
                    "type": "string",
                    "enum": [
                      "/v1/chat/completions"
                    ]
                  },
                  "completion_window": {
                    "type": "string",
                    "default": "24h"
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "operationId": "listBatches",
        "tags": [
          "Batch"
        ],
        "summary": "List your batches",
        "responses": {
          "200": {
            "description": "List of batch objects",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/batches/{batch_id}": {
      "get": {
        "operationId": "retrieveBatch",
        "tags": [
          "Batch"
        ],
        "summary": "Batch status, request_counts, output_file_id, error_file_id",
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Batch id"
          }
        ],
        "responses": {
          "200": {
            "description": "Batch object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/batches/{batch_id}/cancel": {
      "post": {
        "operationId": "cancelBatch",
        "tags": [
          "Batch"
        ],
        "summary": "Cancel a batch; requests not yet started are not billed",
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Batch id"
          }
        ],
        "responses": {
          "200": {
            "description": "Batch object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Batch"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/messages/batches": {
      "post": {
        "operationId": "createMessageBatch",
        "tags": [
          "Batch"
        ],
        "summary": "Create an Anthropic Message Batch (same discount as /v1/batches)",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "anthropicApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "requests"
                ],
                "properties": {
                  "requests": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "custom_id": {
                          "type": "string"
                        },
                        "params": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Message batch",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "operationId": "listMessageBatches",
        "tags": [
          "Batch"
        ],
        "summary": "List Anthropic Message Batches",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "anthropicApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/messages/batches/{batch_id}": {
      "get": {
        "operationId": "retrieveMessageBatch",
        "tags": [
          "Batch"
        ],
        "summary": "Retrieve an Anthropic Message Batch",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "anthropicApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Batch id"
          }
        ],
        "responses": {
          "200": {
            "description": "Message batch",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/messages/batches/{batch_id}/cancel": {
      "post": {
        "operationId": "cancelMessageBatch",
        "tags": [
          "Batch"
        ],
        "summary": "Cancel an Anthropic Message Batch",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "anthropicApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Batch id"
          }
        ],
        "responses": {
          "200": {
            "description": "Message batch",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/messages/batches/{batch_id}/results": {
      "get": {
        "operationId": "getMessageBatchResults",
        "tags": [
          "Batch"
        ],
        "summary": "Download Anthropic Message Batch results (JSONL)",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "anthropicApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Batch id"
          }
        ],
        "responses": {
          "200": {
            "description": "JSONL",
            "content": {
              "application/jsonl": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/management/fallbacks": {
      "get": {
        "operationId": "listFallbacks",
        "summary": "List your fallbacks (keys masked) and the served model ids",
        "security": [
          {
            "managementKey": [
              "fallbacks:read"
            ]
          }
        ],
        "tags": [
          "Management"
        ],
        "responses": {
          "200": {
            "description": "Fallbacks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/management/fallbacks/{model_id}": {
      "get": {
        "operationId": "getFallback",
        "summary": "Get one fallback",
        "security": [
          {
            "managementKey": [
              "fallbacks:read"
            ]
          }
        ],
        "tags": [
          "Management"
        ],
        "parameters": [
          {
            "name": "model_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Served model id, e.g. google/gemma-4-26B-A4B-it (may contain slashes)"
          }
        ],
        "responses": {
          "200": {
            "description": "Fallback",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "description": "Fallback provider config; see https://inference.raindragon.ai/management-api.md"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "put": {
        "operationId": "putFallback",
        "summary": "Create or replace one fallback (idempotent)",
        "security": [
          {
            "managementKey": [
              "fallbacks:write"
            ]
          }
        ],
        "tags": [
          "Management"
        ],
        "parameters": [
          {
            "name": "model_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Served model id, e.g. google/gemma-4-26B-A4B-it (may contain slashes)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true,
                "description": "Fallback provider config; see https://inference.raindragon.ai/management-api.md"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Fallback",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "description": "Fallback provider config; see https://inference.raindragon.ai/management-api.md"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "delete": {
        "operationId": "deleteFallback",
        "summary": "Remove one fallback",
        "security": [
          {
            "managementKey": [
              "fallbacks:write"
            ]
          }
        ],
        "tags": [
          "Management"
        ],
        "parameters": [
          {
            "name": "model_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Served model id, e.g. google/gemma-4-26B-A4B-it (may contain slashes)"
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/management/fallbacks/bulk": {
      "post": {
        "operationId": "bulkSetFallbacks",
        "summary": "Set the same fallback for many models at once (idempotent, atomic)",
        "security": [
          {
            "managementKey": [
              "fallbacks:write"
            ]
          }
        ],
        "tags": [
          "Management"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/management/fallbacks/test": {
      "post": {
        "operationId": "testFallback",
        "summary": "Dry-run one 1-token request to the provider; returns ok/error",
        "security": [
          {
            "managementKey": [
              "fallbacks:write"
            ]
          }
        ],
        "tags": [
          "Management"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/management/usage/metrics": {
      "get": {
        "operationId": "getUsageMetrics",
        "summary": "Requests, tokens, spend, cache-hit rate, TTFT percentiles, tok/s, error rate, failover share and fill-or-kill outcomes",
        "security": [
          {
            "managementKey": [
              "usage:read"
            ]
          }
        ],
        "tags": [
          "Management"
        ],
        "parameters": [
          {
            "name": "window",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1h",
                "24h",
                "7d",
                "30d"
              ],
              "default": "24h"
            }
          },
          {
            "name": "model",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Metrics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/management/status": {
      "get": {
        "operationId": "getStatus",
        "summary": "Engine status (healthy / degraded / failing_over) and incidents from the past week",
        "security": [
          {
            "managementKey": [
              "usage:read"
            ]
          }
        ],
        "tags": [
          "Management"
        ],
        "responses": {
          "200": {
            "description": "Status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "RainDragon API key: Authorization: Bearer <key>"
      },
      "anthropicApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Same RainDragon API key, Anthropic-client style"
      },
      "managementKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Management key (rdm_...) with scopes fallbacks:read, fallbacks:write, usage:read"
      }
    },
    "schemas": {
      "ChatMessage": {
        "type": "object",
        "required": [
          "role"
        ],
        "additionalProperties": true,
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "developer",
              "user",
              "assistant",
              "tool"
            ]
          },
          "content": {},
          "tool_calls": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "tool_call_id": {
            "type": "string"
          }
        }
      },
      "ChatCompletion": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "chat.completion"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "service_tier": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "message": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string"
                    },
                    "content": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning": {
                      "type": "string",
                      "description": "Thinking text when reasoning is on; also mirrored as reasoning_content"
                    },
                    "tool_calls": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  }
                },
                "finish_reason": {
                  "type": "string"
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "prompt_tokens": {
            "type": "integer"
          },
          "completion_tokens": {
            "type": "integer",
            "description": "Includes reasoning tokens; summed over all choices when n > 1"
          },
          "total_tokens": {
            "type": "integer"
          },
          "prompt_tokens_details": {
            "type": "object",
            "properties": {
              "cached_tokens": {
                "type": "integer",
                "description": "Prompt tokens billed at the cached-input rate"
              }
            }
          }
        }
      },
      "File": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string"
          },
          "bytes": {
            "type": "integer"
          },
          "purpose": {
            "type": "string"
          },
          "created_at": {
            "type": "integer"
          },
          "filename": {
            "type": "string"
          }
        }
      },
      "Batch": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          },
          "input_file_id": {
            "type": "string"
          },
          "output_file_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "error_file_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "completion_window": {
            "type": "string"
          },
          "request_counts": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "completed": {
                "type": "integer"
              },
              "failed": {
                "type": "integer"
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "code": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "param": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "detail": {},
          "request_id": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error (400 unsupported_parameter, 401 bad key, 402 no payment method, 404 model_not_found, 429 server_overloaded / resource_unavailable with Retry-After, 503 server_busy with Retry-After)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
