Getting Started with COZHUB: A Complete Guide
Learn how to set up your account, get API keys, and make your first AI model request in under 5 minutes.
Developer Relations
DevRel
Introduction
Welcome to COZHUB! This guide will walk you through everything you need to start using our unified AI API. By the end, you'll have made your first API request to any of our 60+ AI models.
What you'll learn:
- Creating your COZHUB account
- Generating API keys
- Making your first API request
- Switching between AI models
- Best practices for production
Prerequisites
Before you begin, make sure you have:
- A valid email address
- Basic familiarity with REST APIs
- Node.js 18+ or Python 3.8+ (for the code examples)
Step 1: Create Your Account
Step 2: Generate an API Key
After logging in:
Your API key looks like this:
sk-coz-xxxxxxxxxxxxxxxxxxxxxxxxxxxx
⚠️ Security Tip: Never commit API keys to version control. Use environment variables instead.
Step 3: Install the SDK
Choose your preferred language:
JavaScript/TypeScript
npm install openai
COZHUB is compatible with the OpenAI SDK
Python
pip install openai
cURL
No installation needed — cURL comes pre-installed on most systems.
Step 4: Make Your First Request
JavaScript/TypeScript
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.cozhub.ai/v1',
apiKey: process.env.COZHUB_API_KEY,
});
async function main() {
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the capital of France?' }
],
});
console.log(response.choices[0].message.content);
}
main();
Python
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.cozhub.ai/v1",
api_key=os.environ.get("COZHUB_API_KEY"),
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
)
print(response.choices[0].message.content)
cURL
curl https://api.cozhub.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COZHUB_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}'
Expected Response:
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
}
Step 5: Try Different Models
The magic of COZHUB is switching models with a single line change:
// Use Claude instead of GPT-4
const response = await client.chat.completions.create({
model: 'claude-3-5-sonnet', // Just change the model name!
messages: [...]
});
// Or try DeepSeek for cost savings
const response = await client.chat.completions.create({
model: 'deepseek-v3',
messages: [...]
});
// Or Gemini for multi-modal tasks
const response = await client.chat.completions.create({
model: 'gemini-2.0-flash',
messages: [...]
});
Available Models
Here are some popular models to try:
| Model | Best For | Price (per 1M tokens) |
| gpt-4o | General tasks, reasoning | $2.50 / $10.00 |
| claude-3-5-sonnet | Long context, analysis | $3.00 / $15.00 |
| gemini-2.0-flash | Fast responses | $0.075 / $0.30 |
| deepseek-v3 | Cost-effective | $0.27 / $1.10 |
See the full list in our Models Catalog.
Best Practices
1. Use Environment Variables
# .env file
COZHUB_API_KEY=sk-coz-xxxxxxxxxxxx
2. Handle Errors Gracefully
try {
const response = await client.chat.completions.create({...});
} catch (error) {
if (error.status === 429) {
// Rate limited - wait and retry
} else if (error.status === 402) {
// Insufficient credits
}
}
3. Set Reasonable Timeouts
const client = new OpenAI({
baseURL: 'https://api.cozhub.ai/v1',
apiKey: process.env.COZHUB_API_KEY,
timeout: 30000, // 30 seconds
});
4. Monitor Your Usage
Check your dashboard regularly to:
- Track spending
- Identify expensive queries
- Set up usage alerts
Next Steps
Now that you're up and running:
Need Help?
Happy building! 🚀