{
  "openapi": "3.1.0",
  "info": {
    "title": "Air Agent Flight Search API",
    "description": "Agent-to-agent flight arbitrage engine. Finds cheapest flights via split-ticketing, hidden-city routing, flex-date arbitrage, and refund prediction strategies.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://msbhlwrimkrbvxczlkhf.supabase.co/functions/v1"
    }
  ],
  "paths": {
    "/flight-agent": {
      "post": {
        "operationId": "searchFlights",
        "summary": "Search for the cheapest flights using AI-powered multi-strategy analysis",
        "description": "Accepts a natural language flight query and returns structured results. Streams Server-Sent Events for progress, then final results. Strategies: direct search, split-ticketing via hub cities, hidden-city ticketing, flex-date arbitrage, refund/cancel prediction.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["query"],
                "properties": {
                  "query": {
                    "type": "string",
                    "description": "Natural language flight search query, e.g. 'NYC to London cheapest in April, 2 passengers'",
                    "example": "Round trip San Francisco to Tokyo, flexible dates in March"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Server-Sent Events stream with progress steps and final flight results",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": ["step", "done", "error"]
                    },
                    "flights": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FlightResult"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "FlightResult": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "airline": { "type": "string" },
          "from": { "type": "string", "description": "IATA airport code" },
          "to": { "type": "string", "description": "IATA airport code" },
          "departTime": { "type": "string", "format": "date-time" },
          "arriveTime": { "type": "string", "format": "date-time" },
          "duration": { "type": "string" },
          "stops": { "type": "integer" },
          "price": { "type": "number" },
          "originalPrice": { "type": "number" },
          "savingsTip": { "type": "string" },
          "dealTag": { "type": "string" },
          "source": { "type": "string" },
          "strategy": {
            "type": "string",
            "enum": ["direct", "split-ticketing", "hidden-city", "flex-date"]
          },
          "refundable": { "type": "boolean" },
          "strategyDetail": { "type": "string" },
          "bookingUrl": { "type": "string", "format": "uri" }
        }
      }
    }
  }
}
