Text to Image
Grok Imagine 2
Expressive visual synthesis engine specializing in dynamic stylized digital art, surreal concept renders, and bold creative visuals.
API Endpoint
POST https://lumozai.com/api/v4/run
Use this endpoint to run the model with your parameters. Authentication is required using your API key.
Sample Code (PHP cURL)
<?php
// API endpoint URL
$apiUrl = 'https://lumozai.com/api/v4/run';
// Your API key
$apiKey = 'YOUR_API_KEY';
// Model parameters
$params = [
'model_id' => 'grok-imagine-image-2',
'prompt' => '',
'image' => '',
'aspect_ratio' => '1:1',
'resolution' => '2k',
'quality' => 'medium',
];
// Initialize cURL session
$curl = curl_init();
// Set cURL options
curl_setopt_array($curl, [
CURLOPT_URL => $apiUrl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $params,
CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Authorization: Bearer ' . $apiKey
]
]);
// Execute the request
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Check for errors
if (curl_errno($curl)) {
echo 'cURL Error: ' . curl_error($curl);
} else {
// Process the response
$result = json_decode($response, true);
if ($httpCode == 200 && isset($result['success']) && $result['success']) {
// Handle successful response
echo "Model output: ";
print_r($result['data']['output']);
} else {
// Handle error response
echo "Error: " . ($result['message'] ?? 'Unknown error');
}
}
// Close cURL session
curl_close($curl);
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model_id | string | Required | The ID of the model to run (grok-imagine-image-2) |
| api_key | string | Required | Your API key for authentication (sent via Bearer token in the Authorization header) |
| prompt | string | Required | Text prompt describing the image you want to generate or edit. |
| image | string | Optional | Optional source image for image-to-image or editing tasks. |
| aspect_ratio | string | Optional | Aspect ratio of the generated image. |
| resolution | string | Optional | Target output resolution. |
| quality | string | Optional | Quality level (medium provides highest detail). |
Response Format
{
"success": true,
"data": {
"output": "https://lumozai.com/storage/outputs/image_12345.jpg"
}
}
Model Pricing
Pay only for what you run. Charges are deducted directly from your account balance with zero recurring commitments.
Rate per generation
$
0.035
/ generation
$35.00 per 1,000 generations
Cost Estimator
1,000 generations
Estimated Total
$35.00
Automatic instant refund if any run fails • Credits valid for 1 year