Skip to main content
GET
/
v1
/
files
List Files
curl --request GET \
  --url https://api.gravixlayer.com/v1/files \
  --header 'Authorization: Bearer <token>'
Overview The List Files API provides a comprehensive view of all files uploaded to your Gravix Layer organization. Use this endpoint to manage your file storage, monitor usage, and organize files by purpose and metadata. Key Features
  • Purpose-based filtering to organize files by use case
  • Pagination support for large file collections
  • Detailed metadata including size, creation date, and status
  • Real-time file status tracking
  • Bulk operations support for file management
Common Use Cases
Monitor and organize your uploaded files:
# List all files with metadata
files = client.files.list()

for file in files.data:
    print(f"{file.filename}: {file.bytes} bytes, {file.purpose}")
Query Parameters
ParameterTypeRequiredDescription
purposestringNoFilter files by purpose. One of: batch, batch_output, fine-tune, vision, user_data, evals
limitintegerNoNumber of files to return (default: 20, max: 100)
afterstringNoCursor for pagination. Use the id of the last file from the previous page
Example Requests
curl https://api.gravixlayer.com/v1/files \
  -H "Authorization: Bearer $GRAVIXLAYER_API_KEY"

Response

{
  "object": "list",
  "data": [
    {
      "id": "file-abc123",
      "object": "file",
      "bytes": 175842,
      "created_at": 1699061776,
      "filename": "training_data.jsonl",
      "purpose": "fine-tune"
    },
    {
      "id": "file-def456", 
      "object": "file",
      "bytes": 245832,
      "created_at": 1699061234,
      "filename": "image_dataset.zip",
      "purpose": "vision"
    }
  ],
  "has_more": false
}

Response Fields

FieldTypeDescription
idstringUnique identifier for the file
objectstringAlways “file”
bytesintegerSize of the file in bytes
created_atintegerUnix timestamp of when the file was created
filenamestringName of the uploaded file
purposestringPurpose specified when uploading

Pagination

Use the after parameter to paginate through results:
# Get first page
files = client.files.list(limit=20)

# Get next page using the last file ID
if files.has_more:
    next_files = client.files.list(
        limit=20,
        after=files.data[-1].id
    )

Error Responses

Status CodeError TypeDescription
400invalid_request_errorInvalid query parameters
401authentication_errorInvalid or missing API key
429rate_limit_exceededToo many requests

Use Cases

Monitor and manage your uploaded files:
def manage_files():
    files = client.files.list()
    
    for file in files.data:
        # Check file age
        age_days = (time.time() - file.created_at) / (24 * 60 * 60)
        
        print(f"File: {file.filename}")
        print(f"  Size: {file.bytes / 1024 / 1024:.1f} MB")
        print(f"  Age: {age_days:.1f} days")
        print(f"  Purpose: {file.purpose}")
        
        # Flag old files for cleanup
        if age_days > 30 and file.purpose in ["batch", "user_data"]:
            print(f"  ⚠️  Consider deleting old file")

Authorizations

Authorization
string
header
required

API key authentication. Get your API key from the Gravix Layer Dashboard.

Query Parameters

purpose
string

Filter files by purpose

limit
integer
default:20

Number of files to return

Required range: x <= 100
order
enum<string>
default:desc

Sort order

Available options:
asc,
desc
after
string

Pagination cursor

Response

200

List of files