The Image Generation API allows you to create images from text prompts using advanced models like DALL-E, Google Imagen, and more. Customize image size, quality, and output format for your creative or business needs.
Note: You need an API key to use this endpoint. See the Quickstart Guide to get started.
prompt
, model
, size
, quality
, etc.).Generate an image using the OpenAI Node.js library:
1const response = await openai.images.generate({
2 model: 'dall-e-3',
3 prompt: 'A cute robot playing with a cat',
4 n: 1,
5 size: '1024x1024',
6 quality: 'hd',
7});
8console.log(response.data[0].url);
model
: The image generation model to use (e.g., dall-e-3
).prompt
: The text prompt describing the image.n
: Number of images to generate.size
: Image size (e.g., 1024x1024
).quality
: Image quality (e.g., hd
).Generate an image using the official Lunos client:
1const client = new LunosClient({ apiKey: 'YOUR_API_KEY' });
2const response = await client.image.generate({
3 prompt: 'A cute robot playing with a cat',
4 model: 'openai/dall-e-3',
5 size: '1024x1024',
6 quality: 'hd',
7 appId: 'my-image-app-v1.0',
8});
9console.log(response.data[0].url);
prompt
: The text prompt for the image.model
: Model ID (e.g., openai/dall-e-3
).size
: Image size.quality
: Image quality.Direct API call for image generation:
1curl -X POST https://api.lunos.tech/v1/image/generations -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_API_KEY" -H "X-App-ID: my-image-generator-v1.0" -d '{
2 "model": "openai/dall-e-3",
3 "prompt": "A cute robot playing with a cat",
4 "n": 1,
5 "size": "1024x1024",
6 "quality": "hd",
7 "response_format": "url"
8 }'
App Tracking: The X-App-ID
header allows you to track image generation usage per application. This helps with analytics, billing, and performance monitoring across different apps.
1{
2 "created": 1623168000,
3 "data": [
4 {
5 "url": "https://example.com/image.png"
6 }
7 ],
8 "model": "openai/dall-e-3",
9 "cost": 0.08
10}
Important: Your API key is sensitive. Never share it publicly or commit it to version control.
response_format: 'b64_json'
for base64-encoded images.model
and prompt
parameters.No headings found on this page.