File manager
The file manager tool saves text and files to your workspace storage and returns a download link and a resource ID for each one. To upload your own files and folders as assets, see Files.
Asset path: aixplain/aixplain-file-manager/aixplain · Marketplace card
Use it when an agent produces a deliverable, such as a report, a dataset or a generated page, that should be downloaded rather than returned inline.
Try it
from aixplain import Aixplain
aix = Aixplain(api_key="YOUR_API_KEY")
file_manager = aix.Tool.get("aixplain/aixplain-file-manager/aixplain")
file_manager.allowed_actions = ["save_content"]
agent = aix.Agent(
name="Report saver",
description="Writes short reports and saves them as downloadable files.",
instructions="Write the requested report, save it with the file manager, and return the file name and download link.",
tools=[file_manager],
).save()
result = agent.run("Write a 3-sentence status update for the BrewBox launch and save it as a file.")
print(result.data.output)
The tool needs no connect step and no config. You get it by path and it is ready to run.
Actions
| Action | What it does |
|---|---|
save_content | Saves one or more strings as files. |
save_files | Copies one or more files that are already in aixplain storage, by URL. |
Inputs, passed in data:
| Parameter | Type | Default | Description |
|---|---|---|---|
requestid | str | required | Groups the files of one request in a folder of that name. Lowercase letters, digits and hyphens, for example "report-saver-6f2c1a9e-k4p7z". Reuse it within a request, never across requests. |
contents | list[str] | required for save_content | One file is created per string. At most 100 per call. |
urls | list[str] | required for save_files | URLs of the files to copy. At most 100 per call. |
names | list[str] | required for save_content | One name per item. A name can include up to 3 folder levels, such as "reports/q3.txt". For save_files, names default to the URL's file name. |
tags | list[str] | none | Tags to attach to each file, up to 64 characters each. |
Each call returns a list with one entry per item: the resource id, the name and a signedUrl, a time-limited download link.
Run the tool directly
allowed_actions also applies to direct runs, so get a fresh copy of the tool to use both actions.
import uuid
file_manager = aix.Tool.get("aixplain/aixplain-file-manager/aixplain")
request_id = f"q3-reports-{uuid.uuid4().hex[:5]}"
result = file_manager.run(action="save_content", data={
"requestid": request_id,
"contents": ["Q3 revenue summary: total $1.2M, up 14% QoQ."],
"names": ["reports/q3_summary.txt"],
})
saved = result.data[0]
print(saved["id"], saved["name"])
print(saved["signedUrl"][:60] + "...")
Copy a stored file
save_files copies a file that is already in aixplain storage, such as a signedUrl returned by save_content, into a new folder and name.
result = file_manager.run(action="save_files", data={
"requestid": request_id,
"urls": [saved["signedUrl"]],
"names": ["archive/q3_summary.txt"],
})
print(result.data[0]["name"])
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Required input 'requestid' is missing | Every call needs a requestid. | Pass a lowercase slug, unique per request. |
An item comes back with error: 'Failed to create file resource' | A file with that name already exists in the requestid folder, or save_files could not fetch the URL (for example, a public web URL). | Use a new requestid or name. For outside content, pass the text with save_content. |
| A download link stops working | signedUrl links expire. | Save the file again to get a fresh link. |
Clean up
agent.delete()
The file manager is a shared Marketplace tool, so there is no tool to delete.
Next steps
- Tools: see every kind of tool an agent can call.
- Files: upload your own files and attach them to agents.
- Agents: configure the agent that calls the tool.
- API reference: tool: every parameter and method.