Theme
Create Chat Completion (Non-Streaming)
POST: https://www.kkiai.com/v1/chat/completions
Given a list of messages, the model returns a complete non-streaming chat completion response.
Create a completion for the provided messages and parameters.
Official documentation: https://docs.anthropic.com/en/api/messages
Request Parameters
Authorization
Add the Authorization parameter to the request header. The value should be your API key prefixed with Bearer.
Example: Authorization: Bearer YOUR_API_KEY
Header Parameters
| Parameter Name | Type | Required | Description | Example |
|---|---|---|---|---|
Content-Type | string | Required | Request content type. | application/json |
Accept | string | Optional | Response content type. | application/json |
Authorization | string | Required | API key used for authentication. | 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 are available, see the model list or pricing table. |
messages | array[object] | Required | A list of messages that make up the conversation so far. |
└ role | string | Required | The role of the message author, such as system, user, or assistant. |
└ content | string | Required | The text content of the message. |
temperature | number | Optional | What sampling temperature to use, between 0 and 2. Higher values make the output more random, while lower values make it more focused and deterministic. We generally recommend changing either this or top_p, but not both. |
top_p | number | Optional | An alternative to sampling with temperature, called nucleus sampling. We generally recommend changing either this or temperature, but not both. |
n | integer | Optional | How many chat completion choices to generate for each input message. |
stream | boolean | Optional | Defaults to false. For non-streaming requests, omit this parameter or set it to false. |
stop | string or array | Optional | Up to 4 sequences where the API will stop generating further tokens. |
max_tokens | integer | Optional | The maximum number of tokens to generate in the chat completion. |
presence_penalty | number | Optional | Penalizes new tokens based on whether they already appear in the text so far. |
frequency_penalty | number | Optional | Penalizes new tokens based on their existing frequency in the text so far. |
logit_bias | object or null | Optional | Modifies the likelihood of specified tokens appearing in the completion. |
user | string | Optional | A unique identifier representing your end user, which can help monitor and detect abuse. |
response_format | object | Optional | Specifies the format that the model should output. |
seed | integer | Optional | If specified, the system will make a best effort to sample deterministically. |
tools | array[object] | Optional | A list of tools the model may call. Currently, only function tools are supported. |
tool_choice | string or object | Optional | Controls which tool, if any, the model should call. Common values include none and auto. |
Request Example
json
{
"model": "claude-sonnet-4-20250514",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello"
}
]
}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": "Hello"
}
]
}'Response
🟢 200 OK
Response Body
| Parameter Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | Unique identifier for the chat completion. |
object | string | Required | Object type. Always chat.completion. |
created | integer | Required | Unix timestamp, in seconds, of when the chat completion was created. |
model | string | Required | The model used to generate the completion. |
choices | array[object] | Required | A list of chat completion choices. |
└ index | integer | Optional | The index of the generated choice. |
└ message | object | Optional | The message generated by the model. |
└ finish_reason | string | Optional | The reason the model stopped generating tokens. |
usage | object | Required | Token usage statistics for the request. |
└ prompt_tokens | integer | Required | Number of tokens in the prompt. |
└ completion_tokens | integer | Required | Number of tokens in the generated completion. |
└ total_tokens | integer | Required | Total number of tokens used in the request. |
Response Example
json
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "claude-sonnet-4-20250514",
"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
}
}