AIN. - AnythingLLM API Integration

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

AIN. - AnythingLLM API Integration

AIN.UploadDocument

Previous Top Next


MiniRobotLanguage (MRL)

 

AIN.UploadDocument
Upload a Document to an AnythingLLM Workspace

 

Intention

 

UploadDocument Command: Adding Files to a Workspace
 
The UploadDocument command allows you to upload a file (e.g., PDF, text, or other supported formats) to a specified AnythingLLM workspace using its slug.

This is useful for adding content to a workspace for processing, analysis, or chat interactions.

It’s part of the AIN - AnythingLLM API suite.

 

What is the UploadDocument Command?

 

The UploadDocument command sends a file to the AnythingLLM API, associating it with a workspace identified by its slug.

You can optionally specify a variable to store the API response, which typically includes confirmation details or an error message.

 

Why Do You Need It?

 

Uploading documents is essential when:

You want to enrich a workspace with documents for AI processing.

Adding reference materials for chat-based queries.

Automating document ingestion into AnythingLLM workflows.

 

How to Use the UploadDocument Command?

 

Provide the workspace slug and the full file path of the document to upload, with an optional variable for the response.

Ensure the file exists and the workspace slug is valid (check with AIN.ListWorkspaces).

 

Example Usage

 

AIN.UploadDocument|my-workspace|C:\Docs\report.pdf|$$RES

DBP.Upload Response: $$RES

 

This uploads "report.pdf" to "my-workspace" and stores the API response in $$RES.

 

Illustration

 

┌───────────────┐

│ Local File    │

├───────────────┤

│ report.pdf    │

└───────────────┘

Before: File on disk; After AIN.UploadDocument: File added to workspace.

 

Syntax

 

AIN.UploadDocument|P1|P2[|P3]

AIN.UploadDocument|P1|P2[|P3]

 

Parameter Explanation

 

P1 - The workspace slug identifying the target workspace (required).

P2 - Full file path of the document to upload (required).

P3 - (Optional) Variable to store the raw API response (e.g., success or error details).

 

Example

 

AIN.CreateWorkspace|test-workspace

AIN.UploadDocument|test-workspace|C:\Docs\manual.txt|$$OUT

DBP.Upload Result: $$OUT

ENR.

 

Remarks

 

- Requires a valid API key set via AIN.SetKey.

- The API response typically confirms the upload with metadata (e.g., document ID) or returns an error if the file is unsupported.

 

Limitations

 

- Fails if the file path is invalid or the file type is not supported by AnythingLLM.

- Limited to 2 or 3 parameters; additional parameters may cause an error.

 

See also:

 

AIN.CreateWorkspace

AIN.ListWorkspaces

AIN.GetWorkspaceBySlug

Workspace Management