feature/api-development #1
|
|
@ -1,71 +0,0 @@
|
|||
@base = http://localhost:3000
|
||||
# Replace with your actual API key (e.g., bnt_abc123...)
|
||||
@apiKey = bnt_d0da2d441cd2f22a0ec13897629b4438cc723f0bcb320d646a41ed05a985fdf8
|
||||
# Replace with your master key for admin endpoints
|
||||
@masterKey = bnt_71475a11d69344ff9db2236ff4f10cfca34512b29c7ac1a74f73c156d708e226
|
||||
|
||||
|
||||
### Health
|
||||
|
||||
GET {{base}}/health
|
||||
|
||||
|
||||
### Info
|
||||
|
||||
GET {{base}}/api/info
|
||||
|
||||
|
||||
### Bootstrap - Create First Master Key (One-time only)
|
||||
|
||||
POST {{base}}/api/bootstrap/initial-key
|
||||
|
||||
|
||||
### Admin - Create New API Key (Requires Master Key)
|
||||
|
||||
POST {{base}}/api/admin/keys
|
||||
Content-Type: application/json
|
||||
X-API-Key: {{masterKey}}
|
||||
|
||||
{
|
||||
"type": "project",
|
||||
"projectId": "my-project",
|
||||
"name": "My Project Key",
|
||||
"expiresInDays": 90
|
||||
}
|
||||
|
||||
|
||||
### Admin - List All API Keys (Requires Master Key)
|
||||
|
||||
GET {{base}}/api/admin/keys
|
||||
X-API-Key: {{masterKey}}
|
||||
|
||||
|
||||
### Admin - Revoke API Key (Requires Master Key)
|
||||
|
||||
DELETE {{base}}/api/admin/keys/KEY_ID_HERE
|
||||
X-API-Key: {{masterKey}}
|
||||
|
||||
|
||||
### Generate Image from Text (Requires API Key)
|
||||
|
||||
POST {{base}}/api/text-to-image
|
||||
Content-Type: application/json
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
{
|
||||
"prompt": "A majestic eagle soaring over snow-capped mountains",
|
||||
"filename": "test-eagle"
|
||||
}
|
||||
|
||||
|
||||
### Generate Image - Text to Image (alternative format)
|
||||
POST http://localhost:3000/api/text-to-image
|
||||
Content-Type: application/json
|
||||
X-API-Key: bnt_61ba018f01474491cbaacec4509220d7154fffcd011f005eece4dba7889fba99
|
||||
|
||||
{
|
||||
"prompt": "фотография детской кроватки в стиле piratespunk",
|
||||
"filename": "generated_image",
|
||||
"autoEnhance": true
|
||||
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@ Create new image generation with optional reference images and flow support.
|
|||
**Purpose:** Generate AI images with reference support and automatic alias assignment
|
||||
|
||||
// TODO: change assignAlias to alias, assignFlowAlias to flowAlias
|
||||
// TODO: response should include enhanced prompt if used
|
||||
---
|
||||
|
||||
### GET /api/v1/generations
|
||||
|
|
@ -60,7 +61,7 @@ Get single generation with full details.
|
|||
### POST /api/v1/generations/:id/retry
|
||||
|
||||
Retry a failed generation.
|
||||
// TODO: the main purpose of this to regenerate an image, e.g. refresh, or reflect some shared project settings like styles or aliases. It's not for generating failed generations. Not sure we need to allow alter prompt or aspectRatio
|
||||
// TODO: the main purpose of this to regenerate an image, e.g. refresh, or reflect some shared project settings like styles or aliases. It's not for generating failed generations. Not sure we need to allow alter prompt or aspectRatio. Now it return error: "Cannot retry a generation that already succeeded" - it's not a desired behavior
|
||||
|
||||
**Authentication:** Project Key required
|
||||
|
||||
|
|
@ -379,22 +380,34 @@ Generate image with prompt-based caching.
|
|||
|
||||
## Alias System
|
||||
|
||||
The v1 API supports a 3-tier alias resolution system:
|
||||
The v1 API supports a 3-tier alias resolution system for referencing images.
|
||||
|
||||
**Technical Aliases** (Computed)
|
||||
**Alias Format Requirements:**
|
||||
- All aliases MUST start with `@` symbol
|
||||
- Pattern: `@[a-zA-Z0-9_-]+` (alphanumeric, underscore, hyphen)
|
||||
- Maximum length: 50 characters
|
||||
- Examples: `@hero`, `@product-main`, `@image_1`
|
||||
|
||||
**Technical Aliases** (Computed, Reserved)
|
||||
- `@last` - Most recently generated image in project
|
||||
- `@first` - First generated image in project
|
||||
- `@upload` - Most recently uploaded image in project
|
||||
|
||||
**Reserved Aliases** (Cannot be used)
|
||||
- Technical aliases: `@last`, `@first`, `@upload`
|
||||
- Future reserved: `@all`, `@latest`, `@oldest`, `@random`, `@next`, `@prev`, `@previous`
|
||||
|
||||
**Flow Aliases** (Flow-scoped)
|
||||
- Stored in flow's aliases JSON field
|
||||
- Only accessible within flow context
|
||||
- Set via `PUT /api/v1/flows/:id/aliases`
|
||||
- Example: `@hero` in flow A is different from `@hero` in flow B
|
||||
|
||||
**Project Aliases** (Global)
|
||||
- Unique within project
|
||||
- Accessible across all flows
|
||||
- Set via `PUT /api/v1/images/:id/alias` or generation parameters
|
||||
- Example: `@logo` is the same image across entire project
|
||||
|
||||
**Resolution Order:**
|
||||
1. Technical aliases (if matches @last, @first, @upload)
|
||||
|
|
@ -420,3 +433,4 @@ The v1 API supports a 3-tier alias resolution system:
|
|||
- `"Alias already exists"` - Alias conflict in project
|
||||
- `"Invalid aspect ratio"` - Unsupported aspect ratio format
|
||||
- `"File too large"` - Upload exceeds 5MB limit
|
||||
- `"alias_format_check"` - Alias must start with @ symbol (e.g., @hero not hero)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,212 @@
|
|||
@base = http://localhost:3000
|
||||
@apiKey = bnt_71e7e16732ac5e21f597edc56e99e8c3696e713552ec9d1f44dfeffb2ef7c495
|
||||
|
||||
###############################################################################
|
||||
# GENERATIONS
|
||||
###############################################################################
|
||||
|
||||
### Create Generation
|
||||
# Generate AI image with optional reference images and flow support
|
||||
POST {{base}}/api/v1/generations
|
||||
Content-Type: application/json
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
{
|
||||
"prompt": "A majestic eagle soaring over snow-capped mountains",
|
||||
"aspectRatio": "16:9",
|
||||
"assignAlias": "@eagle-hero",
|
||||
"assignFlowAlias": "@hero",
|
||||
"autoEnhance": true,
|
||||
"meta": {
|
||||
"tags": ["demo", "nature"]
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
"flowId": "flow-uuid-here",
|
||||
generationID: "e14e0cc1-b3bc-4841-a6dc-f42c842d8d86"
|
||||
|
||||
###
|
||||
|
||||
### List Generations
|
||||
# Browse generation history with filters and pagination
|
||||
GET {{base}}/api/v1/generations?limit=20&offset=0&status=success
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
### Get Generation by ID
|
||||
# View complete generation details including output and reference images
|
||||
GET {{base}}/api/v1/generations/e14e0cc1-b3bc-4841-a6dc-f42c842d8d86
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
### Retry Generation
|
||||
# Recreate a failed generation with optional parameter overrides
|
||||
POST {{base}}/api/v1/generations/e14e0cc1-b3bc-4841-a6dc-f42c842d8d86/retry
|
||||
Content-Type: application/json
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
|
||||
|
||||
### Delete Generation
|
||||
# Remove generation record and associated output image (soft delete)
|
||||
DELETE {{base}}/api/v1/generations/generation-uuid-here
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
###############################################################################
|
||||
# FLOWS
|
||||
###############################################################################
|
||||
|
||||
### Create Flow
|
||||
# Initialize a new generation chain/workflow
|
||||
POST {{base}}/api/v1/flows
|
||||
Content-Type: application/json
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
{
|
||||
"meta": {
|
||||
"name": "Product Images Campaign"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
### List Flows
|
||||
# Browse all flows with computed generation and image counts
|
||||
GET {{base}}/api/v1/flows?limit=20&offset=0
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
### Get Flow by ID
|
||||
# View flow metadata, aliases, and computed counts
|
||||
GET {{base}}/api/v1/flows/flow-uuid-here
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
### List Flow Generations
|
||||
# View all generations associated with this flow
|
||||
GET {{base}}/api/v1/flows/flow-uuid-here/generations?limit=20
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
### List Flow Images
|
||||
# View all images (generated and uploaded) in this flow
|
||||
GET {{base}}/api/v1/flows/flow-uuid-here/images?limit=20
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
### Update Flow Aliases
|
||||
# Add or update flow-scoped aliases for image referencing
|
||||
PUT {{base}}/api/v1/flows/flow-uuid-here/aliases
|
||||
Content-Type: application/json
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
{
|
||||
"aliases": {
|
||||
"@hero": "image-uuid-here",
|
||||
"@background": "another-image-uuid"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
### Delete Flow Alias
|
||||
# Remove a single alias from flow's alias map
|
||||
DELETE {{base}}/api/v1/flows/flow-uuid-here/aliases/@hero
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
### Delete Flow
|
||||
# Remove flow (hard delete, generations and images remain)
|
||||
DELETE {{base}}/api/v1/flows/flow-uuid-here
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
###############################################################################
|
||||
# IMAGES
|
||||
###############################################################################
|
||||
|
||||
### Upload Image
|
||||
# Upload image with automatic database record creation and storage
|
||||
POST {{base}}/api/v1/images/upload
|
||||
X-API-Key: {{apiKey}}
|
||||
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
|
||||
|
||||
------WebKitFormBoundary7MA4YWxkTrZu0gW
|
||||
Content-Disposition: form-data; name="file"; filename="image.png"
|
||||
Content-Type: image/png
|
||||
|
||||
< ./path/to/image.png
|
||||
------WebKitFormBoundary7MA4YWxkTrZu0gW
|
||||
Content-Disposition: form-data; name="alias"
|
||||
|
||||
@product-hero
|
||||
------WebKitFormBoundary7MA4YWxkTrZu0gW
|
||||
Content-Disposition: form-data; name="flowId"
|
||||
|
||||
flow-uuid-here
|
||||
------WebKitFormBoundary7MA4YWxkTrZu0gW--
|
||||
|
||||
|
||||
### List Images
|
||||
# Browse image library with optional filters
|
||||
GET {{base}}/api/v1/images?limit=20&offset=0&source=generated
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
### Resolve Alias
|
||||
# Lookup image by alias with technical → flow → project precedence
|
||||
GET {{base}}/api/v1/images/resolve/@last?flowId=flow-uuid-here
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
### Get Image by ID
|
||||
# View complete image metadata and details
|
||||
GET {{base}}/api/v1/images/image-uuid-here
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
### Update Image Metadata
|
||||
# Modify image metadata fields
|
||||
PUT {{base}}/api/v1/images/image-uuid-here
|
||||
Content-Type: application/json
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
{
|
||||
"alias": "@new-alias",
|
||||
"focalPoint": {
|
||||
"x": 0.5,
|
||||
"y": 0.3
|
||||
},
|
||||
"meta": {
|
||||
"description": "Updated description"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
### Assign Image Alias
|
||||
# Set project-level alias for image referencing
|
||||
PUT {{base}}/api/v1/images/image-uuid-here/alias
|
||||
Content-Type: application/json
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
{
|
||||
"alias": "@product-hero"
|
||||
}
|
||||
|
||||
|
||||
### Delete Image
|
||||
# Mark image as deleted without removing from storage (soft delete)
|
||||
DELETE {{base}}/api/v1/images/image-uuid-here
|
||||
X-API-Key: {{apiKey}}
|
||||
|
||||
|
||||
###############################################################################
|
||||
# LIVE GENERATION
|
||||
###############################################################################
|
||||
|
||||
### Generate with Prompt Caching
|
||||
# Generate images with intelligent caching based on prompt hash
|
||||
# Returns raw image bytes (not JSON)
|
||||
GET {{base}}/api/v1/live?prompt=A beautiful sunset&aspectRatio=16:9
|
||||
X-API-Key: {{apiKey}}
|
||||
Loading…
Reference in New Issue