api.ts
Overview
The api.ts file serves as a centralized API endpoint configuration module within the application. It defines and exports a collection of RESTful API endpoint URLs, organized by functional domains such as user management, team operations, language model management, knowledge bases, document handling, chat, file management, system configuration, flows, agents, MCP servers, and search functionalities.
This file abstracts the API URL definitions, enabling consistent and maintainable usage of endpoints throughout the frontend or client-side codebase. It exports a default object containing string constants for fixed URLs and functions for dynamic URLs that require parameters (e.g., IDs or channel names).
Detailed Explanation
Constants
api_host: string
Base path prefix for most API endpoints, set to"/v1". Used as the root prefix for all internal API calls.ExternalApi: string
Base path prefix for external API endpoints, set to"/api". Used primarily to prefix external-facing API URLs that may interact with external services or APIs.
Default Export Object
The default export is a large plain object containing all API routes grouped logically by domain. Each key maps to either:
A string representing a fixed endpoint URL, or
A function returning a string URL when dynamic parameters are needed.
Domain Groups and Their Endpoints
User-related Endpoints
Key | Type | Description | Parameters | Example Usage |
|---|---|---|---|---|
string | User login endpoint | None | ||
string | User logout endpoint | None | ||
string | User registration endpoint | None | api.register → | |
string | User settings endpoint | None | ||
| string | Get user information | None | api.user_info → |
string | Get tenant information associated with user | None | ||
string | Set tenant information | None | ||
string | List login channels | None | ||
(channel: string) => string | Login via specific channel |
|
Team-related Endpoints
Key | Type | Description | Parameters | Example Usage |
|---|---|---|---|---|
(tenantId: string) => string | Add a user to a tenant | tenantId (string) | ||
(tenantId: string) => string | List users of a tenant | tenantId (string) | ||
| (tenantId: string, userId: string) => string | Remove a user from a tenant | api.deleteTenantUser("123", "456") → "/v1/tenant/123/user/456" | |
string | List all tenants | None | ||
(tenantId: string) => string | Approve or agree to tenant invitation | tenantId (string) |
LLM Model Endpoints
Key | Type | Description |
|---|---|---|
| string | List LLM factories |
string | List available LLM models | |
string | List LLM models owned by user | |
string | Set API key for LLM usage | |
string | Add a new LLM model | |
string | Delete an existing LLM model | |
string | Delete an LLM factory |
Plugin Endpoints
Key | Type | Description |
|---|---|---|
| string | List or manage LLM tools |
Knowledge Base Endpoints
Key | Type | Description | Parameters | Example Usage |
|---|---|---|---|---|
| string | List knowledge bases | None | api.kb_list → |
string | Create knowledge base | None | api.create_kb → | |
string | Update knowledge base | None | ||
string | Remove knowledge base | None | ||
string | Get knowledge base details | None | ||
(knowledgeId: string) => string | Get knowledge graph for KB | knowledgeId (string) | api.getKnowledgeGraph("kb123") → "/v1/kb/kb123/knowledge_graph" | |
string | Get KB metadata | None |
Tags Endpoints
Key | Type | Description | Parameters | Example Usage |
|---|---|---|---|---|
(knowledgeId: string) => string | List tags for KB | knowledgeId (string) | ||
| string | List tags across KBs | None | |
(knowledgeId: string) => string | Remove tags from KB | knowledgeId (string) | api.removeTag("kb123") → | |
(knowledgeId: string) => string | Rename tag in KB | knowledgeId (string) | api.renameTag("kb123") → |
Chunk Endpoints
Includes endpoints for managing data chunks related to knowledge bases.
Key | Type | Description |
|---|---|---|
string | List chunks | |
string | Create a chunk | |
string | Update a chunk | |
string | Get chunk details | |
string | Switch chunk active status | |
string | Remove chunk | |
string | Test chunk retrieval mechanism | |
| string | Chunk-related knowledge graph |
Document Endpoints
Comprehensive document management including listing, status changing, upload, parsing, and thumbnails.
Key | Type | Description |
|---|---|---|
string | List documents | |
| string | Change document status |
string | Remove document | |
string | Delete document | |
string | Rename document | |
string | Create document | |
string | Execute document process | |
| string | Change document parser |
string | Get document thumbnails | |
string | Get document file | |
string | Upload document | |
| string | Crawl web for documents |
string | Get document info | |
string | Upload and parse document | |
string | Parse document | |
string | Set document metadata | |
string | Get dataset filter |
Chat Endpoints
Endpoints to manage dialogs, conversations, messaging, and chat-related features.
Key | Type | Description |
|---|---|---|
string | Save dialog | |
string | Get dialog | |
string | Remove dialog | |
string | List dialogs | |
| string | Save conversation |
string | Get conversation | |
string | Get conversation via SSE (Server-Sent Events) | |
| string | List conversations |
string | Remove conversation | |
| string | Complete conversation |
string | Delete message | |
| string | Thumbs-up a message |
string | Text-to-speech functionality | |
string | Ask a question | |
string | Generate mindmap | |
string | Get related questions |
Chat for External API
Key | Type | Description |
|---|---|---|
string | Create API token for external chat | |
string | List API tokens | |
string | Remove API token | |
string | Get API usage statistics | |
| string | Create conversation externally |
| string | Get external conversation |
| string | Complete external conversation |
string | Upload and parse doc externally |
Next Chat Endpoints
Key | Type | Description | Parameters | Example Usage |
|---|---|---|---|---|
string | List next dialogs | None | ||
| (id: string) => string | Fetch external chatbot info | id (string) | api.fetchExternalChatInfo("bot123") → "/api/v1/chatbots/bot123/info" |
File Manager Endpoints
Key | Type | Description |
|---|---|---|
string | List files | |
string | Upload file | |
string | Remove file | |
string | Rename file | |
string | Get all parent folders | |
string | Create folder | |
| string | Convert file to knowledge document |
string | Get file | |
string | Move file |
System Endpoints
Key | Type | Description |
|---|---|---|
string | Get system version | |
string | Get system status | |
string | List system tokens | |
string | Create system token | |
string | List system tokens (duplicate key) | |
string | Remove system token | |
string | Get system configuration | |
string | Set Langfuse API key configuration |
Flow (Canvas) Endpoints
Key | Type | Description |
|---|---|---|
string | List canvas templates | |
string | List canvases | |
string | List team canvases | |
string | Get canvas details | |
string | Get canvas via SSE | |
string | Remove canvas | |
string | Set or update canvas | |
string | Canvas settings | |
string | Get list of canvas versions | |
string | Get specific canvas version | |
string | Reset canvas | |
string | Run canvas completion | |
string | Test database connection | |
string | Get input elements of canvas | |
string | Debug canvas | |
string | Upload file for canvas | |
string | Trace canvas |
Agent Endpoints
Key | Type | Description | Parameters |
|---|---|---|---|
string | Input form for canvas agent | None | |
(id: string) => string | Fetch version list for canvas | ||
(id: string) => string | Fetch a specific version | ||
(id: string) => string | Fetch canvas by ID | ||
(id: string) => string | Fetch agent avatar via SSE | ||
(id?: string) => string | Upload file for agent | Optional id | |
(canvasId: string) => string | Fetch agent session logs | ||
| (canvasId: string) => string | Fetch external agent inputs | |
string | Prompt for canvas agent | None |
MCP Server Endpoints
Key | Type | Description |
|---|---|---|
string | List MCP servers | |
string | Get MCP server details | |
string | Create MCP server | |
string | Update MCP server | |
string | Delete MCP server | |
string | Import MCP server configuration | |
string | Export MCP server configuration | |
string | List tools for MCP server | |
string | Test MCP server tool | |
string | Cache MCP server tools | |
string | Test MCP server connectivity |
Next-Search Endpoints
Key | Type | Description |
|---|---|---|
string | Create a new search | |
string | List searches | |
string | Delete a search | |
string | Get search details | |
string | Get shared search details | |
string | Update search settings | |
| string | Ask question in shared search |
| string | Mindmap in shared search |
string | Related questions in shared search | |
string | Retrieval test in shared search |
Implementation Details and Usage
The file does **