{
  "schema_version": "2025-03-26",
  "name": "therouter",
  "description": "TheRouter.ai — unified LLM gateway. Route requests across OpenAI, Anthropic, Google, and other providers through a single OpenAI-compatible API.",
  "server": {
    "base_url": "https://api.therouter.ai",
    "authentication": {
      "type": "bearer",
      "header": "Authorization",
      "prefix": "Bearer",
      "env_var": "THEROUTER_API_KEY"
    }
  },
  "tools": [
    {
      "name": "chat_completion",
      "description": "Send an OpenAI-compatible chat completion request through TheRouter gateway. Supports model fallbacks, provider routing, streaming, tool calling, and structured outputs.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "description": "Model alias in provider/model format, e.g. 'openai/gpt-4o' or 'openai/gpt-4o-mini'. Required unless 'models' is provided."
          },
          "messages": {
            "type": "array",
            "description": "Conversation messages. Each requires 'role' (system|user|assistant|tool); 'content' is string or structured content parts.",
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string",
                  "enum": ["system", "user", "assistant", "tool"]
                },
                "content": {
                  "description": "String or array of content parts (text, image_url)."
                }
              },
              "required": ["role"]
            }
          },
          "temperature": {
            "type": "number",
            "description": "Sampling temperature. Range: 0–2. Lower = more deterministic.",
            "minimum": 0,
            "maximum": 2
          },
          "max_tokens": {
            "type": "integer",
            "description": "Maximum tokens to generate."
          },
          "stream": {
            "type": "boolean",
            "description": "Enable server-sent events streaming. Default: false.",
            "default": false
          },
          "top_p": {
            "type": "number",
            "description": "Nucleus sampling probability mass. Range: 0–1.",
            "minimum": 0,
            "maximum": 1
          },
          "tools": {
            "type": "array",
            "description": "Tool/function definitions for the model to call.",
            "items": {
              "type": "object",
              "properties": {
                "type": { "type": "string", "enum": ["function"] },
                "function": {
                  "type": "object",
                  "properties": {
                    "name": { "type": "string" },
                    "description": { "type": "string" },
                    "parameters": { "type": "object" }
                  },
                  "required": ["name", "parameters"]
                }
              },
              "required": ["type", "function"]
            }
          },
          "tool_choice": {
            "description": "Tool selection mode: 'auto', 'none', 'required', or {type:'function', function:{name:'...'}}."
          },
          "response_format": {
            "type": "object",
            "description": "Structured output constraints. Use {type:'json_object'} or {type:'json_schema', json_schema:{...}}."
          },
          "models": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Fallback model chain. Gateway tries models in order. TheRouter extension."
          },
          "provider": {
            "type": "object",
            "description": "Provider routing preferences. TheRouter extension.",
            "properties": {
              "allow_fallbacks": { "type": "boolean" },
              "order": { "type": "array", "items": { "type": "string" } },
              "only": { "type": "array", "items": { "type": "string" } },
              "ignore": { "type": "array", "items": { "type": "string" } }
            }
          },
          "route": {
            "type": "string",
            "enum": ["fallback", "sort"],
            "description": "Routing strategy. TheRouter extension."
          },
          "stop": {
            "description": "Stop sequence(s). String or array of strings."
          },
          "frequency_penalty": {
            "type": "number",
            "description": "Frequency penalty. Range: -2 to 2."
          },
          "presence_penalty": {
            "type": "number",
            "description": "Presence penalty. Range: -2 to 2."
          },
          "seed": {
            "type": "integer",
            "description": "Deterministic sampling seed."
          },
          "user": {
            "type": "string",
            "description": "End-user identifier for analytics."
          }
        },
        "required": ["messages"]
      }
    },
    {
      "name": "list_models",
      "description": "List all available models on TheRouter gateway with pricing, context length, and capability metadata.",
      "inputSchema": {
        "type": "object",
        "properties": {},
        "required": []
      }
    },
    {
      "name": "get_credits",
      "description": "Check current credit balance and total usage. Requires a management API key (sk-mgmt-... prefix).",
      "inputSchema": {
        "type": "object",
        "properties": {},
        "required": []
      }
    }
  ]
}
