Skip to main content
The DeepTutor API is a FastAPI application that powers the frontend and exposes all AI capabilities as network services.

Base URL

http://localhost:8001
The port is configured in config/main.yaml under server.backend_port. Interactive API docs (Swagger UI) are available at:
http://localhost:8001/docs

Route structure

PrefixDescription
/api/v1/All versioned API routes
/api/outputs/Static files served from data/user/

Authentication

No authentication is required for self-hosted deployments. All endpoints are open by default. For production use, add your own authentication middleware before exposing the API publicly.

CORS

The server currently allows all origins:
allow_origins=["*"]
To restrict this in production, update src/api/main.py to specify your frontend origin.

Transport protocols

The API uses both HTTP and WebSocket:
  • REST (HTTP): Used for CRUD operations — knowledge base management, notebook management, co-writer operations, and session state retrieval.
  • WebSocket: Used for long-running AI tasks that stream progress and results — solving, research, question generation, idea generation, and guided learning.

WebSocket pattern

All WebSocket endpoints follow the same pattern:
1

Connect

Open a WebSocket connection to the endpoint URL.
2

Send initial message

Send a JSON object with the task parameters as the first message.
3

Receive streaming messages

The server streams typed JSON messages as the task progresses. Message types include task_id, status, log, agent_status, token_stats, progress, and result.
4

Receive final result

The server sends a type: "result" message with the completed output, then closes the connection.

WebSocket message types

typeWhen sentDescription
task_idAfter connectionUnique ID for this task run
sessionAfter connection (solve)Session ID for conversation history
statusAt start and key stagesHuman-readable status string
logDuring executionLog lines from the agent
agent_statusDuring executionPer-agent status updates
token_statsDuring and after executionLLM token usage and cost
progressDuring executionStructured progress object
resultOn completionFinal output
errorOn failureError message string
completeOn completion (some endpoints)Signals the stream is done

Static outputs

Generated artifacts (images, PDFs, Markdown files) are served at:
/api/outputs/{module}/{task_dir}/{filename}
Example:
/api/outputs/solve/solve_20250101_120000/artifacts/diagram.png
This maps to the physical path data/user/solve/solve_20250101_120000/artifacts/diagram.png on the server.

Endpoints

Solve

WebSocket AI problem solver with streaming agent logs and session history.

Research

WebSocket deep research pipeline with topic optimization.

Knowledge

REST endpoints for creating and managing knowledge bases and document uploads.

Question

WebSocket question generation from knowledge base content.

Notebook

REST endpoints for creating notebooks and saving learning records.

Co-writer

REST endpoints for AI-assisted text editing, annotation, and TTS narration.

Guide

REST and WebSocket endpoints for guided learning sessions.

IdeaGen

WebSocket research idea generation from notebook content.

Build docs developers (and LLMs) love