Asset API
Upload and manage assets for AI features such as images for image processing, PDFs for document analysis, and other file types.
Overview
The Asset API provides a secure way to upload files that can be used with various AI features. Once uploaded, assets are stored with unique identifiers and can be referenced in other API calls. This API supports multiple file types and provides detailed metadata about uploaded files.
Endpoint
Authentication
All requests require authentication using an API key in the request header.
Field | Value |
---|---|
API-KEY | <api-key> |
Content-Type | multipart/form-data |
Request Parameters
Required Parameters
Parameter | Type | Description |
---|---|---|
asset | File | The file to upload (images, PDFs, documents, etc.) |
Example Request
- JavaScript
- cURL
- Python
const formData = new FormData();
formData.append('asset', fileInput.files[0]);
fetch('https://api.1min.ai/api/assets', {
method: 'POST',
headers: {
'API-KEY': 'YOUR_API_KEY'
},
body: formData
})
.then(response => response.json())
.then(data => console.log(data));
curl --location 'https://api.1min.ai/api/assets' \
--header 'API-KEY: YOUR_API_KEY' \
--form 'asset=@"/path/to/your/file.png"'
import requests
url = "https://api.1min.ai/api/assets"
headers = {
"API-KEY": "YOUR_API_KEY"
}
with open("/path/to/your/file.png", "rb") as file:
files = {"asset": file}
response = requests.post(url, headers=headers, files=files)
print(response.json())
Response Payload
Success Response (200 OK)
{
"asset": {
"fieldname": "asset",
"originalname": "example.png",
"encoding": "7bit",
"mimetype": "image/png",
"size": 12368,
"bucket": "asset.1min.ai",
"key": "images/2024_09_30_13_38_59_100_example.png",
"acl": "private",
"contentType": "application/octet-stream",
"contentDisposition": null,
"contentEncoding": null,
"storageClass": "STANDARD",
"serverSideEncryption": null,
"metadata": {
"team-id": "307b3666-0869-4910-9d01-75fc14a08c4d",
"user-id": "52555103-410b-4ea0-881c-d6f3453f2469",
"fieldname": "asset",
"originalname": "example.png",
"encoding": "7bit",
"mimetype": "image/png"
},
"location": "https://asset.1min.ai.s3.us-east-1.amazonaws.com/images/2024_09_30_13_38_59_100_example.png",
"etag": "\"2cb9318ab87188247c8ed71e1d4078d9\""
},
"fileContent": {
"uuid": "26f30dfd-1d61-4b5b-889c-d7ab2d60d1ee",
"path": "images/2024_09_30_13_38_59_100_example.png",
"type": "png",
"name": "2024_09_30_13_38_59_100_example.png",
"content": "",
"status": "ACTIVE",
"metadata": {
"token": 0,
"character": 0
},
"createdAt": "2024-09-30T06:39:00.540Z"
}
}
Response Fields
asset Object
Field | Type | Description |
---|---|---|
fieldname | string | Form field name used for upload |
originalname | string | Original filename of the uploaded file |
encoding | string | File encoding (e.g., "7bit") |
mimetype | string | MIME type of the uploaded file |
size | number | File size in bytes |
bucket | string | S3 bucket name where file is stored |
key | string | Unique key/path for the file in storage |
acl | string | Access control level ("private") |
contentType | string | Content type of the stored file |
contentDisposition | string | Content disposition header (nullable) |
contentEncoding | string | Content encoding header (nullable) |
storageClass | string | S3 storage class (e.g., "STANDARD") |
serverSideEncryption | string | Server-side encryption method (nullable) |
metadata | object | Additional metadata about the file |
location | string | Full URL to access the uploaded file |
etag | string | Entity tag for the uploaded file |
fileContent Object
Field | Type | Description |
---|---|---|
uuid | string | Unique identifier for the file record |
path | string | Storage path relative to bucket |
type | string | File type/extension |
name | string | Generated filename in storage |
content | string | Text content (empty for binary files) |
status | string | File status ("ACTIVE", "INACTIVE") |
metadata | object | Processing metadata (tokens, characters) |
createdAt | string | File creation timestamp (ISO 8601) |
Using Uploaded Assets
Once an asset is uploaded successfully, you can use the key
or path
from the response in other API calls:
In AI Feature API
{
"type": "IMAGE_GENERATOR",
"model": "midjourney",
"promptObject": {
"imageUrl": "images/2024_09_30_13_38_59_100_example.png",
"mode": "fast"
}
}
Direct Access
You can also access the file directly using the location
URL provided in the response (requires proper authentication).
Supported File Types
- Images: PNG, JPEG, WEBP, GIF, SVG
- Documents: PDF, DOC, DOCX, TXT
- Data: JSON, CSV, XML
- Other: Various file types depending on the AI feature requirements
Error Responses
Bad Request (400)
{
"success": false,
"error": {
"code": "BAD_REQUEST",
"message": "No file uploaded or invalid file format"
}
}
Unauthorized (401)
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}
Payload Too Large (413)
{
"success": false,
"error": {
"code": "PAYLOAD_TOO_LARGE",
"message": "File size exceeds maximum limit"
}
}
Too Many Requests (429)
{
"success": false,
"error": {
"code": "TOO_MANY_REQUESTS",
"message": "Rate limit exceeded"
}
}
Rate Limits
- Maximum file size: 50MB per upload
- Rate limit: 100 requests per minute per API key
- Concurrent uploads: 5 simultaneous uploads per API key
For more details about rate limits, see the Rate Limits specification.