Open WebUI Pipe: run Claude Code's agent loop inside chats via the Claude Agent SDK
Go to file
Thomas Friedel 05d53ade55 feat(sandbox): install document + DS tooling for vendored skills
The docx/pdf/pptx/xlsx skills' scripts assume a working set of Python
libraries (pypdf, pdfplumber, reportlab, openpyxl, lxml, defusedxml,
Pillow, markitdown) and native tools (soffice headless, pdftoppm). Without
them, first-turn invocations of those skills fail with ImportError — and
the egress allowlist's pypi.org entry can't save us because pip install
on every turn adds latency and exercises an attack surface we'd rather
not hit on the critical path.

Bakes everything into the image:
  - libreoffice-{core,writer,calc,impress}: drops the GUI/Java bloat of
    the meta package while keeping headless conversion for all three
    office formats. Adds ~500 MB vs ~800+ MB for the full meta.
  - poppler-utils + fonts-dejavu: pdftoppm binary, pdf2image backend,
    and baseline glyph set so rendered PDFs aren't empty boxes.
  - pip: pypdf pdfplumber pdf2image reportlab Pillow openpyxl
    python-docx python-pptx pandas numpy matplotlib lxml defusedxml
    markitdown[pptx]. Also covers the explicit DS ask (pandas/numpy/
    matplotlib) so ad-hoc analysis doesn't hit pip on first use.
  - npm -g docx: the JS library the docx skill prefers for generating
    richly formatted new documents.

Final image is ~4.6 GB (up from ~1 GB). LibreOffice is the dominant term.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 23:49:08 +02:00
anthropic-proxy feat(sandbox): route Anthropic traffic through credential-injecting proxy 2026-04-18 21:59:59 +02:00
sandbox feat(sandbox): install document + DS tooling for vendored skills 2026-04-18 23:49:08 +02:00
.gitignore Initial commit: Claude Code pipe for Open WebUI 2026-04-18 14:55:03 +02:00
README.md Disable fast path — always run full agent loop 2026-04-18 15:19:57 +02:00
claude_agent_pipe.py Disable fast path — always run full agent loop 2026-04-18 15:19:57 +02:00
claude_agent_pipe_sandboxed.py feat(sandbox): vendor Anthropic document + frontend skills into image 2026-04-18 23:44:20 +02:00
sync_pipe.py feat: sandboxed Claude Code pipe via open-terminal 2026-04-18 21:02:01 +02:00

README.md

OpenWebUI Claude Code Pipe

Run Claude Code's agent loop from inside Open WebUI chats, via the Claude Agent SDK.

This is an Open WebUI Pipe that exposes Claude Code as a selectable model. Each chat gets its own isolated workspace directory; agent turns within the same chat resume the same Claude Code session, so context (files, prior tool calls) carries forward.

Features

  • Full Claude Code agent loop — Read, Write, Edit, Bash, Glob, Grep, WebSearch, WebFetch (configurable allowlist)
  • Per-chat workspaces — each chat_id gets a sandboxed working directory that persists across turns
  • Dual auth — bring your own Anthropic API key (pay-per-token) or a Claude Pro/Max OAuth token (bills against your subscription)
  • Streaming UI — tool calls render inline with previews; generated images/PDFs/CSVs surface as artifacts in the chat
  • Configurable valves — model, permission mode, tool allowlist, max turns, workspace root

Requirements

  • Open WebUI (any recent version with the Pipes/Functions framework)
  • Python deps (auto-installed by Open WebUI from the file header):
    • claude-agent-sdk>=0.1.60
    • anthropic>=0.40.0
  • The claude CLI must be available on the host running Open WebUI's Python backend (the SDK shells out to it). Install via npm install -g @anthropic-ai/claude-code.

Installation

  1. In Open WebUI, go to Workspace → Functions → + (or Admin Panel → Functions).
  2. Paste the contents of claude_agent_pipe.py into the editor.
  3. Save and enable the function.
  4. Open the function's Valves and configure auth (one of):
    • ANTHROPIC_API_KEY — standard pay-per-token billing
    • CLAUDE_CODE_OAUTH_TOKEN — generate on a machine with a browser via claude setup-token; bills against your Pro/Max/Team subscription
  5. A new model named Claude Code will appear in the model picker.

Configuration (Valves)

Valve Default Description
ANTHROPIC_API_KEY (env) Anthropic API key. Falls back to the backend's env var.
CLAUDE_CODE_OAUTH_TOKEN (empty) Claude subscription OAuth token. Takes priority over the API key when set.
MODEL claude-haiku-4-5 Claude model ID (e.g. claude-haiku-4-5, claude-sonnet-4-6, claude-opus-4-7).
PERMISSION_MODE bypassPermissions default, acceptEdits, bypassPermissions, plan, or dontAsk.
ALLOWED_TOOLS Read,Write,Edit,Bash,Glob,Grep,WebSearch,WebFetch Comma-separated tools auto-approved without prompting.
WORKDIR_ROOT /tmp/claude-agent-pipe Root directory for per-chat workspaces.
MAX_TURNS 30 Max agent turns per user message. 0 disables the cap.

Auth notes

When both auth methods are present, the OAuth token wins and the API key is unset before invoking the SDK so it can't override.

Per Anthropic's terms: a Claude subscription is for personal use — don't re-offer subscription auth to other end users through a shared Open WebUI deployment. For multi-user setups, use API keys.

License

MIT