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
Section titled โ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
Section titled โ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
Section titled โ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
Section titled โ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?
Section titled โ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.