Theme
Create Chat Vision (Non-Streaming)
POST: https://www.kkiai.com/v1/chat/completions
Given a list of messages with text and image content, 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://docs.anthropic.com/en/docs/build-with-claude/vision
Request Parameters
Authorization
Add the Authorization parameter to the Header, with its value being the Token concatenated after Bearer.
Example: Authorization: Bearer YOUR_API_KEY
Header Parameters
| Parameter Name | Type | Required | Description | Example |
|---|---|---|---|---|
Content-Type | string | Required | application/json | |
Accept | string | Required | application/json | |
Authorization | string | Required | Bearer YOUR_API_KEY |
Body Parameters (application/json)
| Parameter Name | Type | Required | Description |
|---|---|---|---|
model | string | Required | The ID of the model to use. For details on which models can be used with the Chat API, see the model endpoint compatibility table. |
messages | array[object] | Required | A list of messages comprising the conversation so far. Python code example. |
└ role | string | Required | The role of the message author, such as system, user, or assistant. |
└ content | string or array[object] | Required | The message content. For vision requests, user messages can contain both text and image content. |
temperature | number | Optional | What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p, but not both. |
top_p | number | Optional | An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature, but not both. |
n | integer | Optional | Defaults to 1. How many chat completion choices to generate for each input message. |
stream | boolean | Optional | Defaults to false. If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Python code example. |
stop | string or array | Optional | Defaults to null. Up to 4 sequences where the API will stop generating further tokens. |
max_tokens | integer | Optional | Defaults to inf. The maximum number of tokens to generate in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length. Python code example for counting tokens. |
presence_penalty | number | Optional | Defaults to 0. A number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. See more information about frequency and presence penalties. |
frequency_penalty | number | Optional | Defaults to 0. A number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. See more information about frequency and presence penalties. |
logit_bias | object or null | Optional | Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens to an associated bias value from -100 to 100. |
user | string | Optional | A unique identifier representing your end-user, which can help OpenAI monitor and detect abuse. Learn more. |
response_format | object | Optional | An object specifying the format that the model must output. |
seed | integer | Optional | This feature is in beta. If specified, our system will make a best effort to sample deterministically. |
tools | array[object] | Optional | A list of tools the model may call. Currently, only functions are supported as a tool. |
tool_choice | string or object | Optional | Controls which function, if any, the model calls. |
Request Example
json
{
"model": "claude-sonnet-4-20250514",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Please describe it in detail."
},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
}
]
}
]
}cURL Example
bash
curl --location --request POST 'https://www.kkiai.com/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "claude-sonnet-4-20250514",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image? Please describe it in detail."
},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
}
]
}
]
}'Response
🟢 200 OK
Response Body
| Parameter Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | |
object | string | Required | |
created | integer | Required | |
model | string | 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,
"model": "claude-sonnet-4-20250514",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nThe image shows a wooden boardwalk stretching through a green natural landscape. There are trees and vegetation on both sides, with a bright outdoor setting and a clear path leading into the distance."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}