Token Harbor: An OpenAI-Compatible AI Gateway for Developers
Token Harbor is a gateway service that provides a single OpenAI-compatible endpoint for accessing multiple LLM models: Anthropic Claude, OpenAI GPT, Google Gemini, DeepSeek, Qwen, and more. A developer uses one API key, one base URL, and a standard OpenAI SDK / HTTP client.
Why Token Harbor?
Traditional approach: for each provider (OpenAI, Anthropic, Google), you need a separate SDK, key, base URL, rate-limiting logic, retry policy, and monitoring. With 5+ models, that means 5 integrations.
Token Harbor unifies this into one OpenAI-compatible endpoint:
- One API key (
sk-th-...) - One base URL (
https://api.tokenharbor.ai/v1or custom) - Standard OpenAI SDK /
openaiPython package /httpx/curl - Per-token billing, transparent pricing, free tier (DeepSeek V4 Flash, MiMo V2.5)
Architecture
Client (OpenAI SDK)
│
▼
┌───────────────────┐
│ Token Harbor │ ←── OpenAI-compatible REST API
│ Gateway │ /v1/chat/completions
│ (Load balancer) │ /v1/models
└─────────┬─────────┘
│
┌─────┼─────┐
▼ ▼ ▼
Claude GPT Gemini DeepSeek Qwen ...
- Routing: the
modelparameter in the request specifies the target model - Failover: if one provider fails, automatic fallback to another
- Observability: per-request logs, token usage, latency metrics
Integration Example: OMP (Oh My Pi)
OMP is a coding harness with AI assistance. Token Harbor is configured as an OpenAI provider:
# 1. Login to OMP
omp login openai
# 2. In the prompt, enter:
# API Key: your_TokenHarbor_key
# Base URL: https://api.tokenharbor.ai/v1
# 3. Select the model from the Token Harbor dashboard, e.g.:
# deepseek-v4-flash
# qwen-2.5-72b
# claude-3.5-sonnet
Environment variables (for scripts/CI):
export OPENAI_API_KEY="sk-th-xxxxxxxxxxxx"
export OPENAI_BASE_URL="https://api.tokenharbor.ai/v1"
Python example without an SDK:
import os, httpx
resp = httpx.post(
f"{os.environ['OPENAI_BASE_URL']}/chat/completions",
headers={"Authorization": f"Bearer {os.environ['OPENAI_API_KEY']}"},
json={
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Hi, can you explain capability seams?"}],
},
timeout=60,
)
print(resp.json()["choices"][0]["message"]["content"])
API Key Security
| Rule | Description |
|---|---|
| Never commit keys to git | Use .env, ~/.omp/agent/.env, GitHub Secrets, Vault |
| Scope keys | Token Harbor allows creating keys with limited scope (specific model, daily quota) |
| Rotate keys | Regularly generate new keys and revoke old ones |
| Monitor usage | The dashboard shows per-model consumption and detects anomalies |
# Correct storage in .env (add to .gitignore)
OPENAI_API_KEY=sk-th-xxxxxxxxxxxx
OPENAI_BASE_URL=https://api.tokenharbor.ai/v1
Production Best Practices
- Timeouts: set reasonable timeouts (30–60s), some models (Claude, GPT-4) take longer.
- Retry + backoff: exponential backoff for 429/5xx, max 3 retries.
- Streaming: for long outputs, use
stream: trueand process chunks. - Model pinning: specify exact model names in code (not
auto) to control cost/latency. - Cost alerts: Token Harbor dashboard supports daily/monthly spending limits.
Comparison with Alternatives
| Feature | Token Harbor | OpenRouter | LiteLLM Proxy | Self-hosted |
|---|---|---|---|---|
| OpenAI-compat | yes | yes | yes | manual |
| Free tier | yes (DeepSeek V4 Flash) | yes | no | no |
| Failover | yes, automatic | yes | yes | manual |
| Per-token billing | yes | yes | no | manual |
| Self-hosted | no | no | yes | yes |
| SDK required | no (standard OpenAI) | no | no | manual |
Conclusion
Token Harbor eliminates integration complexity when using multiple LLM providers. For developers using OMP, Python, TypeScript, or plain HTTP, it is a drop-in replacement for the OpenAI API, you only change base_url and api_key, and the rest of your code remains unchanged.
For production: rotate keys, monitor usage, set cost alerts, and always test failover scenarios in staging.
Comments (0)
No comments yet — be the first to react.