Export Open WebUI chats to
.curt v1 single-file conversation
files. Three artifacts:
curt-openwebui-export— standalone TypeScript/Node CLI. Reads a chat export file or fetches from the Open WebUI REST API; writes one validated.curtper chat.functions/curt_export_function.py— an Open WebUI Filter Function (the official successor to pipelines; install steps infunctions/INSTALL.md) that writes/updates a.curtfile as each conversation happens.pipelines/curt_export_pipeline.py— legacy: open-webui/pipelines is deprecated. Pipelines is deprecated — use Functions (official Filter Function docs); this file is kept only for existing deployments.
All field names were verified against the open-webui main source (not guessed):
| Fact | Source file (open-webui/open-webui @ main) |
|---|---|
ChatResponse: id, user_id, title, chat: dict, created_at/updated_at (epoch seconds), share_id, archived, pinned, meta, variables, folder_id, summary, current_message_id |
backend/open_webui/models/chats.py |
GET /api/v1/chats/all streams NDJSON (one ChatResponse per line), batch size 100 |
backend/open_webui/routers/chats.py → generate_chat_export_ndjson |
chat.chat.history.messages is a Record<id, message> tree linked by parentId; the visible conversation is the parent chain ending at history.currentId |
src/lib/components/chat/Messages.svelte → buildMessages (same walk as createMessagesList in src/lib/utils/index.ts) |
Legacy chats keep a flat array at chat.chat.messages |
backend/open_webui/models/chats.py (dual-write path) |
A message with error === true is a legacy error stub — the error string is stored in content and the UI never renders that content |
src/lib/components/chat/Messages/ResponseMessage.svelte (hasResponseContent && message.error !== true) |
Message fields: id, parentId, childrenIds, role, content, timestamp (epoch seconds, Math.floor(Date.now()/1000)), model / model_id, done, error, files, sources, usage, annotations; newer rows may store content as a list of typed blocks |
src/lib/components/chat/Chat.svelte, src/lib/components/chat/Messages/ResponseMessage.svelte, backend/open_webui/models/chat_messages.py |
| Open WebUI | .curt | Notes |
|---|---|---|
id |
conversation.id |
verbatim |
title |
conversation.title |
fallback "" |
created_at / updated_at (s) |
createdAt / updatedAt (ms) |
×1000 |
current history branch or messages[] |
messages[] |
UI-visible branch only |
message.timestamp (s) |
message.timestamp (ms) |
×1000; falls back to chat updatedAt when missing |
message.model / model_id |
message.model |
assistant messages only |
chat.models |
conversation.model |
joined; provider = "Open WebUI" |
files, sources, usage, annotations, error |
same-named passthrough fields | .curt readers ignore unknowns and preserve them on round-trip |
block-array content |
content (text blocks joined) + openwebuiContent passthrough |
original structured payload kept verbatim |
error === true (legacy error stub) |
dropped | UI renders only an error bubble for these, never the content; counted as skippedHidden in the CLI summary. Error objects are kept with error passthrough |
folder_id, share_id, summary |
conversation passthrough fields | |
roles outside user/assistant/system/tool |
dropped | counted in the export summary |
- Message-tree branches: Open WebUI stores regenerate/variant siblings;
only the currently displayed branch is exported. The count of dropped
sibling messages is recorded as
openwebuiSkippedBranches(conversation passthrough) and in the CLI summary. - Files/images: attachment metadata survives as passthrough
files, but .curt v1 has no inline-binary story beyond data URIs insidecontent. - Chat UI state: pinned/archived/tags/folder membership beyond
folder_idis not exported.
Both artifacts verified against a real Open WebUI instance (current main
image, API-key auth over HTTP):
- CLI fetched live chats via
/api/v1/chats/alland wrote parseCurt-valid.curtfiles — tree traversal, block-array content (joined + preserved asopenwebuiContent), and model fields all exercised on real API records. - Python pipeline serializer cross-checked 2/2 valid on the same records.
Known parity gap (pre-PR): the pipeline maps the turn body message list and does not traverseClosed — the pipeline now walkschat.historyparent-linked trees.chat.history.messagesfromhistory.currentIdwith the exact same rule as the CLI (convert_chatmirrorsconvertChat), andtest/parity.test.tsdeep-compares both implementations on shared fixtures so they cannot drift (seescripts/parity-check.md).- Deploy gotcha: API keys require env
ENABLE_API_KEYS(plural). The value is persisted to the DB at first boot — setting the env on an existing instance is not enough; flip it in Admin Settings or start with a fresh data volume.
npm i
npm run build
# from a UI export file (Settings > Chats > Export) — NDJSON or JSON array
node dist/src/cli.js chat-export.ndjson -o ./curt-out
# or straight from the API
OPENWEBUI_BASE_URL=https://openwebui.example \
OPENWEBUI_API_KEY=sk-... \
node dist/src/cli.js -o ./curt-outEvery file is validated with the reference parseCurt before it is written;
an invalid conversation is reported and skipped, never half-written. Output
names follow the Curtis bulk convention (YYYY-MM-DD slug suffix.curt, via
curtFilename).
Import functions/curt_export_function.py via Admin Panel > Functions
(full steps in functions/INSTALL.md). Valves:
EXPORT_DIR, EXPORT_ON_OUTLET. No pip packages required — the Function is
stdlib-only; it reads chat_id from the outlet body (Functions receive it
natively) and synthesizes title/id/models when the body carries no chat
payload. The user parameter uses the official __user__ dunder convention
(verified against upstream backend/open_webui/utils/filter.py). An export
failure never breaks the chat turn. Its output round-trips through the
reference parseCurt.
On outlet, the Function shapes the body as a ChatResponse record and maps it
with the exact same rules as the CLI (visible history branch, block-array
content, hidden error stubs, variant counting) — see
scripts/parity-check.md. The Function module mirrors the pipeline mapping
line-for-line (Functions are installed as a standalone single file, so it
cannot import the pipeline module); functions/tests/test_parity.py pins the
two together.
Copy pipelines/curt_export_pipeline.py into your pipelines filters/
directory (requirements: requests, which is only used for the optional
title/created_at enrichment call — the filter degrades gracefully without
it). Valves: OPENWEBUI_BASE_URL, OPENWEBUI_API_KEY, OUTPUT_DIR,
EXPORT_ON_OUTLET.
npm test # vitest (32) + pytest (47)
python -m pytest functions/tests pipelines/tests -q # Python suites aloneThe pytest leg skips cleanly with a message when Python 3.10+ is absent.
MIT