{
  "openapi": "3.1.0",
  "info": {
    "title": "ODEN Search API",
    "version": "1.0.0",
    "summary": "Web search and synthesis for LLMs and AI agents.",
    "description": "POST a natural-language query and receive a synthesized answer plus ranked, citation-backed source metadata as JSON. robots.txt and the EU TDM opt-out are honored at the source, so disallowed pages never appear in a citation. Full documentation: https://oden-api.com/docs",
    "termsOfService": "https://oden-api.com/terms",
    "contact": {
      "name": "ODEN support",
      "email": "support@oden-api.com",
      "url": "https://oden-api.com/contact"
    },
    "license": {
      "name": "Commercial",
      "url": "https://oden-api.com/terms"
    }
  },
  "servers": [
    {
      "url": "https://api.oden-api.com",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "ODEN documentation",
    "url": "https://oden-api.com/docs"
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/search": {
      "post": {
        "operationId": "search",
        "summary": "Search the web and return a cited answer",
        "description": "Runs a live web search, extracts and ranks passages semantically, and returns a synthesized answer with the sources it drew on. One call; no follow-up scrape needed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Plain query",
                  "value": {
                    "query": "What changed in the EU AI Act in 2026?"
                  }
                },
                "citationsOnly": {
                  "summary": "Citations without a synthesized answer",
                  "value": {
                    "query": "EU AI Act 2026 changes",
                    "answer": false,
                    "max_results": 5
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The answer and its citations.",
            "headers": {
              "X-Quota-Limit": {
                "description": "Calls included in the plan this period.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-Quota-Remaining": {
                "description": "Calls left in the monthly quota.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-Quota-Source": {
                "description": "Which pot the call was drawn from: monthly or topup.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "monthly",
                    "topup"
                  ]
                }
              },
              "X-Quota-Period": {
                "description": "The billing period the counters refer to (YYYY-MM).",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body or missing query. Rejected calls do not count against the quota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit hit, or the monthly quota is spent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "searchViaQuery",
        "summary": "Same search, as a GET with query parameters",
        "description": "Convenience form for shells and quick tests. Prefer POST in production.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The query."
          },
          {
            "name": "answer",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": true
            },
            "description": "Include a synthesized answer."
          },
          {
            "name": "depth",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "basic",
                "advanced"
              ],
              "default": "advanced"
            }
          },
          {
            "name": "max_results",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 8,
              "default": 8
            }
          },
          {
            "name": "snippets",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The answer and its citations.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          }
        }
      }
    },
    "/search/stream": {
      "post": {
        "operationId": "searchStream",
        "summary": "Same search, streamed as Server-Sent Events",
        "description": "Identical retrieval to POST /search, but the answer arrives token by token. Citations are sent FIRST, so sources can be rendered before the text finishes. Every event is a `data:` line holding one JSON object with a `type` field:\n\n- `citations` — `{ type, trace_id, citations[] }`, sent once, before any text.\n- `delta` — `{ type, text }`, sent repeatedly; concatenate `text` in order.\n- `answer_retracted` — `{ type, reason }`, sent when a grounding check rejected the finished answer (fabricated quote, unsupported figure, degenerate output). Discard everything you rendered from `delta` when this arrives.\n- `done` — `{ type, chars, retracted, answer? }`, sent last. `answer` holds the cleaned final text and is omitted when `retracted` is true.\n\nThe stream ends with the literal line `data: [DONE]`. Equivalent to POST /search with `\"stream\": true`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Streamed query",
                  "value": {
                    "query": "How do Durable Objects handle concurrency?"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "An SSE stream of citations, text deltas and a final done event.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit hit, or the monthly quota is spent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "health",
        "summary": "Service status",
        "description": "No authentication required. Use for uptime checks.",
        "security": [],
        "responses": {
          "200": {
            "description": "Service is up."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from https://oden-api.com/app, sent as \"Authorization: Bearer <key>\"."
      }
    },
    "schemas": {
      "SearchRequest": {
        "type": "object",
        "required": [
          "query"
        ],
        "additionalProperties": false,
        "properties": {
          "query": {
            "type": "string",
            "minLength": 1,
            "description": "The natural-language query."
          },
          "answer": {
            "type": "boolean",
            "default": true,
            "description": "Include a synthesized answer in results.answer. Send false for citations only."
          },
          "depth": {
            "type": "string",
            "enum": [
              "basic",
              "advanced"
            ],
            "default": "advanced",
            "description": "basic returns search snippets (~1.5 s). advanced runs full passage extraction."
          },
          "max_results": {
            "type": "integer",
            "minimum": 1,
            "maximum": 8,
            "default": 8,
            "description": "Cap the number of citations returned."
          },
          "include_snippets": {
            "type": "boolean",
            "default": false,
            "description": "Add one attributed sentence per citation."
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "description": "Stream the answer as Server-Sent Events instead of one JSON body. Same contract as POST /search/stream. `additionalProperties: false` above means a client that validates its own payloads needs this field declared."
          }
        }
      },
      "SearchResponse": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string"
          },
          "trace_id": {
            "type": "string",
            "description": "Include this when reporting a problem."
          },
          "execution_time_ms": {
            "type": "number"
          },
          "cached": {
            "type": "boolean",
            "description": "True when served from the one-hour answer cache."
          },
          "results": {
            "type": "object",
            "properties": {
              "answer": {
                "type": "string",
                "description": "Synthesized answer. Absent when the sources did not support one — ODEN drops an answer it cannot ground rather than guessing."
              },
              "citations": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Citation"
                }
              }
            }
          }
        }
      },
      "Citation": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "score": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "Relevance to the query."
          },
          "snippet": {
            "type": "string",
            "description": "Present only when include_snippets was set."
          },
          "license": {
            "type": "string",
            "description": "Source licence, e.g. CC BY-SA 4.0, when one applies."
          },
          "license_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "limit": {
            "type": "integer",
            "description": "Present on quota errors."
          },
          "used": {
            "type": "integer",
            "description": "Present on quota errors."
          }
        }
      }
    }
  }
}