PrivateGPT Documentation

repository·main·Indexed 32 days ago

https://github.com/zylon-ai/private-gpt

An open-source API layer providing ingestion, retrieval, tools, and orchestration to turn local, OpenAI-compatible LLM inference servers into production-ready AI applications. Supports async ingestion, embeddings, and agentic RAG.

Tokens
32.8K
Snippets
89
Records
146
Agent score
99%

What's inside private-gpt

  1. Overview of PrivateGPT Integrations

    main

    PrivateGPT implements the full Claude API, making it compatible with Claude-native tools and any client that requires a Claude-compatible interface.

    Claude-Native Integrations

    PrivateGPT can power first-party Anthropic applications that typically require specific API capabilities (like structured output, tool use, and tokenizer endpoints) which standard local inference providers (e.g., Ollama) often lack. Documented integrations include:

    • Claude Code: Anthropic's official CLI. You can route requests through your PrivateGPT server instead of api.anthropic.com.
    • Claude Desktop: Connect Claude Desktop to your PrivateGPT server using third-party inference.
    • Claude for Microsoft 365: Connect Claude add-ins for Word, Excel, PowerPoint, and Outlook to your PrivateGPT server.
    • OpenCode: An open-source AI coding agent that can be pointed at a PrivateGPT server via configuration.

    Other Compatible Tools

    Because PrivateGPT exposes a standard Claude-compatible interface, it is also compatible with tools designed for local OpenAI-compatible providers, such as:

    • OpenClaw
    • Hermes Agent
    • n8n
    • VS Code
    • Cline
  2. Overview of vLLM capabilities

    main

    vLLM is a high-throughput inference engine optimized for low latency. It is the only supported provider in PrivateGPT that exposes a structured output (JSON schema) endpoint, making it ideal for production applications requiring reliable schema-constrained responses.

    Capabilities

    • Model discovery (/v1/models): ✅
    • Tokenizer endpoint (/tokenize): ✅
    • Embeddings: ✅
    • Tool / function calling: ✅ (model-dependent)
    • Structured output (JSON schema): ✅
    • Streaming: ✅
    • Vision / image input: ✅ (model-dependent)
    • Audio input: ❌

    Note: vLLM requires an NVIDIA GPU with CUDA support. It is not designed for CPU-only inference.

  3. Overview of PrivateGPT features and API

    main

    PrivateGPT is an open-source API layer designed to turn local models into production AI applications. It follows the Claude API model and provides the following capabilities:

    • Standard Messages API: Supports streaming, async processing, and token counting.
    • Knowledge & Ingestion: File and artifact ingestion, PDF/document ingestion, and retrieval with citations.
    • Tools: Built-in tools mirroring Claude (web search, web fetch, code execution), custom tools, and MCP (Model Context Protocol) connectors.
    • Data Access: Structured access to databases and CSV/tabular analysis.
    • Orchestration: Embeddings and agentic RAG support.

    Note: PrivateGPT is an API-first product. While it includes a built-in workbench UI at /ui for testing and demos, developers are intended to build their own applications on top of the API.

  4. Overview of PrivateGPT capabilities and architecture

    main

    PrivateGPT is an open-source, Claude API-compatible orchestration layer designed to turn local or self-hosted model servers into production-ready AI application backends. It does not run models itself; instead, it connects to an external OpenAI-compatible inference server (e.g., Ollama, vLLM, llama.cpp) via the OPENAI_API_BASE environment variable.

    Key Capabilities

    • Messaging: Standard messages API with streaming, batch/async processing, and token counting.
    • Knowledge & RAG: File/artifact ingestion (including PDFs), retrieval with citations, and embeddings.
    • Tool Use: Built-in tools (web search, extraction, database querying, CSV/tabular analysis), custom tools support, and MCP (Model Context Protocol) connectors.
    • Agentic Features: Code execution, skills, and extended reasoning support.

    Architecture Model

    Your app / agent / workflow / UI
                  |
            PrivateGPT API
                  |
        Self-hosted LLM Server
  5. Compare PrivateGPT with other AI tools

    main

    To choose the right tool for your stack, understand how PrivateGPT differs from inference providers and application interfaces:

    PrivateGPT vs. Inference Providers (Ollama, LM Studio, vLLM, llama.cpp)

    • Inference Providers answer how to run a model.
    • PrivateGPT answers how to build a useful AI application on top of that model.
    • Usage: Run your model with an inference server, then use PrivateGPT as the Claude-style backend for your application.

    PrivateGPT vs. AI Applications (Onyx, Open WebUI)

    • Onyx/Open WebUI are self-hosted, app-first experiences focused on chat and enterprise search.
    • PrivateGPT is an API-first layer designed for developers to build their own applications.

    PrivateGPT vs. Zylon

    • PrivateGPT is the open-source application API layer.
    • Zylon is a complete enterprise production platform that includes PrivateGPT plus integrated inference, Kubernetes deployment, API gateways, and enterprise connectors (SharePoint, LDAP, etc.).
  6. Explore the PrivateGPT REST API endpoints

    main

    PrivateGPT exposes a REST API that follows the Claude API model. By default, all endpoints are available at http://localhost:8080. The API is organized into several functional groups:

    • Messages: Handles chat, streaming, token counting, validation, and async messaging via POST /v1/messages and its variants.
    • Models: Use GET /v1/models to list and inspect available models.
    • Artifacts: Manage document lifecycle (ingest, list, retrieve, and delete) via /v1/artifacts/*.
    • Embeddings: Generate text embeddings using POST /v1/embeddings.
    • Tools: Access specialized capabilities like semantic search, web search, web fetch, database query, and tabular analysis via /v1/tools/*.
    • Primitives: Perform low-level chunk retrieval using POST /v1/primitives/search.
    • Skills: Create and manage reusable instruction sets via /v1/skills/*.
  7. Compare PrivateGPT LLM providers

    main

    Choose a provider based on your requirements for throughput, features, and local vs. cloud deployment:

    CapabilityOllamaLM StudioLlamaCPP ServervLLM
    Model discovery (/v1/models)
    Tokenizer endpoint (/tokenize)
    Embeddings endpoint
    Tool / function calling✅ †✅ †✅ †✅ †
    Structured output (JSON schema)
    Streaming
    Vision / image input✅ †✅ †✅ †✅ †
    Audio input⚙️ Limited

    † Model-dependent: The server must support the protocol and the loaded model must support the capability.

    Key Considerations

    • Structured Output: Only vLLM supports the structured output (JSON schema enforcement) endpoint. Other providers use prompt-based JSON extraction, which is less reliable for complex schemas.
    • Missing Tokenizer Endpoint: If your provider (like Ollama) does not expose a /tokenize endpoint, PrivateGPT uses a character-based estimate (4 chars = 1 token). This can lead to inaccurate context management. To mitigate this, explicitly set a conservative context_window in your model profile.
  8. OpenCode Compatibility with PrivateGPT

    main

    OpenCode is an open-source AI coding agent that supports PrivateGPT via the @ai-sdk/openai-compatible package.

    Supported Features

    • Chat & streaming: ✅
    • Tool use / function calling: ✅ (Model-dependent)
    • File tools (read, write, edit): ✅ (Managed by OpenCode)
    • MCP servers: ✅ (Configured in OpenCode)
    • Multi-session agents: ✅

    Unsupported Features

    • Images: ❌
  9. Understand the PrivateGPT startup flow

    main

    When PrivateGPT starts, it follows this sequence:

    1. Loads Configuration: It reads settings.yaml and any additional profiles specified via the PGPT_PROFILES environment variable.
    2. Model Discovery: It calls GET /v1/models on your configured LLM server to automatically register all available models.
    3. Applies Defaults: It applies smart defaults to each discovered model, including a 128k context window, tool use capabilities, and vision support.
    4. Starts API Server: The server begins listening on port 8080 (unless configured otherwise via the PORT environment variable).

    Note: For basic usage, no configuration file is required as auto-discovery handles model registration.

  10. Understand S3 Bucket Retention Semantics

    main

    PrivateGPT utilizes two distinct buckets with different retention requirements:

    1. Durable Bucket (durable_bucket_name): Used for skill bundles, versioned files, and application state. This is long-lived data; do not apply aggressive lifecycle expiration rules here.
    2. Temporary Bucket (temporary_bucket_name): Used for intermediate processing files and upload staging. This is short-lived data; it is safe to apply lifecycle expiry rules (e.g., deleting files after 7 days).
  11. Understand the PrivateGPT Workbench UI implementation

    main

    The PrivateGPT Workbench UI is a single-file runtime implementation located at ../index.html. It follows the Fern-generated OpenAPI schema found at ../../fern/openapi/openapi.json.

    Key UI architectural details:

    • Global Collection: The active document collection is managed in Settings via state.context.documents.defaultCollection and is used for all document and chat operations.
    • Onboarding: The first-run experience is controlled by state.onboarding. The overlay is displayed as long as state.onboarding.completed !== true.
    • Appearance: UI themes and visibility are driven by state.uiAppearance and applied via applyAppearance(). Theme generation is performed by sending a brief to the chat API (POST /v1/messages), which returns JSON to update the appearance fields.
    • Navigation: The UI uses hash-based navigation (syncHash() / restoreFromHash()) to manage views. Supported formats include #context/{tab}, #chat/{id}, #settings, and #apiDebugger.
  12. Understand the Code Execution workspace layout

    main

    The code execution environment uses canonical paths that are transparently mapped to the host filesystem. The LLM should only interact with these canonical paths:

    DirectoryCanonical pathWritablePurpose
    Workspace/home/agent/workspace/YesWorking directory for creating files
    Uploads/mnt/user-data/uploads/NoUser-uploaded files (read-only)
    Outputs/mnt/user-data/outputs/YesDeliverables for user download
    Skills/skills/YesLoaded skill bundles

    Warning: Attempting to write to /mnt/user-data/uploads/ or accessing paths outside this layout will be rejected.