Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.samuraiapi.in/llms.txt

Use this file to discover all available pages before exploring further.

Image Generation

Create an image from a text prompt using various state-of-the-art models. Our API is fully compatible with the OpenAI Image Generation schema.

Endpoint

POST https://api.samuraiapi.in/v1/images/generations

Request Body

model
string
required
The model ID to use for image generation.Available models include:
  • flux-schnell (Fast, high quality)
  • flux-1.1-pro (Professional grade)
  • dall-e-3 (OpenAI’s latest)
  • ideogram-v3 (Excellent for text in images)
  • imagen-3 (Google’s latest)
prompt
string
required
A text description of the desired image(s). The maximum length is 1000 characters.
n
integer
default:1
The number of images to generate. Must be between 1 and 10.
size
string
default:"1024x1024"
The size of the generated images. Options: 256x256, 512x512, 1024x1024.
response_format
string
default:"url"
The format in which the generated images are returned. Must be one of url or b64_json.
user
string
A unique identifier for the end-user, for abuse monitoring.

Response

created
integer
Unix timestamp of when the generation was created
data
array
An array of image objects. Each object contains:
  • url (string): The URL of the generated image (if response_format is url)
  • b64_json (string): The base64-encoded JSON of the generated image (if response_format is b64_json)
  • revised_prompt (string): The prompt as revised by the model (if applicable)

Examples

from openai import OpenAI

client = OpenAI(
    api_key="sk-samurai-...",
    base_url="https://api.samuraiapi.in/v1"
)

response = client.images.generate(
    model="flux-1.1-pro",
    prompt="A futuristic samurai warrior in a neon-lit cyberpunk city, high detail, 8k resolution",
    n=1,
    size="1024x1024"
)

print(response.data[0].url)

Error Responses

StatusError TypeDescription
400invalid_request_errorMissing required field or invalid parameter
401authentication_errorInvalid API key
404not_found_errorModel not found
429rate_limit_errorRate limit exceeded
500server_errorInternal server error