Official SDKs
SDK & Libraries
Official SDKs and libraries for integrating COZHUB into your applications
Fully Typed
Complete type definitions for all SDKs
Streaming Support
Built-in support for real-time streaming
Auto Retry
Automatic retry with exponential backoff
OpenAI Compatible
Drop-in replacement for OpenAI SDK
Available SDKs
🟦
TypeScript / JavaScript
@cozhub/sdk
v2.1.0
125K+
GitHubFull TypeScript support
Tree-shakeable
Browser & Node.js
Installation
npm install @cozhub/sdk🐍
Python
cozhub
v2.1.0
🐹
Go
github.com/cozhub/sdk-go
v2.1.0
💎
Ruby
cozhub
v2.1.0
🌐
cURL / REST API
REST API
vv1
N/A
GitHubNo SDK needed
Works anywhere
Full API access
Installation
# No installation needed - use any HTTP clientCode Examples
Quick start examples for each SDK
Quick Start
import { Cozhub } from '@cozhub/sdk';
const client = new Cozhub({
apiKey: process.env.COZHUB_API_KEY,
});
// Simple chat completion
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [
{ role: 'user', content: 'Hello, how are you?' }
],
});
console.log(response.choices[0].message.content);Advanced Example (Streaming + Function Calling)
import { Cozhub } from '@cozhub/sdk';
const client = new Cozhub({
apiKey: process.env.COZHUB_API_KEY,
timeout: 30000,
maxRetries: 3,
});
// Streaming with function calling
const stream = await client.chat.completions.create({
model: 'claude-3-5-sonnet',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the weather in Tokyo?' }
],
tools: [
{
type: 'function',
function: {
name: 'get_weather',
description: 'Get current weather for a location',
parameters: {
type: 'object',
properties: {
location: { type: 'string', description: 'City name' },
},
required: ['location'],
},
},
},
],
stream: true,
});
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content;
if (content) process.stdout.write(content);
}OpenAI SDK Compatibility
Use the official OpenAI SDK with COZHUB - just change the base URL
COZHUB is fully compatible with the OpenAI API specification. You can use the official OpenAI SDK with any programming language by simply changing the base URL to our API endpoint.
import OpenAI from 'openai';
// Just change the baseURL - everything else works the same!
const client = new OpenAI({
apiKey: process.env.COZHUB_API_KEY,
baseURL: 'https://api.cozhub.ai/v1',
});
// Use any OpenAI SDK code as-is
const response = await client.chat.completions.create({
model: 'gpt-4o', // or 'claude-3-5-sonnet', 'gemini-2.0-flash', etc.
messages: [{ role: 'user', content: 'Hello!' }],
});