{
  "openapi": "3.0.3",
  "info": {
    "title": "AI Identifiers Detection API",
    "description": "Detect AI-generated images, video, audio, and text with 95.8% accuracy. Powered by Google SynthID and 12+ detection models including ensemble ML, forensic analysis, and real-time processing.",
    "version": "1.0.0",
    "contact": {
      "name": "AI Identifiers API Support",
      "url": "https://aiidentifiers.com/developers",
      "email": "api@aiidentifiers.com"
    },
    "license": {
      "name": "Commercial",
      "url": "https://aiidentifiers.com/terms"
    },
    "x-logo": {
      "url": "https://aiidentifiers.com/icon-512.svg"
    }
  },
  "servers": [
    {
      "url": "https://aiidentifiers.com/api",
      "description": "Production"
    }
  ],
  "security": [
    { "BearerAuth": [] }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Enterprise API key obtained from https://aiidentifiers.com/enterprise. Format: `aid_<key>`"
      }
    },
    "schemas": {
      "AnalysisResult": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "example": "res_abc123" },
          "isAIGenerated": { "type": "boolean", "example": true },
          "confidenceScore": { "type": "number", "format": "float", "minimum": 0, "maximum": 100, "example": 97.3 },
          "fileType": { "type": "string", "enum": ["image", "video", "audio", "text"], "example": "image" },
          "models": {
            "type": "object",
            "description": "Per-model confidence scores",
            "additionalProperties": { "type": "number" },
            "example": { "synthid": 98.1, "ensemble_ml": 96.5, "forensic": 97.8 }
          },
          "processingTimeMs": { "type": "integer", "example": 347 },
          "createdAt": { "type": "string", "format": "date-time" }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": { "type": "string" },
          "message": { "type": "string" }
        }
      }
    }
  },
  "paths": {
    "/upload": {
      "post": {
        "summary": "Analyze a file for AI-generated content",
        "description": "Upload a file (image, video, audio) or provide a URL. Returns a full AI detection analysis across all models within seconds.",
        "operationId": "analyzeFile",
        "tags": ["Detection"],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "File to analyze (image, video, audio). Max 50MB."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Analysis complete",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AnalysisResult" }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
          },
          "402": {
            "description": "Insufficient credits",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/analysis": {
      "get": {
        "summary": "List past analyses",
        "description": "Retrieve a paginated list of past detection results for the authenticated user.",
        "operationId": "listAnalyses",
        "tags": ["Detection"],
        "parameters": [
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 20, "maximum": 100 } },
          { "name": "offset", "in": "query", "schema": { "type": "integer", "default": 0 } }
        ],
        "responses": {
          "200": {
            "description": "List of analyses",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": { "type": "array", "items": { "$ref": "#/components/schemas/AnalysisResult" } },
                    "total": { "type": "integer" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/enterprise/key": {
      "get": {
        "summary": "Get your enterprise API key",
        "description": "Returns your enterprise API key. Generates one on first call.",
        "operationId": "getApiKey",
        "tags": ["Enterprise"],
        "responses": {
          "200": {
            "description": "API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "apiKey": { "type": "string", "example": "aid_a1b2c3d4e5f6" }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Rotate enterprise API key",
        "description": "Generates a new API key, invalidating the previous one.",
        "operationId": "rotateApiKey",
        "tags": ["Enterprise"],
        "responses": {
          "200": {
            "description": "New API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "apiKey": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/healthz": {
      "get": {
        "summary": "Health check",
        "description": "Returns service status. No authentication required.",
        "operationId": "healthCheck",
        "tags": ["Status"],
        "security": [],
        "responses": {
          "200": {
            "description": "Service healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "ok" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "tags": [
    { "name": "Detection", "description": "AI content detection endpoints" },
    { "name": "Enterprise", "description": "API key management for B2B integrations" },
    { "name": "Status", "description": "Service health and status" }
  ]
}
