{
  "openapi": "3.1.0",
  "info": {
    "title": "ยกด่วน YokDuan AI API",
    "version": "1.0.0",
    "description": "Public AI-friendly API for ยกด่วน 24/7 tow/forklift/slide-car services across Thailand. Use for ChatGPT Actions, Perplexity Plugins, and custom AI agents.",
    "contact": { "name": "ยกด่วน", "url": "https://xn--12c2bp7a1a1r.com", "email": "contact@xn--12c2bp7a1a1r.com" }
  },
  "servers": [
    { "url": "https://vyymqxqpkycbogwxofld.supabase.co/functions/v1", "description": "Production AI endpoints" }
  ],
  "paths": {
    "/knowledge-api": {
      "get": {
        "operationId": "getKnowledge",
        "summary": "Full structured knowledge snapshot (services, FAQ, coverage, contact, JSON-LD)",
        "parameters": [
          { "name": "topic", "in": "query", "schema": { "type": "string" }, "description": "Filter by topic, e.g. 'tow-truck', 'forklift', 'slide-car', 'ev', 'pricing'" },
          { "name": "area", "in": "query", "schema": { "type": "string" }, "description": "Filter by Thai province (Thai script)" },
          { "name": "format", "in": "query", "schema": { "type": "string", "enum": ["json", "jsonld"] } }
        ],
        "responses": { "200": { "description": "Knowledge snapshot" } }
      }
    },
    "/ai-search": {
      "get": {
        "operationId": "search",
        "summary": "Structured AI answer with citations for a free-text query",
        "parameters": [
          { "name": "q", "in": "query", "required": true, "schema": { "type": "string" } },
          { "name": "lang", "in": "query", "schema": { "type": "string", "enum": ["th", "en", "auto"] } }
        ],
        "responses": { "200": { "description": "Answer + citations + CTA" } }
      }
    },
    "/chat": {
      "servers": [
        { "url": "https://xn--12c2bp7a1a1r.com/api/public", "description": "Site-hosted AI chat (streaming)" }
      ],
      "post": {

        "operationId": "chat",
        "summary": "Streaming chat (AI SDK UI message protocol). Multilingual.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["messages"],
                "properties": {
                  "messages": { "type": "array", "items": { "type": "object" } }
                }
              }
            }
          }
        },
        "responses": { "200": { "description": "Streamed UI messages" } }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpJsonRpc",
        "summary": "Model Context Protocol JSON-RPC 2.0 endpoint",
        "responses": { "200": { "description": "MCP JSON-RPC response" } }
      },
      "get": {
        "operationId": "mcpDiscovery",
        "summary": "MCP server discovery info",
        "responses": { "200": { "description": "Server info + tools list" } }
      }
    }
  }
}
