The REST API is served by FastAPI at the same port as the web UI (default :5468).
All endpoints return JSON unless noted. Long-running operations return a job_id
and stream progress via Server-Sent Events (SSE).
Base URL: http://localhost:5468
Authentication is controlled by auth.enabled in config.yml. When enabled, pass a
bearer token:
Authorization: Bearer <your-token>
Set the token via auth.token in config.yml or the PERSPICACITE_AUTH_TOKEN
environment variable.
Returns server status.
{"status": "ok", "version": "2.0.0"}Run a RAG query. Supports streaming SSE or non-streaming JSON.
Request body:
{
"query": "your research question",
"kb_name": "my-kb", // or "auto" for routing, or omit for web search only
"kb_names": ["kb-1", "kb-2"], // multi-KB alternative to kb_name
"mode": "basic", // basic | advanced | profound | agentic | literature_survey | contradiction
"stream": true // true for SSE, false for blocking JSON
}Streaming response (stream: true): server-sent events. Event types include
thinking, kb_route (when auto-routing), chunk, answer, provenance, done.
Non-streaming response (stream: false):
{
"answer": "...",
"sources": [...],
"mode": "basic",
"latency_ms": 1234
}List all conversations with message counts.
Create a conversation.
{"title": "My research session"}Get a conversation with all messages.
Delete a conversation and its messages.
Delete all conversations.
Full-text search across conversation content (SQLite FTS5).
Add a message to a conversation (triggers RAG synthesis).
Get the retrieval trace for a specific answer.
Get all provenance records for a conversation.
Export a conversation. Format controlled by ?format= query parameter:
?format=markdown— Markdown document with inline citations?format=ro-crate— RO-Crate 1.1 zip bundle with full provenance
List all knowledge bases.
[{"name": "my-kb", "paper_count": 42, "embedding_model": "text-embedding-3-small", ...}]Create a knowledge base.
{"name": "my-kb", "description": "Diamond sensors papers"}Get KB metadata.
Permanently delete a KB (metadata + Chroma collection).
KB statistics: paper count, chunk count, year histogram, content-type breakdown, source-database breakdown.
Add papers to a KB from a list of paper objects.
Synchronous BibTeX import. Body: {"bibtex": "<bibtex string>"}.
Asynchronous BibTeX import. Returns {"job_id": "..."}. Poll progress via
GET /api/jobs/{job_id}/events.
Synchronous bulk DOI add. Body: {"dois": ["10.1234/...", ...]}.
Asynchronous bulk DOI add. Returns {"job_id": "..."}.
Export a KB. Format controlled by ?format= query parameter:
?format=obsidian-vault— Obsidian Markdown vault zip?format=bibtex— BibTeX file (with optional PDFs in a folder)
List or search chunks in a KB. Query parameters: ?query=TEXT&top_k=N.
Ingest local files (paths must be under local_docs.allowed_roots).
Ingest a directory tree from a local path.
Trigger capsule building for all papers in a KB (async). Returns {"job_id": "..."}.
Fetch external resources (GitHub, Zenodo) for a single paper.
List figure metadata for a paper (from its capsule).
Download a specific figure image.
Fetch discovery metadata and content-type availability for a DOI. Hits OpenAlex and Unpaywall without ingesting the paper.
Get the status of an async ingestion job.
{
"job_id": "...",
"status": "running", // pending | running | done | failed
"progress": {"papers_processed": 5, "papers_total": 20}
}SSE stream of job progress events. Each event is a JSON line. Emit until
{"type": "done"} or {"type": "failed"}.
Check Zotero integration status and connectivity.
Push papers to Zotero by DOI list.
{
"dois": ["10.1234/...", ...],
"attach_pdf": true,
"attach_supplementary": false
}Preview which KBs would be created from Zotero collections.
Build one KB per Zotero collection. Body: {"library_id": "..."} (optional override).
Returns {"job_id": "..."}.
Get the status of a literature survey session.
Select which paper clusters to include in the survey report.
Generate the survey report from selected clusters.
- reference/mcp-tools.md — MCP equivalents for most of these endpoints
- concepts/provenance.md — what the provenance endpoints return
- reference/config.md — server and auth configuration