Theme
Making Requests
SynStar AI provides OpenAI-compatible API endpoints for common chat, vision, and multimodal workflows.
This page explains the basic structure of an API request.
Request Structure
A typical API request includes:
- An API endpoint
- Request headers
- A JSON request body
- A selected model ID
- Input messages or content
For chat completions, the endpoint is:
text
POST https://www.kkiai.com/v1/chat/completionsHTTP Method
Most generation requests use the POST method.
http
POST /v1/chat/completionsUse POST when sending messages, prompts, images, parameters, or other request body data to a model.
Headers
Each request should include the following headers:
http
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY| Header | Required | Description |
|---|---|---|
Content-Type | Yes | Use application/json for JSON request bodies |
Authorization | Yes | Your API key in Bearer format |
Request Body
For a basic chat completion request, the body usually includes:
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model ID you want to use |
messages | array | Yes | The conversation messages |
temperature | number | No | Controls randomness |
stream | boolean | No | Whether to return the response as a stream |
max_tokens | integer | No | Maximum number of tokens to generate |
Messages
The messages field is an array of message objects.
Each message usually contains:
| Field | Type | Description |
|---|---|---|
role | string | The role of the message sender |
content | string or array | The message content |
Common roles include:
text
system
user
assistantExample:
json
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Explain what an API gateway is."
}
]Example Request
bash
curl https://www.kkiai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Say this is a test!"
}
],
"temperature": 0.7
}'Example Response
A successful response will look similar to this:
json
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677858242,
"model": "gpt-4o",
"usage": {
"prompt_tokens": 13,
"completion_tokens": 7,
"total_tokens": 20
},
"choices": [
{
"message": {
"role": "assistant",
"content": "This is a test!"
},
"finish_reason": "stop",
"index": 0
}
]
}Response Fields
| Field | Description |
|---|---|
id | Unique ID of the response |
object | Response object type |
created | Unix timestamp of when the response was created |
model | Model used for the request |
usage | Token usage information |
choices | Generated response choices |
The generated text is usually located at:
text
choices[0].message.contentStreaming Requests
To receive output incrementally, set stream to true.
json
{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Write a short introduction to AI APIs."
}
],
"stream": true
}Streaming is useful for chat interfaces because the response can be displayed as it is generated.
Choosing a Model
Set the model parameter to a supported model ID.
Example:
json
{
"model": "gpt-4o"
}You can find supported model IDs in the model list or model marketplace.
Use the model name exactly as shown in the documentation or dashboard.
Common Request Issues
Missing API Key
Make sure the request includes:
http
Authorization: Bearer YOUR_API_KEYIncorrect Base URL
For most SDK integrations, use:
text
https://www.kkiai.com/v1For direct chat completion requests, use:
text
https://www.kkiai.com/v1/chat/completionsInvalid Model ID
Check that the model ID is spelled correctly and available in your account.
Insufficient Balance
If the request fails due to balance or quota, check your account balance, token quota, and token group settings in the dashboard.