Step 3: Generate Your First Image (Text-to-Image)
Now that you have authenticated your requests, it’s time to generate your first image. While Scenario offers standard text-to-image endpoints, high-performance third-party models (such as Flux or Imagen) utilize a Custom Generation workflow.
Unlike standard generation, this process is asynchronous. You will submit a request to start a "job," receive a Job ID, and then poll the API to retrieve your final image asset.
1. Initiate the Generation
To generate an image, you will send a POST request to the custom generation endpoint. You must specify a modelId (e.g., model_flux-1-dev or model_imagen4-ultra) in the URL.
The Request
- Endpoint:
POST https://api.cloud.scenario.com/v1/generate/custom/{modelId} - Key Parameters:
prompt: A detailed description of the image you want.aspectRatio: The desired dimensions (e.g.,"1:1","16:9","9:16").
Example cURL:
curl -X POST "https://api.cloud.scenario.com/v1/generate/custom/model_flux-1-dev" \
-u "YOUR_API_KEY:YOUR_API_SECRET" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cinematic shot of a futuristic neon city in the rain, hyper-realistic, 8k",
"aspectRatio": "16:9"
}'
The Response:
The API will return a job object containing a jobId.
{
"job": {
"id": "job_abcd1234efgh",
"status": "queued"
}
}
2. Poll for the Result
Because the image is being processed in the cloud, you need to check the status of your jobId until it is completed.
Endpoint: GET https://api.cloud.scenario.com/v1/jobs/{jobId}
Example Request:
curl -u "YOUR_API_KEY:YOUR_API_SECRET" \
"https://api.cloud.scenario.com/v1/jobs/job_abcd1234efgh"
Keep polling every 2–3 seconds until the status changes from "queued" or "in-progress" to "success".
3. Retrieve Your Image
Once the job status is "success", the response will include an images array (or result object) containing the URL of your generated asset.
Success Response Snippet:
{
"job": {
"id": "job_abcd1234efgh",
"status": "success",
"result": {
"images": [
{
"url": "https://media.scenario.com/assets/asset_xyz123.png"
}
]
}
}
}
What’s Next?
Now that you've successfully generated an image using a third-party model, you can:
- Explore advanced parameters: Check the specific Parameters Reference for the model you are using.
- List available models: Use
GET /v1/modelsto see which other models you can use. - Train your own: Move to Step 4 to learn how to train a model on your own specific art style.
Updated 2 days ago