{
  "openapi": "3.1.0",
  "info": {
    "title": "DEEF.AI Detection API",
    "version": "1.0.0",
    "description": "Detect AI-generated and manipulated images. Authenticate with a DEEF.AI license key (Bearer). Each deep scan consumes one credit.",
    "contact": { "email": "hello@deef.ai", "url": "https://deef.ai/" }
  },
  "servers": [{ "url": "https://api.deef.ai" }],
  "paths": {
    "/v1/health": {
      "get": {
        "summary": "Health check",
        "operationId": "health",
        "security": [],
        "responses": { "200": { "description": "Service is healthy" } }
      }
    },
    "/v1/detect": {
      "post": {
        "summary": "Detect whether an image is AI-generated",
        "operationId": "detect",
        "description": "Send raw image bytes as the request body. Consumes one credit on success.",
        "security": [{ "licenseKey": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "image/jpeg": { "schema": { "type": "string", "format": "binary" } },
            "image/png": { "schema": { "type": "string", "format": "binary" } },
            "image/webp": { "schema": { "type": "string", "format": "binary" } }
          }
        },
        "responses": {
          "200": {
            "description": "Verdict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "risk": { "type": "number", "description": "AI-generated probability, 0–1" },
                    "verdict": { "type": "string", "enum": ["ai_generated", "likely_authentic"] },
                    "remaining": { "type": "integer", "description": "Credits left after this scan" },
                    "model": { "type": "string" }
                  }
                }
              }
            }
          },
          "401": { "description": "Missing license key" },
          "402": { "description": "No credits remaining" },
          "403": { "description": "Invalid license key" }
        }
      }
    },
    "/v1/license/verify": {
      "get": {
        "summary": "Verify a license key and return remaining credits",
        "operationId": "verifyLicense",
        "security": [],
        "parameters": [
          { "name": "key", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "License status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": { "type": "boolean" },
                    "remaining": { "type": "integer" },
                    "granted": { "type": "integer" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "licenseKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "DEEF.AI license key, format DEEF-XXXX-XXXX-XXXX, sent as `Authorization: Bearer <key>`."
      }
    }
  }
}
