Skip to main content
NexLLM’s image endpoints let you generate brand-new images from natural language descriptions and edit or modify existing images. Both endpoints are OpenAI-compatible, so any code written for the DALL·E API works directly with NexLLM by changing only the base URL.

Endpoints

EndpointPathDescription
Image GenerationPOST /v1/images/generationsGenerate new images from a text prompt
Image EditingPOST /v1/images/editsEdit or modify an existing image

Image Generation Parameters

model
string
required
The image generation model to use. Example: dall-e-3, dall-e-2. For Imagen models on Vertex AI, ensure your API key is assigned to a group that includes them (see the note below).
prompt
string
required
A text description of the image you want to generate. More detailed prompts generally produce better results. Maximum length varies by model.
n
integer
The number of images to generate. Defaults to 1. dall-e-3 supports only n=1; dall-e-2 supports up to 10.
size
string
The resolution of the generated image. Supported values depend on the model. Common options: 256x256, 512x512, 1024x1024, 1792x1024, 1024x1792. Defaults to 1024x1024.

Code Example

from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxxxxxxxxxxxx",
    base_url="https://www.nexllm.ai/v1"
)

response = client.images.generate(
    model="dall-e-3",
    prompt="A futuristic cityscape at sunset",
    n=1,
    size="1024x1024"
)

print(response.data[0].url)

Image Editing Example

To edit an existing image, send a POST request to /v1/images/edits with the original image file and a prompt describing the change you want:
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxxxxxxxxxxxx",
    base_url="https://www.nexllm.ai/v1"
)

with open("original.png", "rb") as image_file:
    response = client.images.edit(
        model="dall-e-2",
        image=image_file,
        prompt="Add a rainbow in the sky",
        n=1,
        size="1024x1024"
    )

print(response.data[0].url)
To access Imagen models (Google’s image generation models on Vertex AI), your API key must be assigned to a channel group that includes them — for example, the gemini-vertex group. Check the channel groups overview to confirm which models are available under your key.