Skip to content

Create Chat Vision (Streaming)

POST: https://www.kkiai.com/v1/chat/completions

Given a list of messages with text and image content, the model returns one or more predicted completions and streams the response incrementally.

Create a vision completion for the provided messages 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 NameTypeRequiredDescriptionExample
Content-TypestringRequiredRequest content type.application/json
AcceptstringRequiredResponse content type.application/json
AuthorizationstringRequiredAPI key used for authentication.Bearer YOUR_API_KEY

Body Parameters (application/json)

Parameter NameTypeRequiredDescription
modelstringRequiredThe ID of the model to use. For details on which models can be used with the Chat API, see the model endpoint compatibility table.
messagesarray[object]RequiredA list of messages comprising the conversation so far.
  └ rolestringRequiredThe role of the message author, such as system, user, or assistant.
  └ contentstring or array[object]RequiredThe message content. For vision requests, user messages can contain both text and image content.
temperaturenumberOptionalWhat 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_pnumberOptionalAn alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. We generally recommend altering this or temperature, but not both.
nintegerOptionalDefaults to 1. How many chat completion choices to generate for each input message.
streambooleanRequiredSet this to true to receive partial message deltas as data-only server-sent events. The stream is terminated by a data: [DONE] message.
stopstring or arrayOptionalDefaults to null. Up to 4 sequences where the API will stop generating further tokens.
max_tokensintegerOptionalDefaults 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.
presence_penaltynumberOptionalDefaults 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.
frequency_penaltynumberOptionalDefaults 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.
logit_biasobject or nullOptionalModifies the likelihood of specified tokens appearing in the completion.
userstringOptionalA unique identifier representing your end user, which can help monitor and detect abuse.
response_formatobjectOptionalAn object specifying the format that the model must output.
seedintegerOptionalIf specified, the system will make a best effort to sample deterministically.
toolsarray[object]OptionalA list of tools the model may call. Currently, only functions are supported as a tool.
tool_choicestring or objectOptionalControls 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://lsky.zhongzhuan.chat/i/2024/10/17/6711068a14527.png"
          }
        }
      ]
    }
  ],
  "stream": true
}

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://lsky.zhongzhuan.chat/i/2024/10/17/6711068a14527.png"
          }
        }
      ]
    }
  ],
  "stream": true
}'

Response

🟢 200 OK

Response Body

Parameter NameTypeRequiredDescription
idstringRequiredUnique identifier for the chat completion. Chunks from the same streaming response share the same ID.
objectstringRequiredObject type. Always chat.completion.chunk.
createdintegerRequiredUnix timestamp, in seconds, of when the chat completion was created.
modelstringRequiredThe model used to generate the completion.
system_fingerprintstringOptionalFingerprint of the backend configuration that processed the request.
choicesarray[object]RequiredA list of chat completion choices.
  └ indexintegerOptionalThe index of the generated choice.
  └ deltaobjectOptionalThe incremental message content returned in the current chunk.
  └ finish_reasonstring or nullOptionalThe reason generation stopped. Usually null for intermediate chunks and stop in the final chunk.

Response Example

text
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"claude-sonnet-4-20250514","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"claude-sonnet-4-20250514","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{"content":"The"},"finish_reason":null}]}

{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"claude-sonnet-4-20250514","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{"content":" image"},"finish_reason":null}]}

...

{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"claude-sonnet-4-20250514","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{"content":" in detail."},"finish_reason":null}]}

{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"claude-sonnet-4-20250514","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}