SDXL, developed by Stability AI, is an advanced text-to-image model released in July 2023, offering enhanced image generation capabilities.
The Image Generation or Text-To-Image API endpoint allows you to generate an image from a textual description (prompt).
Image Generation refers to the process of automatically generating visual content (such as images) based on textual descriptions provided as input.
AI Endpoints makes it easy, with ready-to-use inference APIs. Discover how to use them:
This Image Generation API is based on an Open-Source model (Stable Diffusion XL): stabilityai/stable-diffusion-xl-base-1.0. It takes text as input (the prompt) and returns the corresponding image in color.
Model configuration:
The Stable Diffusion XL (SDXL) endpoint offers you an optimized way to generate an image from:
Learn how to use them with the following examples:
Consider changing the your-access-token by your token value before running the following command:
curl -X POST "https://stable-diffusion-xl.endpoints.kepler.ai.cloud.ovh.net/api/text2image" \
-H 'accept: application/octet-stream' \
-H 'content-type: application/json' \
-H 'Authorization: Bearer <your-access-token>' \
-d '{"negative_prompt":"Ugly, unrealistic","prompt":"Photo of a hippopotamus dressed suit and tie sitting in a coffee shop with a matcha latte, award winning photography, Elke vogelsang, 4k"}' \
--output -Warning:
First install the requests library and pillow dependencies:
pip install requests pillowNext, export your access token to the OVH_AI_ENDPOINTS_ACCESS_TOKEN environment variable:
export OVH_AI_ENDPOINTS_ACCESS_TOKEN=<your-access-token>If you do not have an access token key yet, follow the instructions in the AI Endpoints – Getting Started.
Finally, run the following Python code:
import os
import io
import base64
import requests
from PIL import Image
# You can use the model dedicated URL
url = "https://stable-diffusion-xl.endpoints.kepler.ai.cloud.ovh.net/api/text2image"
# Or our unified endpoint for easy model switching with optimal OpenAI compatibility
url = "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1/images/generations"
# Set prompts (negative prompt is not used when using OpenAI compatibility)
prompt = "Photo of a hippopotamus dressed suit and tie sitting in a coffee shop with a matcha latte, award winning photography, Elke vogelsang, 4k"
negative_prompt = "Ugly, unrealistic"
headers = {
"Authorization": f"Bearer {os.getenv('OVH_AI_ENDPOINTS_ACCESS_TOKEN')}",
}
if "oai.endpoints" in url:
# OpenAI-compatible endpoint
headers["Content-Type"] = "application/json"
payload = {
"model": "stabilityai/stable-diffusion-xl-base-1.0",
"prompt": prompt,
"size": "1024x1024",
}
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
resp_json = response.json()
img_b64 = resp_json["data"][0]["b64_json"]
img_bytes = base64.b64decode(img_b64)
img = Image.open(io.BytesIO(img_bytes))
img.show()
else:
print("Error:", response.status_code, response.text)
else:
# Raw endpoint
headers["accept"] = "application/octet-stream"
headers["content-type"] = "application/json"
payload = {
"prompt": prompt,
"negative_prompt": negative_prompt,
}
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
img = Image.open(io.BytesIO(response.content))
img.show()
else:
print("Error:", response.status_code, response.text)You will obtain the following (1024x1024) image:

When using AI Endpoints, the following rate limits apply:
If you exceed this limit, a 429 error code will be returned.
If you require higher usage, please get in touch with us to discuss increasing your rate limits.
For a broader overview of AI Endpoints, explore the full AI Endpoints Documentation.
Reach out to our support team or join the OVHcloud Discord #ai-endpoints channel to share your questions, feedback, and suggestions for improving the service, to the team and the community.
New to AI Endpoints? This guide walks you through everything you need to get an access token, call AI models, and integrate AI APIs into your apps with ease.
Start TutorialExplore what AI Endpoints can do. This guide breaks down current features, future roadmap items, and the platform's core capabilities so you know exactly what to expect.
Start TutorialRunning into issues? This guide helps you solve common problems on AI Endpoints, from error codes to unexpected responses. Get quick answers, clear fixes, and helpful tips to keep your projects running smoothly.
Start Tutorial