haimaker API - Getting Started
Access 100+ LLMs through a single API endpoint
haimaker provides a unified OpenAI-compatible API to access models from multiple providers:
- OpenAI-compatible format - Use the same request format you're familiar with
- Consistent responses - Same response format regardless of which model you use
- Automatic routing - haimaker handles model selection and routing for you
Quick Start
Make your first API request
- cURL
- Python
- Node.js
curl https://api.haimaker.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [{"role": "user", "content": "Hello, how are you?"}]
}'
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.chat.completions.create(
model="openai/gpt-4o",
messages=[{"role": "user", "content": "Hello, how are you?"}]
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'YOUR_API_KEY',
baseURL: 'https://api.haimaker.ai/v1'
});
const response = await client.chat.completions.create({
model: 'openai/gpt-4o',
messages: [{ role: 'user', content: 'Hello, how are you?' }]
});
console.log(response.choices[0].message.content);
Response Format
All responses follow the OpenAI Chat Completions format:
{
"id": "chatcmpl-565d891b-a42e-4c39-8d14-82a1f5208885",
"created": 1734366691,
"model": "gpt-4o-2024-08-06",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! I'm doing well, thank you for asking. How can I help you today?",
"role": "assistant"
}
}
],
"usage": {
"completion_tokens": 17,
"prompt_tokens": 13,
"total_tokens": 30
}
}
Streaming
Enable streaming by setting stream=true:
- cURL
- Python
curl https://api.haimaker.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [{"role": "user", "content": "Write a haiku about coding"}],
"stream": true
}'
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
stream = client.chat.completions.create(
model="openai/gpt-4o",
messages=[{"role": "user", "content": "Write a haiku about coding"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
Available Endpoints
| Endpoint | Description |
|---|---|
/v1/chat/completions | Chat completion requests |
/v1/completions | Text completion requests |
/v1/embeddings | Generate text embeddings |
/v1/images/generations | Generate images |
/v1/audio/transcriptions | Transcribe audio |
/v1/audio/speech | Text to speech |
/v1/moderations | Content moderation |
/v1/rerank | Rerank documents |
See Supported Endpoints for complete documentation.
Error Handling
haimaker returns standard HTTP error codes with descriptive messages:
from openai import OpenAI, APIError, RateLimitError, AuthenticationError
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
try:
response = client.chat.completions.create(
model="openai/gpt-4o",
messages=[{"role": "user", "content": "Hello"}]
)
except AuthenticationError as e:
print(f"Authentication failed: {e}")
except RateLimitError as e:
print(f"Rate limited: {e}")
except APIError as e:
print(f"API error: {e}")
See Exception Mapping for all error types.
What's Next?
- Chat Completions - Full request/response documentation
- Streaming - Real-time response streaming
- JSON Mode - Structured JSON responses
- Vision - Image understanding
- Function Calling - Tool use and function calling