BYOK gateway

Bring Your Own Key. Plug in your existing OpenAI, Claude, MiniMax, DeepSeek, Gemini, Groq or Cohere API key once — Aimactok routes every call through the lowest-latency edge node, fallbacks automatically if a provider hiccups, and gives you one OpenAI-compatible endpoint for the lot.

What it is

BYOK is a thin routing layer in front of the providers you already pay for. You keep your provider relationship, billing and rate limits; Aimactok adds:

Why bother? If you call more than one provider, you already know the pain: 4 SDKs, 4 auth flows, 4 error shapes, 4 dashboards. BYOK collapses it to one.

Supported models

Seven first-class providers today. More on the way — see /aimactok-blog/ for the integration roadmap.

Provider Default model Speed (P50) Best for
openai gpt-4o-mini 320ms Reasoning, long context, tooling
claude claude-3-5-sonnet 410ms Code, careful writing, 200k context
minimax MiniMax-Text-01 280ms Multilingual, 50+ languages
deepseek deepseek-chat 350ms Cheap reasoning, code, math
gemini gemini-1.5-flash 260ms Long context (1M tokens), multimodal
groq llama-3.1-8b-instant 89ms Ultra-low latency, high QPS
cohere command-r-plus 290ms RAG, rerank, embed

More models are continuously being added. If a model is missing, ask for it — most requests ship within 2 weeks.

Configure your provider key

From your dashboardBYOK keysAdd key, pick the provider, paste the key, save. Aimactok encrypts the key with AES-256 at rest and never logs it. The dashboard shows only the last 4 characters.

Test it with the quickstart example — just swap gpt-4o-mini for any model from the table above. The gateway uses your key automatically when you request that provider’s model.

Edge routing & latency

Every provider exposes multiple regions. The gateway measures live latency from your IP to each region and pins the call to the lowest one. If a region slows down by >50ms it falls off the list for 60s. Measurements live in aim-routing-cache in Redis and refresh every 30s.

The numbers in the table above are the global P50 we observe from a mix of test points. Your mileage will vary by region — the dashboard shows your personal P50 over the last 24h.

Self-host the gateway

Prefer running it on your own infra? The whole gateway is a single Python file — chat_v3.py — plus a small SQLite ledger. No external services required. Run it on a $5 VPS, a Lambda, or your laptop.



# Single file, ~600 lines, no external deps beyond stdlib + httpx
curl -O https://aimactok.com/static/chat_v3.py
pip install httpx
# Set provider keys as env vars (or use --key openai=sk-...)
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
python3 chat_v3.py --port 4006 --bind 0.0.0.0
# Now POST to http://localhost:4006/v1/chat/completions

The self-hosted binary supports the same model names, the same OpenAI SDK, and the same response shape. The only things it does not include are: managed failover across providers, the usage dashboard, and PayPal billing — bring your own.

OpenAI-compatible API

Every model is exposed as provider/model-name on the same /v1 namespace. The request and response shapes match the OpenAI Chat Completions spec exactly, so any client library that speaks OpenAI works without modification.

Chat completions




curl -X POST https://aimactok.com/v1/chat/completions 
  -H "Authorization: Bearer sk-YOUR_KEY" 
  -H "Content-Type: application/json" 
  -d '{
    "model": "claude/claude-3-5-sonnet",
    "messages": [{"role": "user", "content": "Explain async/await in 2 sentences"}],
    "temperature": 0.7
  }'
from openai import OpenAI
client = OpenAI(api_key="sk-YOUR_KEY", base_url="https://aimactok.com/v1")
r = client.chat.completions.create(
    model="claude/claude-3-5-sonnet",
    messages=[{"role":"user","content":"Explain async/await in 2 sentences"}],
    temperature=0.7,
)
print(r.choices[0].message.content)
const r = await fetch("https://aimactok.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer sk-YOUR_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "claude/claude-3-5-sonnet",
    messages: [{ role: "user", content: "Explain async/await in 2 sentences" }],
    temperature: 0.7
  })
});
const d = await r.json();
console.log(d.choices[0].message.content);

Streaming

Set "stream": true in the request body. The response is server-sent events (SSE) with the same data: {...}nn framing as OpenAI. Both the Python and JS SDKs handle this automatically when stream=True / you call .stream().

Image generation




curl -X POST https://aimactok.com/v1/images/generations 
  -H "Authorization: Bearer sk-YOUR_KEY" 
  -H "Content-Type: application/json" 
  -d '{
    "model": "minimax/image-01",
    "prompt": "a small red apple on white background",
    "size": "1024x1024"
  }'
from openai import OpenAI
client = OpenAI(api_key="sk-YOUR_KEY", base_url="https://aimactok.com/v1")
r = client.images.generate(
    model="minimax/image-01",
    prompt="a small red apple on white background",
    size="1024x1024",
)
print(r.data[0].url)
const r = await fetch("https://aimactok.com/v1/images/generations", {
  method: "POST",
  headers: {
    "Authorization": "Bearer sk-YOUR_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "minimax/image-01",
    prompt: "a small red apple on white background",
    size: "1024x1024"
  })
});
const d = await r.json();
console.log(d.data[0].url);

Returns a JSON body with data[0].url pointing to a CDN-hosted PNG. Aimactok-hosted images are valid for 30 days.

Text-to-speech (TTS)



curl -X POST https://aimactok.com/v1/audio/speech 
  -H "Authorization: Bearer sk-YOUR_KEY" 
  -H "Content-Type: application/json" 
  -d '{
    "model": "minimax/speech-01",
    "input": "Hello, welcome to Aimactok.",
    "voice": "male-qn-jingying"
  }' --output hello.mp3
from openai import OpenAI
client = OpenAI(api_key="sk-YOUR_KEY", base_url="https://aimactok.com/v1")
r = client.audio.speech.create(
    model="minimax/speech-01",
    input="Hello, welcome to Aimactok.",
    voice="male-qn-jingying",
)
r.stream_to_file("hello.mp3")

23 voices in 8 languages. Output is 128 kbps MP3 by default; pass "format": "wav" for 44.1kHz PCM. The full voice list lives in the dashboard under TTS → Voices.

Error codes

Code Meaning What to do
401 TOKEN_EXPIRED Daily login bonus hasn’t refreshed Re-login at /account/login
402 INSUFFICIENT_CREDITS Out of credits Top up at /account/billing
403 PROVIDER_KEY_MISSING No BYOK key for that provider Add the key in dashboard
429 RATE_LIMITED Too many requests Back off, retry with jitter
502 PROVIDER_DOWN All provider regions failed Wait & retry; status at /trust/

Next