cURL
curl --request POST \ --url https://api.xtrix.workers.dev/v1/images/generations \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "dall-e-3", "prompt": "<string>" }'
{ "created": 123, "data": [ { "b64_json": "<string>", "revised_prompt": "<string>" } ] }
Generate images from text prompts
dall-e-3
256x256
512x512
1024x1024
1792x1024
1024x1792
curl https://api.xtrix.workers.dev/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "model": "dall-e-3", "prompt": "A serene landscape with mountains", "n": 1, "size": "1024x1024" }'
{ "created": 1677858242, "data": [ { "b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==", "revised_prompt": "A serene landscape featuring majestic mountains" } ] }
<img src="data:image/png;base64,{b64_json_value}" alt="Generated image" />
import base64 from PIL import Image import io image_data = base64.b64decode(response.data[0].b64_json) image = Image.open(io.BytesIO(image_data)) image.save("generated_image.png")
API key authentication
Successful response
The response is of type object.
object