Overview
The AI Visual Studio API enables you to generate stunning AI images and videos programmatically. Build powerful integrations into your applications with our RESTful API.
Base URL
https://aivisualstudio.co/api/v1Format
JSON (application/json)Authentication
Bearer Token (API Key)Quick Start
- 1Get an API Key
Create an API key from your account dashboard
- 2Make your first request
Use the code examples below to generate your first image
- 3Set up webhooks (optional)
Receive real-time notifications when generations complete
Authentication
All API requests require authentication using an API key. Include your key in the Authorization header as a Bearer token.
Authorization: Bearer avs_live_your_api_key_hereNever expose your API key in client-side code or public repositories. Use environment variables or secret management tools.
API Key Scopes
API keys can have different permission scopes:
| Scope | Description |
|---|---|
read | Read generations, models, and account info |
generate:image | Create image generations |
generate:video | Create video generations |
webhooks | Manage webhooks |
Rate Limits
API requests are rate limited to 60 requests per minute per API key. This limit ensures fair resource distribution across all API consumers.
Rate Limit Headers
Every API response includes headers showing your current rate limit status:
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests allowed per window |
X-RateLimit-Remaining | Requests remaining in current window |
X-RateLimit-Reset | Unix timestamp when the window resets |
If you exceed your rate limit, you'll receive a 429 Too Many Requests response. Wait until the reset time before making more requests.
Generate Image
Create AI-generated images from text prompts.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Text description of the image to generate |
model | string | No | Model ID (default: prunaai/z-image-turbo). Use GET /api/v1/models to list all available models. |
aspect_ratio | string | No | Image aspect ratio: 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3 |
output_format | string | No | Output image format: webp, png, jpg (default: webp) |
webhook_url | string | No | URL to receive a webhook when generation completes |
Example Request
curl -X POST https://aivisualstudio.co/api/v1/generate/image \
-H "Authorization: Bearer avs_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A futuristic city at sunset, cyberpunk style",
"model": "prunaai/z-image-turbo",
"aspect_ratio": "16:9"
}'Response
{
"id": "gen_abc123def456",
"status": "processing",
"prompt": "A futuristic city at sunset, cyberpunk style",
"model": "prunaai/z-image-turbo",
"type": "image",
"credits_charged": 5,
"created_at": "2025-01-09T12:00:00Z"
}Generate Video
Create AI-generated videos from text prompts or images.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Text description of the video to generate |
model | string | No | Model ID (default: minimax/hailuo-2.3-fast). Use GET /api/v1/models?type=video to list all available models. |
aspect_ratio | string | No | Video aspect ratio: 16:9, 9:16, 1:1, 4:3, 3:4 (default: 16:9) |
duration | integer | No | Video duration in seconds, 1-10 (default: 5) |
first_frame_image | string | No | Source image URL for image-to-video generation |
webhook_url | string | No | URL to receive a webhook when generation completes |
Example Request
curl -X POST https://aivisualstudio.co/api/v1/generate/video \
-H "Authorization: Bearer avs_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A spaceship flying through an asteroid field",
"model": "minimax/hailuo-2.3-fast",
"duration": 5
}'List Generations
Retrieve a list of your generations with pagination support.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
type | string | Filter by type: image or video |
status | string | Filter by status: processing, completed, failed |
limit | integer | Number of results (default: 20, max: 100) |
offset | integer | Pagination offset |
Example Request
curl -X GET "https://aivisualstudio.co/api/v1/generations?limit=10&type=image" \
-H "Authorization: Bearer avs_live_your_api_key"Get Single Generation
Retrieve details of a specific generation by ID.
Models
List all available AI models for image and video generation.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
type | string | Filter by type: image or video |
Response Example
{
"data": [
{
"id": "prunaai/z-image-turbo",
"name": "Z-Image Turbo",
"type": "image",
"credits_per_generation": 5,
"description": "Fast image generation",
"category": "image-generation"
},
{
"id": "minimax/hailuo-2.3-fast",
"name": "Hailuo 2.3 Fast",
"type": "video",
"credits_per_generation": 450,
"description": "Fast video generation",
"category": "video-generation"
}
],
"total": 18
}Webhooks
Receive real-time notifications when your generations complete or fail. Webhooks use HMAC-SHA256 signatures for security.
Create Webhook
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | HTTPS URL to receive webhook events |
events | array | No | Events to subscribe to (default: all) |
Available Events
generation.completed- Generation finished successfullygeneration.failed- Generation failed
Example: Create Webhook
curl -X POST https://aivisualstudio.co/api/v1/webhooks \
-H "Authorization: Bearer avs_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-app.com/webhooks/photoverse",
"events": ["generation.completed", "generation.failed"]
}'Webhook Payload
{
"event": "generation.completed",
"data": {
"id": "gen_abc123def456",
"type": "image",
"status": "completed",
"prompt": "A futuristic city at sunset",
"output_url": "https://cdn.example.com/image.png",
"created_at": "2025-01-09T12:00:00Z",
"completed_at": "2025-01-09T12:00:15Z"
},
"created_at": "2025-01-09T12:00:15Z"
}Verifying Webhook Signatures
Every webhook request includes an X-Webhook-Signature header that you should verify to ensure the request came from AI Visual Studio.
X-Webhook-Signature: t=1704801600,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bdVerification Example
import crypto from 'crypto';
function verifyWebhookSignature(payload, signature, secret) {
const [timestamp, hash] = signature.split(',').map(part => {
const [key, value] = part.split('=');
return value;
});
// Verify timestamp is recent (within 5 minutes)
const now = Math.floor(Date.now() / 1000);
if (Math.abs(now - parseInt(timestamp)) > 300) {
return false; // Replay attack protection
}
const expectedHash = crypto
.createHmac('sha256', secret)
.update(`${timestamp}.${JSON.stringify(payload)}`)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(hash),
Buffer.from(expectedHash)
);
}
// In your webhook handler
app.post('/webhooks/photoverse', (req, res) => {
const signature = req.headers['x-webhook-signature'];
if (!verifyWebhookSignature(req.body, signature, WEBHOOK_SECRET)) {
return res.status(401).send('Invalid signature');
}
// Process the webhook
const { event, data } = req.body;
console.log('Received event:', event, data);
res.status(200).send('OK');
});Other Webhook Endpoints
/api/v1/webhooksList all webhooks/api/v1/webhooks/:idUpdate a webhook/api/v1/webhooks/:idDelete a webhookAPI Keys
Manage your API keys programmatically. These endpoints use web session authentication (cookie-based) rather than API key authentication.
API key management endpoints require you to be logged in via the web interface. They cannot be accessed with an API key.
/api/v1/keysCreate a new API key/api/v1/keysList all your API keys/api/v1/keys/:idRevoke an API keyCreate API Key
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the API key |
scopes | array | No | Permission scopes (default: ["read"]) |
ip_allowlist | array | No | Allowed IP addresses |
expires_at | string | No | Expiration date (ISO 8601) |
Error Handling
The API uses standard HTTP status codes and returns detailed error information in JSON format.
Error Response Format
{
"error": {
"code": "insufficient_credits",
"message": "You need 5 credits but only have 2",
"details": {
"required": 5,
"available": 2
}
}
}Error Codes
| Code | HTTP Status | Description |
|---|---|---|
missing_api_key | 401 | No API key provided in request |
invalid_api_key | 401 | API key is invalid or revoked |
expired_api_key | 401 | API key has expired |
insufficient_scope | 403 | API key doesn't have required permissions |
ip_not_allowed | 403 | Request from unauthorized IP address |
insufficient_credits | 403 | Not enough credits for this operation |
rate_limited | 429 | Too many requests, please slow down |
invalid_request | 400 | Invalid request parameters |
not_found | 404 | Requested resource not found |
internal_error | 500 | Unexpected server error |
