Download OpenAPI specification:
This API combines the OpenAI-compatible chat endpoints from the Munger BI Agent API and the OCR Service API.
Completion api.
model required | string (Model) Model name |
required | Array of objects (Messages) List of messages |
max_tokens | integer or null (Max Tokens) Maximum number of tokens to generate |
temperature | number or null (Temperature) Temperature parameter |
top_p | number or null (Top P) Top-p parameter |
n | integer or null (N) Default: 1 Number of completions to generate |
stream | boolean or null (Stream) Default: false Whether to respond in a streaming manner |
(Stop (string or null)) or (Array of Stop (strings or null)) (Stop) Stop words | |
presence_penalty | number or null (Presence Penalty) Presence penalty |
frequency_penalty | number or null (Frequency Penalty) Frequency penalty |
object or null (Logit Bias) Logit bias | |
user | string or null (User) User identifier |
{- "model": "string",
- "messages": [
- {
- "role": "system",
- "content": "string",
- "name": "string"
}
], - "max_tokens": 0,
- "temperature": 0,
- "top_p": 0,
- "n": 1,
- "stream": false,
- "stop": "string",
- "presence_penalty": 0,
- "frequency_penalty": 0,
- "logit_bias": {
- "property1": 0,
- "property2": 0
}, - "user": "string"
}
{- "detail": [
- {
- "loc": [
- "string"
], - "msg": "string",
- "type": "string"
}
]
}
Get detailed information of the currently logged-in user based on the JWT token.
{- "id": "123e4567-e89b-12d3-a456-426614174000",
- "email": "user@example.com",
- "username": "john_doe",
- "fullName": "John Doe",
- "organizationId": "456e7890-e12b-34d5-a678-426614174001",
- "organizationName": "Example Corp",
- "role": "user",
- "permissions": [
- "manage_documents",
- "export_data"
], - "createdAt": "2024-01-01T00:00:00.000Z",
- "lastLoginAt": "2024-01-01T12:00:00.000Z",
- "isNewUser": false
}
Validate the provided JWT token and return the user information associated with the token.
{- "valid": true,
- "user": {
- "id": "123e4567-e89b-12d3-a456-426614174000",
- "email": "user@example.com",
- "username": "john_doe",
- "fullName": "John Doe",
- "organizationId": "456e7890-e12b-34d5-a678-426614174001",
- "organizationName": "Example Corp",
- "role": "user",
- "permissions": [
- "manage_documents",
- "export_data"
], - "createdAt": "2024-01-01T00:00:00.000Z",
- "lastLoginAt": "2024-01-01T12:00:00.000Z",
- "isNewUser": false
}, - "error": "Token has expired"
}
Generate a presigned URL for file upload. The frontend can use this URL to upload files directly to cloud storage. Note: When uploading, be sure to set the Content-Type header to the type specified during signing.
fileName required | string File name |
fileSize required | number [ 1 .. 52428800 ] File size (bytes) |
mimeType required | string File MIME type |
description | string Document description |
{- "fileName": "invoice-001.pdf",
- "fileSize": 1024000,
- "mimeType": "application/pdf",
- "description": "January 2024 Invoice"
}
{- "documentId": "doc-550e8400-e29b-41d4-a716-446655440000",
- "filePath": "uploads/org-123/doc-550e8400-e29b-41d4-a716-446655440000/invoice-001.pdf"
}
Confirm that the file has been successfully uploaded to cloud storage, set the file for public access, add it to the OCR processing queue, and return the document information including the public access link.
id required | string Document ID |
{- "id": "doc-550e8400-e29b-41d4-a716-446655440000",
- "fileName": "invoice-001.pdf",
- "status": "uploaded",
- "message": "File confirmed and added to processing queue"
}
page | number >= 1 Default: 1 Example: page=1 Page number |
limit | number [ 1 .. 100 ] Default: 10 Example: limit=10 Number of items per page |
search | string Example: search=Invoice Search keyword |
status | string Enum: "uploading" "uploaded" "processing" "completed" "failed" Filter by document status |
archived | boolean Example: archived=false Whether to show only archived documents |
documentType | string Example: documentType=pdf Filter by document type |
createdFrom | string Example: createdFrom=2024-01-01 Creation date range start |
createdTo | string Example: createdTo=2024-12-31 Creation date range end |
id required | string Document ID |
description | string Document description |
archived | boolean Whether to archive the document |
{- "description": "Updated invoice description",
- "archived": true
}
Generate a presigned download URL for secure file download.
id required | string Document ID |
expires | number Example: expires=3600 Expiration time (seconds) |
{- "downloadUrl": "string"
}
Automatically analyze the content of an uploaded file using AI and generate a structured data extraction template.
id required | string Document ID |
Template generation configuration
templateName required | string Template name |
description | string Template description |
{- "templateName": "Invoice Template",
- "description": "Extracts key information from invoices"
}
{- "templateId": "tpl-550e8400-e29b-41d4-a716-446655440000",
- "message": "Template generation started"
}
documentId required | string Document ID |
webhookUrl | string Webhook URL for receiving processing results |
{- "documentId": "doc-550e8400-e29b-41d4-a716-446655440000",
}
{- "message": "OCR processing has been initiated.",
- "documentId": "doc_clx123456789"
}
documentId required | string |
[- {
- "id": "ocr-550e8400-e29b-41d4-a716-446655440000",
- "documentId": "doc-550e8400-e29b-41d4-a716-446655440000",
- "status": "completed",
- "content": "This is the recognized text.",
- "startedAt": "2024-01-01T00:00:00.000Z",
- "completedAt": "2024-01-01T00:01:00.000Z"
}
]
Get all card objects for a document by its ID, including OCR content, classification information, and processing status.
documentId required | string Example: clh1234567890abcdef Unique identifier for the document. |
[- {
- "id": "card-550e8400-e29b-41d4-a716-446655440000",
- "documentId": "doc-550e8400-e29b-41d4-a716-446655440000",
- "ocrResultId": "ocr-550e8400-e29b-41d4-a716-446655440000",
- "status": "pending",
- "content": "This is a card.",
- "classification": "invoice",
- "createdAt": "2024-01-01T00:00:00.000Z",
- "updatedAt": "2024-01-01T00:00:00.000Z"
}
]
Update the processing status of a specific card, used for user confirmation, rejection, or archiving.
id required | string Example: clh1234567890abcdef Unique identifier for the card. |
status | string Card status |
{- "status": "confirmed"
}
{- "id": "card-550e8400-e29b-41d4-a716-446655440000",
- "documentId": "doc-550e8400-e29b-41d4-a716-446655440000",
- "ocrResultId": "ocr-550e8400-e29b-41d4-a716-446655440000",
- "status": "pending",
- "content": "This is a card.",
- "classification": "invoice",
- "createdAt": "2024-01-01T00:00:00.000Z",
- "updatedAt": "2024-01-01T00:00:00.000Z"
}
Manually generate card objects based on document ID and OCR results. Supports specifying an OCR result ID or using the latest OCR result.
documentId required | string Document ID |
ocrResultId | string OCR result ID (optional, uses latest if not provided) |
{- "documentId": "doc-550e8400-e29b-41d4-a716-446655440000",
- "ocrResultId": "ocr-550e8400-e29b-41d4-a716-446655440000"
}
{- "message": "Card generation successful.",
- "documentId": "doc_clx123456789",
- "count": 5
}
Apply a prompt template to a specified document to extract structured information. This is an asynchronous operation that immediately returns an identifier for the extraction task.
documentId required | string Example: doc_clx123456789 Unique identifier for the document. |
templateId required | string Template ID |
{- "templateId": "tpl-550e8400-e29b-41d4-a716-446655440000"
}
{- "extractionId": "ext-550e8400-e29b-41d4-a716-446655440000",
- "documentId": "doc-550e8400-e29b-41d4-a716-446655440000",
- "status": "pending",
- "message": "Extraction has been initiated"
}
Get all structured extraction history and generated cards for a specified document. The frontend can use this for grouped display.
documentId required | string Example: doc_clx123456789 Unique identifier for the document. |
[- {
- "id": "ext-550e8400-e29b-41d4-a716-446655440000",
- "documentId": "doc-550e8400-e29b-41d4-a716-446655440000",
- "templateId": "tpl-550e8400-e29b-41d4-a716-446655440000",
- "status": "completed",
- "createdAt": "2024-01-01T00:00:00.000Z",
- "cards": [
- {
- "id": "card-550e8400-e29b-41d4-a716-446655440000",
- "documentId": "doc-550e8400-e29b-41d4-a716-446655440000",
- "ocrResultId": "ocr-550e8400-e29b-41d4-a716-446655440000",
- "status": "pending",
- "content": "This is a card.",
- "classification": "invoice",
- "createdAt": "2024-01-01T00:00:00.000Z",
- "updatedAt": "2024-01-01T00:00:00.000Z"
}
]
}
]
Get the current processing status via the extraction ID, used for frontend polling to check if extraction is complete. Recommended polling interval: 2-5 seconds.
extractionId required | string Example: clx5aefd0000008l9g7z2h4a1 Unique identifier for the extraction result. |
{- "status": "completed",
- "message": "Extraction completed successfully"
}
Get all card details and statistics generated by this extraction via the extraction ID. It is recommended to call this interface when the status is COMPLETED.
extractionId required | string Example: clx5aefd0000008l9g7z2h4a1 Unique identifier for the extraction result. |
{- "cards": [
- {
- "id": "card-550e8400-e29b-41d4-a716-446655440000",
- "documentId": "doc-550e8400-e29b-41d4-a716-446655440000",
- "ocrResultId": "ocr-550e8400-e29b-41d4-a716-446655440000",
- "status": "pending",
- "content": "This is a card.",
- "classification": "invoice",
- "createdAt": "2024-01-01T00:00:00.000Z",
- "updatedAt": "2024-01-01T00:00:00.000Z"
}
], - "count": 5
}
Create a new document processing template, including prompts and field configurations.
name required | string Template name |
prompt required | string Template prompt |
required | Array of objects |
{- "name": "Invoice Template",
- "prompt": "Extract the following fields from the invoice: ...",
- "fields": [
- {
- "name": "invoice_number",
- "type": "string",
- "description": "The invoice number"
}
]
}
{- "id": "clx5aefd0000008l9g7z2h4a1",
- "name": "訂單資訊提取模板",
- "description": "適用於訂單文件的結構化資訊提取",
- "systemPrompt": "你是一名結構化資料提取助手,負責從訂單文件中提取並整理訂單基本資料和商品資訊...",
- "fields": [
- "string"
], - "successRate": 0.95,
- "usageCount": 42,
- "status": "active",
- "createdAt": "2025-07-10T10:00:00.000Z",
- "updatedAt": "2025-07-10T11:00:00.000Z"
}
Get all processing templates for the current organization, with support for pagination and search.
page | number >= 1 Example: page=1 Page number |
limit | number [ 1 .. 100 ] Example: limit=10 Number of items per page |
search | string Example: search=Invoice Search keyword |
includeInactive | boolean Example: includeInactive=false Whether to include inactive templates. |
status | string Enum: "active" "inactive" "archived" Filter by template status. |
{- "data": [
- {
- "id": "clx5aefd0000008l9g7z2h4a1",
- "name": "訂單資訊提取模板",
- "description": "適用於訂單文件的結構化資訊提取",
- "systemPrompt": "你是一名結構化資料提取助手,負責從訂單文件中提取並整理訂單基本資料和商品資訊...",
- "fields": [
- "string"
], - "successRate": 0.95,
- "usageCount": 42,
- "status": "active",
- "createdAt": "2025-07-10T10:00:00.000Z",
- "updatedAt": "2025-07-10T11:00:00.000Z"
}
], - "total": 50,
- "page": 1,
- "limit": 10,
- "totalPages": 5,
- "hasNext": true,
- "hasPrev": false
}
Get usage statistics for templates, including usage counts, success rates, etc.
days | number Example: days=30 Number of days for statistics. |
[- {
- "id": "clx5aefd0000008l9g7z2h4a1",
- "name": "訂單資訊提取模板",
- "totalUsage": 42,
- "successRate": 0.95,
- "averageProcessingTime": 2500,
- "lastUsedAt": "2025-07-10T10:00:00.000Z"
}
]
Get detailed information for a specific template by its ID.
id required | string Example: clx5aefd0000008l9g7z2h4a1 Unique identifier for the template. |
{- "id": "clx5aefd0000008l9g7z2h4a1",
- "name": "訂單資訊提取模板",
- "description": "適用於訂單文件的結構化資訊提取",
- "systemPrompt": "你是一名結構化資料提取助手,負責從訂單文件中提取並整理訂單基本資料和商品資訊...",
- "fields": [
- "string"
], - "successRate": 0.95,
- "usageCount": 42,
- "status": "active",
- "createdAt": "2025-07-10T10:00:00.000Z",
- "updatedAt": "2025-07-10T11:00:00.000Z"
}
Update information for a specified template.
id required | string Example: clx5aefd0000008l9g7z2h4a1 Unique identifier for the template. |
name | string 模板名稱 |
description | string 模板描述 |
systemPrompt | string 系統提示詞 |
fields | Array of strings 欄位列表 |
status | string Enum: "active" "inactive" "archived" 模板狀態 |
{- "name": "更新後的訂單模板",
- "description": "更新後的描述",
- "systemPrompt": "string",
- "fields": [
- "string"
], - "status": "active"
}
{- "id": "clx5aefd0000008l9g7z2h4a1",
- "name": "訂單資訊提取模板",
- "description": "適用於訂單文件的結構化資訊提取",
- "systemPrompt": "你是一名結構化資料提取助手,負責從訂單文件中提取並整理訂單基本資料和商品資訊...",
- "fields": [
- "string"
], - "successRate": 0.95,
- "usageCount": 42,
- "status": "active",
- "createdAt": "2025-07-10T10:00:00.000Z",
- "updatedAt": "2025-07-10T11:00:00.000Z"
}