Lunos

Documentation

🖼️ Image Generation

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.

How to Generate Images (Step-by-Step)

  1. Choose your preferred client library or use cURL for direct API calls.
  2. Set your API key and endpoint URL.
  3. Configure the request parameters (prompt, model, size, quality, etc.).
  4. Send the request and receive the generated image(s).

Example: Using OpenAI Library

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);
Parameters:
  • 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).

Example: Using Lunos Client

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);
Parameters:
  • prompt: The text prompt for the image.
  • model: Model ID (e.g., openai/dall-e-3).
  • size: Image size.
  • quality: Image quality.

Example: Using cURL

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.

Example Response

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.

Best Practices & Tips

  • Use response_format: 'b64_json' for base64-encoded images.
  • Choose the right model and quality for your use case (see Model Discovery).
  • Be mindful of image size and cost for large batch generations.

Troubleshooting

  • Authentication error: Verify your API key and permissions.
  • Unexpected output: Check your model and prompt parameters.
  • Request issues: Ensure your request payload matches the API specification.