For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Login
DocumentationAPI Reference
DocumentationAPI Reference
  • Getting Started
    • Overview
    • Developer Quickstart
  • Models
    • ASI:One Models
    • Model Selection
    • asi1-ultra
    • asi1-mini
  • Build with ASI:One
    • Tool Calling
    • OpenAI Compatibility
    • Image Generation
    • Agentic LLM
    • Structured Data
  • Tutorials
    • Agent Chat Protocol
Login
LogoLogo
On this page
  • Overview
  • Quick Start
  • API Reference
  • Request Parameters
  • Supported Image Sizes
  • Response Format
  • Examples
  • Basic Image Generation
  • Landscape Image Generation
  • Portrait Image Generation
  • Error Handling
  • Common Error Responses
  • Example Error Response
  • Best Practices
  • Writing Effective Prompts
  • Example Prompts
  • Rate Limiting
  • Image Quality Tips
  • Integration Examples
  • Batch Image Generation
Build with ASI:One

Image Generation

Was this page helpful?
Previous

Agentic LLM

Next
Built with

Generate high-quality images from text descriptions using ASI:One’s advanced AI models.

Generate high-quality images from text descriptions using ASI:One’s image generation API. This feature allows you to create custom images based on natural language prompts.


Overview

The image generation API accepts text prompts and returns generated images in various sizes. The API supports different image dimensions and uses advanced AI models to create realistic and creative images.

Endpoint: POST https://api.asi1.ai/v1/image/generate


Quick Start

cURL
Python
JavaScript
$curl -X POST https://api.asi1.ai/v1/image/generate \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer $ASI_ONE_API_KEY" \
> -d '{
> "prompt": "A futuristic city skyline at sunset with flying cars",
> "size": "1024x1024",
> "model": "asi1-mini"
> }'

API Reference

Request Parameters

ParameterTypeRequiredDescriptionDefault
promptstringYesText description of the image to generate-
sizestringNoImage dimensions"1024x1024"
modelstringNoImage generation model to use"asi1-mini"

Supported Image Sizes

SizeDescriptionUse Case
1024x1024Square imageGeneral purpose, avatars, icons
1792x1024Landscape imageWallpapers, banners, wide scenes
1024x1792Portrait imageMobile wallpapers, tall scenes

Response Format

The API returns a JSON response containing the generated image as a base64-encoded data URL.

Success Response:

  • Status Code: 200 OK
  • Content-Type: application/json
  • Body: JSON object with image data
1{
2 "status": 1,
3 "message": "Success",
4 "created": 1753792957496,
5 "images": [
6 {
7 "url": "data:image/png;base64,iVBORw0KGgoAAA... (truncated)"
8 }
9 ]
10}

Examples

Basic Image Generation

cURL
Python
JavaScript
$curl -X POST https://api.asi1.ai/v1/image/generate \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer $ASI_ONE_API_KEY" \
> -d '{
> "prompt": "A serene mountain landscape with snow-capped peaks and a crystal clear lake"
> }'

Landscape Image Generation

cURL
Python
JavaScript
$curl -X POST https://api.asi1.ai/v1/image/generate \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer $ASI_ONE_API_KEY" \
> -d '{
> "prompt": "A beautiful sunset over the ocean with palm trees silhouetted against the sky",
> "size": "1792x1024"
> }'

Portrait Image Generation

cURL
Python
JavaScript
$curl -X POST https://api.asi1.ai/v1/image/generate \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer $ASI_ONE_API_KEY" \
> -d '{
> "prompt": "A majestic waterfall cascading down a cliff face with mist and rainbows",
> "size": "1024x1792"
> }'

Error Handling

Common Error Responses

Status CodeError TypeDescription
400Bad RequestInvalid parameters or malformed request
401UnauthorizedInvalid or missing API key
404Not FoundEndpoint not found
500Internal Server ErrorServer-side error

Example Error Response

1{
2 "error": {
3 "message": "Invalid prompt provided",
4 "type": "invalid_request_error",
5 "code": 400
6 }
7}

Best Practices

Writing Effective Prompts

  1. Be Specific: Include details about style, mood, lighting, and composition
  2. Use Descriptive Language: Mention colors, textures, and artistic styles
  3. Specify Perspective: Include camera angles and viewpoints
  4. Add Context: Provide background information and setting details

Example Prompts

CategoryGood PromptPoor Prompt
Landscape”A misty mountain valley at dawn with golden sunlight filtering through pine trees""mountains”
Portrait”A professional headshot of a confident businesswoman in a modern office setting""person”
Abstract”A vibrant abstract painting with swirling colors in the style of Van Gogh""abstract art”

Rate Limiting

  • The API applies rate limits based on your plan
  • Monitor your usage to avoid hitting limits
  • Implement exponential backoff for retries

Image Quality Tips

  1. Use High-Resolution Sizes: Choose larger sizes for better quality
  2. Provide Detailed Prompts: More specific prompts yield better results
  3. Experiment with Different Models: Try different models for various styles
  4. Consider Aspect Ratios: Choose appropriate sizes for your use case

Integration Examples

Batch Image Generation

1import asyncio
2import aiohttp
3
4async def generate_multiple_images(prompts):
5 API_KEY = os.getenv("ASI_ONE_API_KEY")
6 headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
7
8 async with aiohttp.ClientSession() as session:
9 tasks = []
10 for prompt in prompts:
11 payload = {"prompt": prompt, "size": "1024x1024"}
12 task = session.post(
13 "https://api.asi1.ai/v1/image/generate",
14 headers=headers,
15 json=payload
16 )
17 tasks.append(task)
18
19 responses = await asyncio.gather(*tasks)
20 return [await resp.json() for resp in responses]
21
22# Generate multiple images concurrently
23prompts = [
24 "A cyberpunk city street at night",
25 "A peaceful forest clearing with sunlight",
26 "A futuristic spaceship in orbit"
27]
28
29results = await generate_multiple_images(prompts)
30for i, result in enumerate(results):
31 print(f"Image {i+1}: {result['images'][0]['url']}")