Skip to main content

📋 Prerequisites

Before you begin, you’ll need:
  • A Kaihoxz account
  • An API key (obtain from the Dashboard)
  • Basic programming knowledge

1️⃣ Get Your API Key

1

Login to Console

Visit Kaihoxz Dashboard and log in
2

Generate Key

Click “Create New Key” on the API Key Management page
3

Save Your Key

Copy and securely save your API key
Security Note: Never expose your API key in public code or on the client side

2️⃣ Make Your First Request

Using cURL

curl https://ai.kaiho.cc/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": "Hello, please introduce yourself"
      }
    ]
  }'

Using Python

import openai

client = openai.OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://ai.kaiho.cc/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Hello, please introduce yourself"}
    ]
)

print(response.choices[0].message.content)

Using JavaScript/Node.js

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://ai.kaiho.cc/v1'
});

async function main() {
  const response = await client.chat.completions.create({
    model: 'gpt-4o',
    messages: [
      { role: 'user', content: 'Hello, please introduce yourself' }
    ]
  });
  
  console.log(response.choices[0].message.content);
}

main();

3️⃣ Understanding the Response

A successful response looks like this:
{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-4o",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hello! I'm an AI assistant..."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}

4️⃣ Explore More Features

📚 Next Steps

Tip: All APIs are compatible with OpenAI SDK, so you can use your existing OpenAI integration code directly!