Overview
This guide will help you make your first API call to ModelsLab and generate an AI image. By the end, you’ll have a working integration.Time to complete: 5 minutesWhat you’ll need:
- A ModelsLab account (sign up free)
- An API key (get one here)
Step 1: Get Your API Key
1
Log in to ModelsLab
Go to modelslab.com and log in to your account.
2
Navigate to API Keys
Open your API Keys Dashboard.
3
Create a New Key
Click Create New Key and copy the generated key.
Step 2: Make Your First API Call
Choose your preferred language and run the code:Step 3: Understanding the Response
Success Response
When your image is generated successfully:output to see your generated image!
Processing Response (Async)
For complex generations, you may receive a processing status:Key Parameters Explained
| Parameter | Description | Default |
|---|---|---|
key | Your API key (required) | - |
prompt | Text description of the image (required) | - |
model_id | AI model to use (e.g., “flux”, “sdxl”) | “flux” |
width | Image width in pixels (256-1024) | 512 |
height | Image height in pixels (256-1024) | 512 |
samples | Number of images to generate (1-4) | 1 |
num_inference_steps | Quality/detail level (20-50) | 30 |
guidance_scale | How closely to follow prompt (1-20) | 7.5 |
Pro Tips for Better Results
Write Detailed Prompts
Write Detailed Prompts
Be specific about what you want:
- ❌ “a dog”
- ✅ “A golden retriever puppy playing in autumn leaves, soft natural lighting, shallow depth of field, professional photography”
Use Style Keywords
Use Style Keywords
Add style modifiers to guide the output:
- “photorealistic”, “8k”, “detailed”
- “oil painting”, “watercolor”, “digital art”
- “cinematic lighting”, “studio photography”
Experiment with Guidance Scale
Experiment with Guidance Scale
- Lower (3-7): More creative, varied results
- Higher (8-15): Closer to your prompt, more literal
Choose the Right Model
Choose the Right Model
- flux: Best for photorealistic images
- sdxl: Great for artistic and stylized images
- Browse all models to find the perfect fit
Next Steps
Now that you’ve made your first API call, explore more:Image Generation
Explore all image generation options
Video Generation
Create AI-generated videos
Voice Cloning
Generate speech and clone voices
Image Editing
Edit and enhance images with AI
Troubleshooting
Invalid API Key Error
Invalid API Key Error
- Double-check your API key is copied correctly
- Ensure you’re including it in the
keyfield of the request body - Verify your key hasn’t been revoked in the dashboard
Rate Limit Exceeded
Rate Limit Exceeded
You’ve hit your queue limit. Wait for current requests to complete or upgrade your plan.
See Rate Limits for details.
Request Timeout
Request Timeout
Some generations take longer. Use the async pattern with the fetch endpoint to handle long-running requests.
Need help? Join our Discord community or contact [email protected].

