DALL·E 2
Model Overview
An advanced AI system designed to generate high-quality images and artwork from textual descriptions. It builds upon its predecessor, DALL·E 1, utilizing improved techniques to create images that are more realistic and contextually accurate.
Setup your API Key
If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.
API Schema
The text prompt describing the content, style, or composition of the image to be generated.
The number of images to generate.
1
The size of the generated image.
1024x1024
Possible values: The format in which the generated images are returned.
url
Possible values: Successfully generated image
async function main() {
const response = await fetch('https://api.aimlapi.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'dall-e-2',
prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',
}),
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
}
main();
Successfully generated image
{
"status": "text",
"prompt": [
"text"
],
"model": "text",
"model_owner": "text",
"tags": {
"ANY_ADDITIONAL_PROPERTY": null
},
"num_returns": 1,
"args": {
"model": "text",
"prompt": "text",
"n": 1,
"steps": 1,
"size": "text"
},
"subjobs": [],
"output": {
"choices": [
{
"image_base64": "text"
}
]
}
}
Quick Example
Let's generate an image of the specified size using a simple prompt.
import requests
def main():
response = requests.post(
"https://api.aimlapi.com/v1/images/generations",
headers={
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
"Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
"Content-Type": "application/json",
},
json={
"prompt": "A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.",
"model": "dall-e-2",
"quality": "hd"
}
)
response.raise_for_status()
data = response.json()
print("Generation:", data)
if __name__ == "__main__":
main()
We obtained the following 1024x1024 image by running this code example:

"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
Last updated
Was this helpful?