Theme
Create gpt-image-1
POST
https://www.kkiai.com/v1/images/generations
Given a prompt, the model will return one or more predicted completions, and can also return the probability of alternative tokens at each position.
Create a completion for the provided prompt and parameters
Official documentation: https://platform.openai.com/docs/api-reference/images/create
Request Parameters
Header Parameters
| Parameter Name | Type | Required | Description | Example |
|---|---|---|---|---|
Content-Type | string | Required | application/json | |
Accept | string | Required | application/json | |
Authorization | string | Optional | Bearer {{YOUR_API_KEY}} |
Body Parameters (application/json)
| Parameter Name | Type | Required | Description |
|---|---|---|---|
prompt | string | Required | A text description of the desired image. Maximum length is 1000 characters. |
n | integer | Required | The number of images to generate. Must be between 1 and 10. |
size | string | Required | The size of the generated image. For GPT image models, must be one of 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), or auto (default). For dall-e-2, must be one of 256x256, 512x512, or 1024x1024. For dall-e-3, must be one of 1024x1024, 1792x1024, or 1024x1792. |
Request Example
json
{
"size": "1024x1536",
"prompt": "A cute little pig.",
"model": "gpt-image-1",
"n": 1
}cURL Example
bash
curl --location --request POST 'https://www.kkiai.com/v1/images/generations' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
"size": "1024x1536",
"prompt": "A cute little pig.",
"model": "gpt-image-1",
"n": 1
}'Response
🟢 200 OK
Response Body
| Parameter Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | |
object | string | Required | |
created | integer | Required | |
choices | array[object] | Required | |
└ index | integer | Optional | |
└ message | object | Optional | |
└ finish_reason | string | Optional | |
usage | object | Required | |
└ prompt_tokens | integer | Required | |
└ completion_tokens | integer | Required | |
└ total_tokens | integer | Required |
Response Example
json
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}