'use client'; /** * API Reference: Image Upload * * Based on docs/api/images-upload.md (upload section) */ import { TipBox } from '@/components/docs/shared/TipBox'; import { Table } from '@/components/docs/shared/Table'; import { CodeBlock } from '@/components/docs/shared/CodeBlock'; import { DocPage } from '@/components/docs/layout/DocPage'; import { Hero, SectionHeader, InlineCode, EndpointCard, } from '@/components/docs/blocks'; const tocItems = [ { id: 'overview', text: 'Overview', level: 2 }, { id: 'endpoint', text: 'Upload Endpoint', level: 2 }, { id: 'parameters', text: 'Form Parameters', level: 2 }, { id: 'constraints', text: 'File Constraints', level: 2 }, { id: 'flow-association', text: 'Flow Association', level: 2 }, { id: 'response', text: 'Response Format', level: 2 }, { id: 'error-codes', text: 'Error Codes', level: 2 }, { id: 'next-steps', text: 'Next Steps', level: 2 }, ]; const formParameters = [ { name: 'file', type: 'file', required: true, description: 'Image file (PNG, JPEG, WebP)' }, { name: 'alias', type: 'string', required: false, description: 'Project-scoped alias (e.g., @logo)' }, { name: 'flowId', type: 'string', required: false, description: 'Flow UUID to associate with' }, { name: 'flowAlias', type: 'string', required: false, description: 'Flow-scoped alias (requires flowId)' }, { name: 'meta', type: 'string', required: false, description: 'JSON string with custom metadata' }, ]; const fileConstraints = [ ['Max file size', '5MB'], ['Supported formats', 'PNG, JPEG, JPG, WebP'], ['MIME types', 'image/png, image/jpeg, image/webp'], ]; const flowIdBehavior = [ ['Not provided', 'Auto-generate pendingFlowId, lazy flow creation'], ['null', 'No flow association'], ['"uuid"', 'Associate with specified flow'], ]; const errorCodes = [ ['400', 'VALIDATION_ERROR', 'Invalid parameters'], ['400', 'FILE_TOO_LARGE', 'File exceeds 5MB limit'], ['400', 'UNSUPPORTED_FILE_TYPE', 'Not PNG, JPEG, or WebP'], ['400', 'ALIAS_FORMAT_CHECK', 'Alias must start with @'], ['401', 'UNAUTHORIZED', 'Missing or invalid API key'], ]; export default function ImageUploadPage() { return ( {/* Hero Section */} {/* Overview */}
Overview

The Upload API allows you to upload images to your project. Uploaded images can be used as references for image-to-image generation, assigned aliases for easy access, or stored as standalone assets.

Tip: Use aliases like @logo to reference uploaded images by name instead of UUID.
{/* Endpoint */}
Upload Endpoint

Requires X-API-Key header with your Project Key. Content-Type must be multipart/form-data.

{/* Parameters */}
Form Parameters

Send parameters as multipart/form-data:

[ {param.name}, {param.type}, {param.required ? 'Yes' : 'No'} , param.description, ])} />
{/* File Constraints */}
File Constraints
[ constraint, {limit}, ])} />
File Size: Files larger than 5MB will be rejected with a 400 error. Compress images before uploading if needed.
{/* Flow Association */}
Flow Association

Images can be associated with generation flows for organized workflows. The flowId parameter controls this behavior:

[ {value}, behavior, ])} />
{/* Response */}
Response Format

On success, the API returns a JSON object containing the uploaded image details.

Note: The id field equals the filename in storage (UUID). Original filename is preserved in object metadata.
{/* Error Codes */}
Error Codes

The API uses standard HTTP status codes and returns descriptive error messages.

[ {status}, {code}, description, ])} /> ); }