{
    "openapi": "3.0.3",
    "info": {
        "title": "Redeyed API",
        "version": "v1",
        "description": "Redeyed's self-hosted AI, IP-reputation and verification API. Authenticate with an API key in the `X-Api-Key` header. All responses are wrapped in a `{ data, meta }` envelope (`{ error, meta }` on failure). Calls are metered: quota first, then credits."
    },
    "servers": [
        {
            "url": "https://redeyed.com/api"
        }
    ],
    "security": [
        {
            "ApiKeyAuth": []
        }
    ],
    "tags": [
        {
            "name": "Account"
        },
        {
            "name": "Sentinel"
        },
        {
            "name": "AI"
        }
    ],
    "paths": {
        "/v1/me": {
            "get": {
                "tags": [
                    "Account"
                ],
                "summary": "Account, plan & remaining quota",
                "description": "Scope: `account:read`. Free.",
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthenticated",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/ip/{ip}": {
            "get": {
                "tags": [
                    "Sentinel"
                ],
                "summary": "IP reputation score & signals",
                "description": "Scope: `sentinel:ip`. Omit `ip` to score the caller.",
                "parameters": [
                    {
                        "name": "ip",
                        "in": "path",
                        "required": false,
                        "schema": {
                            "type": "string"
                        },
                        "description": "IPv4/IPv6 to score"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthenticated",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Insufficient scope",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Quota exceeded",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/verify": {
            "post": {
                "tags": [
                    "Sentinel"
                ],
                "summary": "Verify a captcha / human token",
                "description": "Scope: `sentinel:verify`.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "site_key": {
                                        "type": "string"
                                    },
                                    "token": {
                                        "type": "string",
                                        "nullable": true
                                    },
                                    "secret": {
                                        "type": "string",
                                        "nullable": true
                                    }
                                },
                                "required": [
                                    "site_key"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthenticated",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validation failed",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/ai/chat": {
            "post": {
                "tags": [
                    "AI"
                ],
                "summary": "Chat completion",
                "description": "Scope: `ai:chat`. Send `prompt` or a `messages` array.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "prompt": {
                                        "type": "string"
                                    },
                                    "messages": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "role": {
                                                    "type": "string",
                                                    "enum": [
                                                        "user",
                                                        "assistant",
                                                        "system"
                                                    ]
                                                },
                                                "content": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    },
                                    "mode": {
                                        "type": "string",
                                        "enum": [
                                            "instant",
                                            "medium",
                                            "high"
                                        ],
                                        "nullable": true
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthenticated",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Insufficient scope",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validation failed",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Model unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/ai/paraphrase": {
            "post": {
                "tags": [
                    "AI"
                ],
                "summary": "Paraphrase / rewrite text",
                "description": "Scope: `ai:paraphrase`.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "text": {
                                        "type": "string"
                                    },
                                    "tone": {
                                        "type": "string",
                                        "enum": [
                                            "standard",
                                            "formal",
                                            "casual",
                                            "fluent",
                                            "creative",
                                            "concise"
                                        ],
                                        "nullable": true
                                    }
                                },
                                "required": [
                                    "text"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthenticated",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validation failed",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/ai/image": {
            "post": {
                "tags": [
                    "AI"
                ],
                "summary": "Generate an image",
                "description": "Scope: `ai:image`. Returns a hosted image URL.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "prompt": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "prompt"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthenticated",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Image engine unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "ApiKeyAuth": {
                "type": "apiKey",
                "in": "header",
                "name": "X-Api-Key"
            }
        },
        "schemas": {
            "Envelope": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object"
                    },
                    "meta": {
                        "type": "object",
                        "properties": {
                            "request_id": {
                                "type": "string"
                            },
                            "version": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "nullable": true
                            }
                        }
                    }
                }
            },
            "Error": {
                "type": "object",
                "properties": {
                    "error": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            }
                        }
                    },
                    "meta": {
                        "type": "object"
                    }
                }
            }
        }
    }
}