The Backend API System provides programmatic access to RAGFlow's functionality through RESTful HTTP endpoints and a Python SDK. It enables developers to manage datasets, documents, chat assistants, agents, and execute RAG workflows without using the web interface. The API follows REST conventions and includes OpenAI-compatible endpoints for seamless integration with existing LLM tooling.
The system is built on a hybrid architecture. The Python-side utilizes the Quart framework api/apps/__init__.py61 providing an asynchronous implementation of the Flask API for handling long-lived SSE connections and concurrent background tasks. Simultaneously, a high-performance Go-based server layer handles core internal services, search operations, and ingestion logic. The Go router in internal/router/router.go manages a wide array of handlers including AuthHandler, UserHandler, DatasetsHandler, AgentHandler, and ChatChannelHandler internal/router/router.go26-58
For information about the visual workflow system and canvas-based agent orchestration, see Agent and Workflow System. For details on the web frontend that consumes these APIs, see Frontend Application.
This page covers:
Detailed coverage of specific endpoint categories is provided in child pages:
@login_required decorator, and current_user proxy.The Backend API is structured to separate routing logic from business logic. RAGFlow employs a dual-server strategy where Go handles system-critical and high-throughput tasks, while Python manages complex RAG logic and LLM integrations. The Go server marks its responses with an X-API-Source: go header for debugging internal/router/router.go135
Title: Hybrid API Layer Architecture
Sources: internal/router/router.go25-58 internal/router/router.go135 api/apps/__init__.py61-65
Every API request follows a standardized processing pipeline to ensure security and consistency.
AUTH_JWT, AUTH_API, and AUTH_BETA types api/apps/__init__.py94-96validate_and_parse_json_request which employs Pydantic models for schema validation, ensuring correct Content-Type and JSON syntax api/utils/validation_utils.py36-112 Query arguments are validated via validate_and_parse_request_args api/utils/validation_utils.py115-162documentHandler or datasetsHandler internal/router/router.go30-31_safe_jsonify and custom encoders to handle model serialization api/utils/api_utils.py55-58 api/utils/api_utils.py96-118Sources: api/apps/__init__.py94-110 api/utils/validation_utils.py36-162 internal/router/router.go30-31 api/utils/api_utils.py55-118
RAGFlow uses a uniform response envelope. Success is indicated by HTTP 200 and a specific code in the JSON body. Error handling is standardized across both Go and Python layers.
| Code | Message | Description |
|---|---|---|
200 | (Success) | Request processed successfully. |
400 | Bad Request | Invalid request parameters docs/references/http_api_reference.md20 |
401 | Unauthorized | Invalid or missing authentication credentials docs/references/http_api_reference.md21 |
403 | Forbidden | Access denied to the specific resource docs/references/http_api_reference.md22 |
1001 | Invalid Chunk ID | The specified chunk identifier does not exist docs/references/http_api_reference.md25 |
1002 | Chunk Update Failed | Failure during the manual editing of a chunk docs/references/http_api_reference.md26 |
Sources: docs/references/http_api_reference.md14-26 api/utils/api_utils.py121-154
The ragflow-sdk provides an object-oriented interface that mirrors the REST API hierarchy, bridging Natural Language space to code entities.
Title: SDK to Backend Mapping
Key Features:
create_dataset allow defining the chunk_method (e.g., naive, qa, laws) and complex parser_config docs/references/python_api_reference.md124-208ragflow-api-key for authentication docs/references/python_api_reference.md10pip install ragflow-sdk docs/references/python_api_reference.md16Sources: docs/references/python_api_reference.md8-208 sdk/python/ragflow_sdk/ragflow.py1-50
RAGFlow implements a compatibility layer to allow standard LLM clients to interact with RAGFlow "Chats" and "Agents".
/api/v1/openai/{chat_id}/chat/completions docs/references/http_api_reference.md63extra_body for RAG-specific features like reference (to return citations) and metadata_condition for complex retrieval filtering docs/references/http_api_reference.md97-113/api/v1/file/upload to /api/v1/files) docs/references/http_api_reference.md30-53Sources: docs/references/http_api_reference.md30-113 docs/references/python_api_reference.md39-114
The API system includes comprehensive health and status monitoring endpoints.
/api/v1/system/healthz provides the operational status of the system docs/references/http_api_reference.md41 The Go router exposes this at the same path internal/router/router.go163internal/cli/ that interacts with these APIs for administrative tasks, including APIShowVersionCommand and ListConfigs internal/cli/user_command.go42-115ragflow_list_datasets and ragflow_list_chats to the RAGFlow MCP server docs/release_notes.md41chatChannelHandler internal/router/router.go37 and documented in release notes docs/release_notes.md62-65Sources: docs/references/http_api_reference.md41 internal/router/router.go163 internal/cli/user_command.go42-115 docs/release_notes.md41-65
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.