{
  "openapi": "3.1.0",
  "info": {
    "title": "XNudes Fanfux API",
    "version": "1.0.0",
    "description": "API endpoints for Fanfux.app as an independent client sharing the XNudes database core."
  },
  "servers": [
    {
      "url": "https://xnudes.app",
      "description": "Production API host"
    }
  ],
  "security": [
    {
      "fanfuxApiKey": [],
      "firebaseBearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "fanfuxApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Fanfux-Api-Key"
      },
      "firebaseBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Firebase ID token"
      }
    },
    "schemas": {
      "PromptData": {
        "type": "object",
        "additionalProperties": true,
        "example": {
          "mood": "playful",
          "lighting": "soft studio",
          "outfit_style": "black dress"
        }
      },
      "GenerationRequest": {
        "type": "object",
        "required": ["model_id"],
        "properties": {
          "model_id": {
            "type": "string",
            "format": "uuid"
          },
          "prompt_data": {
            "$ref": "#/components/schemas/PromptData"
          },
          "is_hd": {
            "type": "boolean",
            "default": false
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/user/profile": {
      "get": {
        "summary": "Return unified profile and token balance",
        "responses": {
          "200": {
            "description": "Profile response"
          },
          "401": {
            "description": "Missing or invalid API key or bearer token"
          },
          "403": {
            "description": "Email is not verified"
          }
        }
      }
    },
    "/api/v1/generation/reveal": {
      "post": {
        "summary": "Reveal a model image, using static free reveal for first two reveals",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Static reveal or live generation response"
          }
        }
      }
    },
    "/api/v1/generation/customize": {
      "post": {
        "summary": "Customize an image and reuse cached results by action hash",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cached or live generation response"
          }
        }
      }
    },
    "/api/v1/gallery/photos": {
      "get": {
        "summary": "Return gallery photos ordered by decay score",
        "security": [
          {
            "fanfuxApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Gallery photos"
          }
        }
      }
    }
  }
}
