Theme
Authentication
SynStar AI uses API keys to authenticate API requests.
After creating an API key in Token Management, include it in the Authorization header of every request.
API Key Format
Your API key will look similar to:
text
sk-xxxxxxxxxxxxxxxxTreat your API key like a password. Anyone with access to your key may be able to use your account balance.
Authorization Header
Use the following format when sending requests:
http
Authorization: Bearer YOUR_API_KEYFor example:
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": "user",
"content": "Hello!"
}
]
}'Replace YOUR_API_KEY with the API key created in your SynStar AI dashboard.
Using an API Key with the OpenAI SDK
If your application already uses the OpenAI SDK, set your SynStar AI API key as the api_key.
python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://www.kkiai.com/v1"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)Keep Your API Key Secure
To protect your account and balance:
- Do not expose your API key in frontend code.
- Do not commit your API key to GitHub or other public repositories.
- Do not share your API key in screenshots, browser recordings, or public documents.
- Use different API keys for testing and production when possible.
- Set quota limits if you want to control the maximum usage of a specific key.
- Rotate or delete keys that are no longer in use.
Common Authentication Errors
Invalid Authorization Header
This usually means the Authorization header is missing or incorrectly formatted.
Make sure the header uses this format:
http
Authorization: Bearer YOUR_API_KEYCommon mistakes include:
http
Authorization: YOUR_API_KEYhttp
Authorization: Bearerhttp
Authorization: Bearer sk-xxx with extra spacesInvalid API Key
If the API key is invalid, check that:
- The key was copied correctly.
- The key has not been deleted.
- The key is enabled in Token Management.
- The key has permission to access the selected model.
- The key has not expired.
Insufficient Balance or Quota
If authentication succeeds but the request cannot be completed, check whether:
- Your account has enough balance.
- The API key has a quota limit.
- The selected token group has enough available balance.
- The selected model is available for your account.