api/src/ai/tools/files/prompt.md
Perform CRUD operations on files in Directus.
read: List/query metadata or get specific items by IDupdate: Modify existing metadatadelete: Remove files by keysimport: Import a file from a URL and create or update its file data{
"action": "read",
"query": {
"fields": ["id", "title", "type", "filesize", "width", "height"],
"filter": { "type": { "_starts_with": "image/" } },
"limit": 10
}
}
{
"action": "read",
"keys": ["file-uuid-here"]
}
{
"action": "import",
"data": [
{
"url": "file-url",
"file": {
"title": "New Title",
"description": "Updated description",
"tags": ["tag1", "tag2", "category"],
"folder": "folder-uuid"
}
}
]
}
Single file:
{
"action": "update",
"keys": ["file-uuid"],
"data": {
"title": "New Title",
"description": "Updated description",
"tags": ["tag1", "tag2", "category"],
"folder": "folder-uuid"
}
}
Batch update:
{
"action": "update",
"data": [
{ "id": "file-uuid-1", "title": "New Title 1" },
{ "id": "file-uuid-2", "title": "New Title 2" }
]
}
{
"query": {
"filter": {
"_and": [
{ "type": { "_icontains": "/png" } }, // PNG files only
{ "folder": { "_eq": "folder-uuid" } }, // Specific folder
{ "filesize": { "_lt": 5000000 } }, // Under 5MB
{ "uploaded_on": { "_gte": "$NOW(-7 days)" } } // Within last week
]
}
}
}
id: Unique identifierstorage: Storage adapter usedfilename_disk: Actual filename on diskfilename_download: Suggested download filenametitle: Display titletype: MIME type (e.g., "image/jpeg", "application/pdf")folder: Parent folder IDuploaded_by: User who uploadeduploaded_on: Upload timestampmodified_by: Last modifiermodified_on: Last modification timefilesize: Size in byteswidth/height: Dimensions for images (in pixels)duration: Length for video/audiodescription: File descriptionlocation: Geo-location datatags: Array of tag strings (e.g., ["product", "red", "handbag"])metadata: Additional metadata objectfocal_point_x: Horizontal focal point (in pixels from left edge)focal_point_y: Vertical focal point (in pixels from top edge)Find appropriate images for articles, pages, or products:
Example: "Find images in our asset library related to customer support for our new help center article."
{
"action": "read",
"query": {
"fields": ["id", "title", "description", "tags", "type"],
"search": "help center"
}
}
Transform generic files into well-organized, searchable assets:
{
"action": "read",
"query": {
"fields": ["id", "filename_disk", "title", "description"],
"filter": { "description": { "_null": true } }
}
}
Analyze with vision (use assets tool for base64): Get image content for AI analysis
Update with descriptive metadata:
{
"action": "update",
"keys": ["image-uuid"],
"data": {
"title": "Red leather handbag product photo",
"description": "Professional e-commerce photo with white background",
"tags": ["handbag", "leather", "red", "product-photo", "accessories"],
"focal_point_x": 512,
"focal_point_y": 300 // Focal points ensure that when images are cropped for different aspect ratios (thumbnails, hero images, etc.), the important subject remains visible. Coordinates are in pixels from the top-left corner of the original image.
}
}
keys and tags must be arrays: ["item"] not "item"