{
  "service": "GhostGPT API",
  "documentation": "https://api.ghostgpt.io/",
  "documentation_languages": ["ru", "en"],
  "base_url": "https://api.ghostgpt.io/v1",
  "web_ui": "https://ghostgpt.io/",
  "default_model": "ghostgpt",
  "model_policy": "Any model name in requests is rewritten to the currently loaded model. Use ghostgpt or omit — same result.",
  "compatible_with": "OpenAI Chat Completions API",
  "authentication": {
    "type": "bearer_or_session",
    "header": "Authorization: Bearer <api_key>",
    "web_ui": "POST https://ghostgpt.io/api/session/bootstrap sets HttpOnly cookie gg_sess (same-origin only)",
    "note": "api.ghostgpt.io requires a valid API key. ghostgpt.io /v1 accepts API key or session cookie after bootstrap."
  },
  "request_policy": {
    "system_message": "Client role:system messages are ignored. Server injects GhostGPT identity and safety rules.",
    "ignored_fields": [
      "grammar",
      "grammar_type",
      "grammar_lazy",
      "grammar_triggers",
      "json_schema",
      "response_format (json_schema/json_object)",
      "logit_bias",
      "logit_bias_map",
      "logits_bias",
      "bias_tokens"
    ],
    "max_tokens": { "min": 32, "max": 4096, "default_if_invalid": 4096 },
    "output_guards": [
      "System prompt exfiltration blocked in responses (including SSE stream)",
      "FX rates without web data block — use /api/web-research on ghostgpt.io or pass your own data in user messages"
    ],
    "ghostgpt_io_v1": "https://ghostgpt.io/v1 accepts the same Bearer key or gg_sess cookie after bootstrap (proxied to gateway)",
    "queue": "Inference is serialized (one GPU job at a time)"
  },
  "endpoints": {
    "models": "GET /v1/models",
    "chat_completions": "POST /v1/chat/completions",
    "completions": "POST /v1/completions",
    "health": "GET /health"
  },
  "auxiliary_api": {
    "description": "Share links, URL fetch, web research, PDF/audio on ghostgpt.io (not under api.ghostgpt.io/v1). Requires same auth as tools API.",
    "base_url": "https://ghostgpt.io",
    "endpoints": {
      "session_bootstrap": {
        "method": "POST",
        "path": "/api/session/bootstrap",
        "auth": "none",
        "note": "Sets gg_sess cookie for web UI"
      },
      "share_create": {
        "method": "POST",
        "path": "/api/share",
        "body": "JSON array of conversation blocks",
        "response": "{ \"id\": \"…\", \"url\": \"https://ghostgpt.io/share/…\" }",
        "max_body_bytes": 2000000
      },
      "share_get": {
        "method": "GET",
        "path": "/api/share/{id}",
        "auth": "public read",
        "response": "{ \"id\", \"created\", \"data\": <payload> }"
      },
      "fetch_url": {
        "method": "POST",
        "path": "/api/fetch-url",
        "body": "{ \"url\": \"https://…\" }"
      },
      "web_research": {
        "method": "POST",
        "path": "/api/web-research",
        "body": "{ \"query\": \"курс доллара\" }",
        "response": "{ \"query\", \"sources\": [{ \"source\", \"url\", \"title\", \"text\", \"favicon\" }] }",
        "note": "Auto-injected in web UI for FX/weather queries; API clients must call explicitly"
      },
      "pdf_extract": {
        "method": "POST",
        "path": "/api/pdf/extract",
        "body": "multipart file field",
        "note": "Server-side pdftotext; rate limited per IP"
      },
      "transcribe": {
        "method": "POST",
        "path": "/api/transcribe",
        "body": "multipart audio"
      }
    }
  },
  "stability": {
    "queue": "Single-GPU inference serialized server-side",
    "retry": "Gateway retries upstream during restarts",
    "aliases": ["ghostgpt", "default", "auto"]
  },
  "errors": {
    "401": "Missing or invalid API key / session",
    "429": "nginx rate limit (infer, pdf, share, …)",
    "503": "Model loading or upstream busy"
  }
}
