Skip to content

Images

Generate and edit images using AI models.

Generate Image

POST https://api.3xcoder.com/v1/images/generations

Create an image from a text prompt.

Request Body

ParameterTypeRequiredDescription
promptstringYesText description of the image to generate
modelstringNoModel to use (e.g., dall-e-3)
nintegerNoNumber of images to generate (1-10). Default: 1
sizestringNoImage size: 256x256, 512x512, 1024x1024, 1792x1024, 1024x1792. Default: 1024x1024
qualitystringNoImage quality: standard or hd. Default: standard
response_formatstringNourl or b64_json. Default: url
stylestringNovivid 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/edits

Edit an existing image using a text prompt and an optional mask.

Request Body (multipart/form-data)

ParameterTypeRequiredDescription
imagefileYesThe image to edit (PNG, max 4MB)
promptstringYesDescription of the desired edit
maskfileNoMask image indicating areas to edit (transparent = edit area)
modelstringNoModel to use
nintegerNoNumber of images. Default: 1
sizestringNoImage size. Default: 1024x1024
response_formatstringNourl 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"

3xCoder — Unified AI API Endpoint