Appearance
Images
Generate and edit images using AI models.
Generate Image
POST https://api.3xcoder.com/v1/images/generationsCreate an image from a text prompt.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Text description of the image to generate |
model | string | No | Model to use (e.g., dall-e-3) |
n | integer | No | Number of images to generate (1-10). Default: 1 |
size | string | No | Image size: 256x256, 512x512, 1024x1024, 1792x1024, 1024x1792. Default: 1024x1024 |
quality | string | No | Image quality: standard or hd. Default: standard |
response_format | string | No | url or b64_json. Default: url |
style | string | No | vivid or natural. Default: vivid |
Response
json
{
"created": 1700000000,
"data": [
{
"url": "https://...",
"revised_prompt": "A detailed description..."
}
]
}Examples
bash
curl https://api.3xcoder.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "dall-e-3",
"prompt": "A futuristic city skyline at sunset, digital art",
"n": 1,
"size": "1024x1024"
}'python
from openai import OpenAI
client = OpenAI(
api_key="your-api-key",
base_url="https://api.3xcoder.com/v1"
)
response = client.images.generate(
model="dall-e-3",
prompt="A futuristic city skyline at sunset, digital art",
n=1,
size="1024x1024"
)
print(response.data[0].url)javascript
const response = await fetch('https://api.3xcoder.com/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`
},
body: JSON.stringify({
model: 'dall-e-3',
prompt: 'A futuristic city skyline at sunset, digital art',
n: 1,
size: '1024x1024'
})
})
const data = await response.json()
console.log(data.data[0].url)Edit Image
POST https://api.3xcoder.com/v1/images/editsEdit an existing image using a text prompt and an optional mask.
Request Body (multipart/form-data)
| Parameter | Type | Required | Description |
|---|---|---|---|
image | file | Yes | The image to edit (PNG, max 4MB) |
prompt | string | Yes | Description of the desired edit |
mask | file | No | Mask image indicating areas to edit (transparent = edit area) |
model | string | No | Model to use |
n | integer | No | Number of images. Default: 1 |
size | string | No | Image size. Default: 1024x1024 |
response_format | string | No | url or b64_json. Default: url |
Example
bash
curl https://api.3xcoder.com/v1/images/edits \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F image="@original.png" \
-F mask="@mask.png" \
-F prompt="Add a rainbow in the sky" \
-F n=1 \
-F size="1024x1024"