This endpoint allows you to generate a high-quality image based on a descriptive text prompt.
Its similar to the chat POST request - just that response.choices.message.content
contains the URL for image generated
API Key of the from Bearer <api_key>
, you can get it from here .
Request
The model to use for image generation, e.g., “blackboxai/black-forest-labs/flux-pro”
An array of message objects. For image generation, provide a single message with role “user” and content as the descriptive text prompt. The role of the message author. One of system
, user
, assistant
, or tool
.
The prompt for the image generation.
Tips for Better Results
Be specific and descriptive in your prompts.
Include details about style, lighting, composition, and mood.
Mention specific artistic styles or artists if desired.
curl -X POST https://api.blackbox.ai/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "blackboxai/black-forest-labs/flux-pro",
"messages": [
{
"role": "user",
"content": "tesla car"
}
]
}'
{
"id" : "chatcmpl-1757147957" ,
"created" : 1757147957 ,
"model" : "black-forest-labs/flux-pro:1e237aa703bf3a8ab480d5b595563128807af649c50afc0b4f22a9174e90d1d6" ,
"object" : "chat.completion" ,
"system_fingerprint" : "None" ,
"choices" :[
{
"finish_reason" : "stop" ,
"index" : 0 ,
"message" :{
"content" : "https://replicate.delivery/xezq/ZDBFJ3anae13UKSmAsDC9eUV1zzDI4XY3dehqUBmUl1rp0kqA/tmpo0625f2a.webp" ,
"role" : "assistant" ,
"tool_calls" : "None" ,
"function_call" : "None"
}
}
],
"usage" :{
"completion_tokens" : 0 ,
"prompt_tokens" : 0 ,
"total_tokens" : 0 ,
"completion_tokens_details" : "None" ,
"prompt_tokens_details" : "None"
}
}