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
post
Authorizations
Body
modelundefined · enumRequiredPossible values:
promptstring · max: 1000Required
The text prompt describing the content, style, or composition of the image to be generated.
nnumber · min: 1 · max: 10OptionalDefault:
The number of images to generate.
1
sizestring · enumOptionalDefault:
The size of the generated image.
1024x1024
Possible values: response_formatstring · enumOptionalDefault:
The format in which the generated images are returned.
url
Possible values: Responses
201Success
post
POST /v1/images/generations HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Content-Type: application/json
Accept: */*
Content-Length: 85
{
"model": "dall-e-2",
"prompt": "text",
"n": 1,
"size": "1024x1024",
"response_format": "url"
}
201Success
No content
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?