Skip to main content

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 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?"}]
}'

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 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
}'

Available Endpoints

EndpointDescription
/v1/chat/completionsChat completion requests
/v1/completionsText completion requests
/v1/embeddingsGenerate text embeddings
/v1/images/generationsGenerate images
/v1/audio/transcriptionsTranscribe audio
/v1/audio/speechText to speech
/v1/moderationsContent moderation
/v1/rerankRerank 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?