{
  "openapi": "3.1.0",
  "info": {
    "title": "LLM API Router",
    "version": "1.0.0",
    "description": "OpenAI-compatible gateway in front of multiple LLM backends. Authenticate with a router API key (rk_live_...) minted on the dashboard. An MCP server with equivalent tools is available at /mcp."
  },
  "servers": [
    {
      "url": "https://llm.nyolab.ai"
    }
  ],
  "components": {
    "securitySchemes": {
      "routerKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "rk_live"
      }
    },
    "schemas": {
      "ChatMessage": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "user",
              "assistant"
            ]
          },
          "content": {
            "type": "string"
          }
        }
      }
    }
  },
  "security": [
    {
      "routerKey": []
    }
  ],
  "paths": {
    "/api/public/v1/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List the model names this router serves",
        "responses": {
          "200": {
            "description": "OpenAI-style model list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "Create a chat completion (streaming supported)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "A model name served by this router.",
                    "examples": [
                      "qwen3-30b"
                    ]
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ChatMessage"
                    }
                  },
                  "stream": {
                    "type": "boolean",
                    "default": false
                  },
                  "temperature": {
                    "type": "number"
                  },
                  "max_tokens": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion, or an SSE stream when stream is true",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "403": {
            "description": "Account not approved for API access"
          },
          "404": {
            "description": "No enabled backend for the requested model"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpEndpoint",
        "summary": "Model Context Protocol endpoint (Streamable HTTP, OAuth 2.1). Tools: list_models, chat, usage_summary.",
        "security": [],
        "responses": {
          "200": {
            "description": "MCP JSON-RPC response"
          }
        }
      }
    }
  }
}