Skip to content

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:

  1. An API endpoint
  2. Request headers
  3. A JSON request body
  4. A selected model ID
  5. Input messages or content

For chat completions, the endpoint is:

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

HTTP Method ​

Most generation requests use the POST method.

http
POST /v1/chat/completions

Use 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
HeaderRequiredDescription
Content-TypeYesUse application/json for JSON request bodies
AuthorizationYesYour API key in Bearer format

Request Body ​

For a basic chat completion request, the body usually includes:

ParameterTypeRequiredDescription
modelstringYesThe model ID you want to use
messagesarrayYesThe conversation messages
temperaturenumberNoControls randomness
streambooleanNoWhether to return the response as a stream
max_tokensintegerNoMaximum number of tokens to generate

Messages ​

The messages field is an array of message objects.

Each message usually contains:

FieldTypeDescription
rolestringThe role of the message sender
contentstring or arrayThe message content

Common roles include:

text
system
user
assistant

Example:

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 ​

FieldDescription
idUnique ID of the response
objectResponse object type
createdUnix timestamp of when the response was created
modelModel used for the request
usageToken usage information
choicesGenerated response choices

The generated text is usually located at:

text
choices[0].message.content

Streaming 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_KEY

Incorrect Base URL ​

For most SDK integrations, use:

text
https://www.kkiai.com/v1

For direct chat completion requests, use:

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

Invalid 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.