Generate images from text prompts
POST
/v1/images/generationsPOST
/v1/images/generationsYour instance endpoint, shown on the instance page in the dashboard. Each instance has its own host; there is no shared API host.
Request Body
| Property | Type | Required | Description |
|---|---|---|---|
prompt | string | No | |
model | string | No | |
n | integer | No | |
quality | string | No | |
responseFormat | string | No | |
size | string | No | |
style | string | No | |
user | string | No | |
background | string | No | |
outputFormat | string | No | |
moderation | string | No | |
metadata | object | No |
Responses
200 Generated images
| Property | Type | Description |
|---|---|---|
created | string | |
data | object[] | |
model | string | |
usage | object |
default An unexpected error response.
| Property | Type | Description |
|---|---|---|
code | integer | |
message | string | |
details | object[] |
Request
curl -X POST "http://localhost:8089/v1/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"string","model":"string","n":0,"quality":"string","responseFormat":"string","size":"string","style":"string","user":"string","background":"string","outputFormat":"string","moderation":"string"}'const response = await fetch("http://localhost:8089/v1/images/generations", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
"prompt": "string",
"model": "string",
"n": 0,
"quality": "string",
"responseFormat": "string",
"size": "string",
"style": "string",
"user": "string",
"background": "string",
"outputFormat": "string",
"moderation": "string"
}),
});
const data = await response.json();import requests
response = requests.post(
"http://localhost:8089/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"prompt": "string",
"model": "string",
"n": 0,
"quality": "string",
"responseFormat": "string",
"size": "string",
"style": "string",
"user": "string",
"background": "string",
"outputFormat": "string",
"moderation": "string"
},
)
data = response.json()Response
{
"created": "string",
"data": [
{
"b64Json": "string",
"url": "string",
"revisedPrompt": "string"
}
],
"model": "string",
"usage": {
"inputTokens": 0,
"outputTokens": 0,
"totalTokens": 0,
"inputTokensDetails": {
"textTokens": 0,
"imageTokens": 0
},
"outputTokensDetails": {
"textTokens": 0,
"imageTokens": 0
}
}
}{
"code": 0,
"message": "string",
"details": [
{
"@type": "string"
}
]
}
