Skip to Content

Knowledge

Stable

Upload documents and query your knowledge base for RAG applications.

Upload Document

POST/api/v1/knowledge/upload-file

Upload one or more documents to your knowledge base using multipart form data.

Request

Use multipart/form-data with the files field:

curl -X POST "https://cloud.milady.ai/api/v1/knowledge/upload-file" \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "files=@document.pdf" \ -F "characterId=optional_agent_id"

Parameters

ParameterTypeRequiredDescription
filesfile[]One or more files to upload (max 10)
characterIdstringAssociate with a specific agent

Upload Limits

LimitValue
Max file size5 MB per file
Max files per batch10 files
Max total batch size10 MB

Supported Formats

FormatExtensions
PDF.pdf
Text.txt, .md
Documents.doc, .docx
Web.html
Data.json, .csv

Response

{ "success": true, "data": [ { "id": "doc_abc123", "filename": "document.pdf", "type": "application/pdf", "size": 1048576, "uploadedAt": 1705312800000, "fragmentCount": 42, "status": "success" } ], "message": "Successfully uploaded 1 file(s)", "successCount": 1, "failedCount": 0, "totalCount": 1 }

List Documents

GET/api/v1/knowledge

Get all documents in your knowledge base.

Response

{ "documents": [ { "id": "doc_abc123", "name": "company-handbook.pdf", "size": 2097152, "chunks": 85, "createdAt": "2024-01-15T10:30:00Z" } ], "total": 15 }

Query Knowledge

POST/api/v1/knowledge/query

Search your knowledge base.

Request

{ "query": "How do I reset my password?", "limit": 5, "minScore": 0.7 }

Parameters

ParameterTypeRequiredDescription
querystringSearch query
limitintegerMax results (default: 5)
minScorenumberMinimum similarity (0-1)

Response

{ "results": [ { "content": "To reset your password, go to Settings > Security > Reset Password...", "score": 0.92, "documentId": "doc_abc123", "documentName": "user-guide.pdf" } ] }

Get Document

GET/api/v1/knowledge/{id}

Get document details.


Delete Document

DELETE/api/v1/knowledge/{id}

Remove a document from your knowledge base.


Check Document

POST/api/v1/knowledge/check

Check if a document exists (by hash).

Documents are automatically chunked and embedded for semantic search.