{
  "openapi": "3.0.3",
  "info": {
    "title": "INRI GPT AI Tools API",
    "version": "2.0.0",
    "description": "Public demos use Turnstile; purchased organization workflows use a private server-side API key. Customer dashboard endpoints require session authentication and CSRF protection."
  },
  "servers": [
    {
      "url": "https://inrigpt.com"
    }
  ],
  "paths": {
    "/api/analyze.php": {
      "post": {
        "summary": "Analyze sample text",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "workflow",
                  "input",
                  "turnstile_token"
                ],
                "properties": {
                  "workflow": {
                    "type": "string",
                    "enum": [
                      "proposals",
                      "knowledge",
                      "sales",
                      "content"
                    ]
                  },
                  "input": {
                    "type": "string",
                    "minLength": 30,
                    "maxLength": 4000
                  },
                  "turnstile_token": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "AI draft result"
          },
          "400": {
            "description": "Invalid input"
          },
          "403": {
            "description": "Verification failed"
          },
          "429": {
            "description": "Rate or daily limit reached"
          },
          "503": {
            "description": "AI unavailable"
          }
        }
      }
    },
    "/api/chat.php": {
      "post": {
        "summary": "Text workspace; Turnstile action chat or workspace",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "messages",
                  "turnstile_token"
                ],
                "properties": {
                  "turnstile_token": {
                    "type": "string",
                    "description": "Fresh same-origin Turnstile token with the matching action."
                  },
                  "tool": {
                    "type": "string",
                    "enum": [
                      "chat",
                      "write",
                      "code",
                      "translate",
                      "summarize",
                      "knowledge",
                      "study",
                      "brainstorm",
                      "plan",
                      "proposals",
                      "sales",
                      "content",
                      "seo",
                      "data"
                    ]
                  },
                  "context": {
                    "type": "string",
                    "description": "At most 16,000 UTF-8 bytes of untrusted source material."
                  },
                  "messages": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 11,
                    "description": "Alternating user/assistant messages, beginning and ending with user; 12,000 UTF-8 bytes total; final message at most 4,000 characters.",
                    "items": {
                      "type": "object",
                      "required": [
                        "role",
                        "content"
                      ],
                      "properties": {
                        "role": {
                          "type": "string",
                          "enum": [
                            "user",
                            "assistant"
                          ]
                        },
                        "content": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 8000
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated response"
          },
          "400": {
            "description": "Invalid input"
          },
          "403": {
            "description": "Origin or Turnstile verification failed"
          },
          "413": {
            "description": "Request too large"
          },
          "429": {
            "description": "Rate or shared daily quota reached"
          },
          "502": {
            "description": "Unusable model response"
          },
          "503": {
            "description": "Provider unavailable"
          }
        }
      }
    },
    "/api/image.php": {
      "post": {
        "summary": "Generate a JPEG; Turnstile action image",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt",
                  "style",
                  "turnstile_token"
                ],
                "properties": {
                  "turnstile_token": {
                    "type": "string",
                    "description": "Fresh same-origin Turnstile token with the matching action."
                  },
                  "prompt": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 1000
                  },
                  "style": {
                    "type": "string",
                    "enum": [
                      "natural",
                      "photo",
                      "illustration",
                      "watercolor",
                      "pixel"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated response"
          },
          "400": {
            "description": "Invalid input"
          },
          "403": {
            "description": "Origin or Turnstile verification failed"
          },
          "413": {
            "description": "Request too large"
          },
          "429": {
            "description": "Rate or shared daily quota reached"
          },
          "502": {
            "description": "Unusable model response"
          },
          "503": {
            "description": "Provider unavailable"
          }
        }
      }
    },
    "/api/media.php": {
      "post": {
        "summary": "Image understanding or 30-second audio transcription; Turnstile action workspace",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tool",
                  "turnstile_token"
                ],
                "properties": {
                  "turnstile_token": {
                    "type": "string",
                    "description": "Fresh same-origin Turnstile token with the matching action."
                  },
                  "tool": {
                    "type": "string",
                    "enum": [
                      "vision",
                      "transcribe"
                    ]
                  },
                  "image": {
                    "type": "string",
                    "description": "Base64 JPEG, at most 1,400,000 characters."
                  },
                  "prompt": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "audio": {
                    "type": "string",
                    "description": "Base64 mono 16 kHz PCM16 WAV, at most 30 seconds."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated response"
          },
          "400": {
            "description": "Invalid input"
          },
          "403": {
            "description": "Origin or Turnstile verification failed"
          },
          "413": {
            "description": "Request too large"
          },
          "429": {
            "description": "Rate or shared daily quota reached"
          },
          "502": {
            "description": "Unusable model response"
          },
          "503": {
            "description": "Provider unavailable"
          }
        }
      }
    },
    "/api/integration.php": {
      "post": {
        "summary": "Run a purchased AI workflow or obtain a hosted checkout link",
        "security": [
          {
            "organizationKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "tool",
                      "input"
                    ],
                    "properties": {
                      "tool": {
                        "type": "string",
                        "enum": [
                          "chat",
                          "proposals",
                          "knowledge",
                          "sales",
                          "content"
                        ]
                      },
                      "input": {
                        "type": "string",
                        "minLength": 30,
                        "maxLength": 4000
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "product"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "checkout"
                        ]
                      },
                      "product": {
                        "type": "string",
                        "enum": [
                          "organization",
                          "proposals",
                          "knowledge",
                          "sales",
                          "content",
                          "integration"
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "AI result or hosted checkout URL"
          },
          "401": {
            "description": "Invalid or revoked key"
          },
          "403": {
            "description": "Missing purchase entitlement"
          },
          "429": {
            "description": "Organization or shared model limit"
          },
          "503": {
            "description": "Provider unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "organizationKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Private purchase API key. Never embed in browser code."
      }
    }
  }
}