{
  "openapi": "3.1.0",
  "info": {
    "title": "WanderSync AI Planning API",
    "version": "3.10.21",
    "description": "Public AI planning endpoint. Accepts an Anthropic-shape messages request and returns a matching response. Beta-code gated during the public beta. Used internally by the WanderSync web app for itinerary generation, proposal drafting, concierge chat, and travel research.",
    "contact": { "email": "hello@wandersync.life", "url": "https://www.wandersync.life/" },
    "license": { "name": "Terms", "url": "https://www.wandersync.life/#faq" }
  },
  "servers": [
    { "url": "https://www.wandersync.life",         "description": "Production (custom domain)" },
    { "url": "https://wandersync-travel.vercel.app","description": "Production (Vercel)" }
  ],
  "paths": {
    "/api/ai": {
      "post": {
        "summary": "AI messages — travel planning, research and proposal drafting",
        "operationId": "aiMessages",
        "security": [{ "BetaCode": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["messages"],
                "properties": {
                  "model":      { "type": "string", "description": "Target model alias (server may remap)" },
                  "max_tokens": { "type": "integer", "minimum": 1, "maximum": 4096, "default": 1024 },
                  "system":     { "type": "string", "description": "Optional system prompt" },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": ["role", "content"],
                      "properties": {
                        "role":    { "type": "string", "enum": ["user", "assistant"] },
                        "content": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "AI response (Anthropic-shape)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id":    { "type": "string" },
                    "type":  { "type": "string", "enum": ["message"] },
                    "role":  { "type": "string", "enum": ["assistant"] },
                    "content": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": { "type": "string", "enum": ["text"] },
                          "text": { "type": "string" }
                        }
                      }
                    },
                    "model":      { "type": "string" },
                    "stop_reason":{ "type": "string" }
                  }
                }
              }
            }
          },
          "401": { "description": "Missing or invalid beta code" },
          "429": { "description": "Daily beta-code quota exceeded" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BetaCode": { "type": "apiKey", "in": "header", "name": "X-Beta-Code" }
    }
  }
}
