AICredits logo
API

Image Generation

Generate images from text prompts using DALL-E and other models. OpenAI-compatible /v1/images/generations endpoint with INR billing.

Use this page with an AI assistant

Opens a new chat with this docs URL and the correct AICredits base URLs.

Generate images from text prompts using the OpenAI-compatible /v1/images/generations endpoint. Costs are charged in INR from your wallet like any other request.

Overview

The image generation endpoint follows the OpenAI Images API format. Use the standard OpenAI SDK — just point it at the AICredits base URL. Images are returned as URLs or base64-encoded data.

Image generation is billed per image based on the model, size, and quality selected. Costs are converted from USD to INR using the live forex rate.

Generate an Image

from openai import OpenAI

client = OpenAI(
    base_url="https://api.aicredits.in/v1",
    api_key="sk-your-key-here",
)

response = client.images.generate(
    model="dall-e-3",
    prompt="A serene view of the Indian Himalayas at sunrise, photorealistic, 4K",
    size="1024x1024",
    quality="standard",
    n=1,
)

image_url = response.data[0].url
print(image_url)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.aicredits.in/v1",
  apiKey: "sk-your-key-here",
});

const response = await client.images.generate({
  model: "dall-e-3",
  prompt: "A serene view of the Indian Himalayas at sunrise, photorealistic, 4K",
  size: "1024x1024",
  quality: "standard",
  n: 1,
});

const imageUrl = response.data[0].url;
console.log(imageUrl);
curl https://api.aicredits.in/v1/images/generations \
  -H "Authorization: Bearer sk-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "A serene view of the Indian Himalayas at sunrise, photorealistic, 4K",
    "size": "1024x1024",
    "quality": "standard",
    "n": 1
  }'

Parameters

ParameterTypeDescription
modelstringImage model to use. Default: dall-e-3
promptstring (required)Text description (max 4000 chars for DALL-E 3)
nintegerNumber of images. DALL-E 3 supports only 1
sizestringImage dimensions. See Sizes & Quality below.
qualitystringstandard or hd. HD costs more but has finer detail.
response_formatstringurl (default) or b64_json
stylestringvivid (hyper-real) or natural (more realistic)

Response Format

Image generation response
{
  "created": 1709123456,
  "data": [
    {
      "url": "https://oaidalleapiprodscus.blob.core.windows.net/...",
      "revised_prompt": "A serene panoramic view of the Indian Himalayas..."
    }
  ]
}

revised_prompt

DALL-E 3 may revise your prompt to add safety mitigations or improve image quality. The revised_prompt field shows what was actually used.

To get the image as base64 (useful for processing without hosting):

Save image to file
import base64
from openai import OpenAI

client = OpenAI(
    base_url="https://api.aicredits.in/v1",
    api_key="sk-your-key-here",
)

response = client.images.generate(
    model="dall-e-3",
    prompt="A minimalist logo for a tech startup",
    response_format="b64_json",
)

image_data = base64.b64decode(response.data[0].b64_json)
with open("logo.png", "wb") as f:
    f.write(image_data)

Sizes & Quality

DALL-E 3 supports the following size and quality combinations:

SizeQualityBest For
1024×1024standardGeneral purpose, square images
1024×1024hdDetailed artwork, fine textures
1792×1024standard / hdLandscape / widescreen images
1024×1792standard / hdPortrait / tall images

Billing

Image generation costs are fixed per image (not per token):

ModelSizeCost
DALL-E 31024×1024Standard: ~₹3.5 · HD: ~₹7
DALL-E 31792×1024 / 1024×1792Standard: ~₹5 · HD: ~₹10
DALL-E 2256–1024px~₹0.7–₹1.5 depending on size

Exact INR prices depend on the live USD/INR rate. See the Pricing page for the full cost formula.

Error Handling

StatusCause
400Invalid parameters (unsupported size, bad model name)
400Prompt violates content policy
402Insufficient wallet balance — top up at Dashboard → Billing
429Rate limit exceeded — image generation counts toward your RPM limit

On this page