POST /v1/images/generations
Create an image from a text prompt.
- Method: POST
- Path:
/v1/images/generations
- Auth: Bearer token in
Authorization
header - Content-Type:
application/json
Request parameters
model
(string, required): Image generation model (e.g.,flux-1-schnell
).prompt
(string, required, 1..8192): The text prompt for image generation.quality
(string | null, optional): Provider-specific quality preset.size
(string | null, optional): Target image resolution (e.g.,1024x1024
).n
(integer ≥ 1 | null, optional): Number of images to generate.response_format
(enum:url
|b64_json
, defaulturl
): Output format per image.
Example requests
- Python
- Node.js
- cURL
from openai import OpenAI
client = OpenAI(base_url="https://api.naga.ac/v1", api_key="YOUR_API_KEY")
resp = client.images.generate(
model="flux-1-schnell",
prompt="A white siamese cat",
size="1024x1024",
n=1,
response_format="url", # or "b64_json"
)
print(resp.data) # array of images with url or b64_json
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.naga.ac/v1", apiKey: "YOUR_API_KEY" });
const resp = await client.images.generate({
model: "flux-1-schnell",
prompt: "A white siamese cat",
size: "1024x1024",
n: 1,
response_format: "url", // or "b64_json"
});
console.log(resp.data);
curl https://api.naga.ac/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-1-schnell",
"prompt": "A white siamese cat",
"size": "1024x1024",
"n": 1,
"response_format": "url"
}'
Response
Returns a JSON object with a data
array of generated images. Each item contains either:
url
whenresponse_format = "url"
, orb64_json
whenresponse_format = "b64_json"
.