API (coming soon)
API-first platform for routing prompts to the best AI.

AITransitHub API

One API to route prompts across multiple AI models — Auto, Single, or Compare. Built for developers and businesses that want one key, one endpoint, and the best model per request.

1) Get an API key
API keys are coming soon. When available, you’ll generate a key in Plans and authenticate every request with: Authorization: Bearer YOUR_API_KEY
2) Make a request
Send a prompt to one endpoint. Choose auto (best model), single (you pick), or compare (multiple answers). Endpoint: POST https://api.aitransithub.com/v1/route
3) Pricing (usage-based)
You only pay for what you use. Pricing is measured per 1,000,000 tokens (1M tokens), with transparent usage tracking. Different routed models may have different costs — AITransitHub will show the effective rate in your dashboard.
4) Docs & examples
Below are request/response examples for Auto, Single, and Compare — plus Streaming and Errors. Copy/paste snippets to get started quickly.

POST /v1/route

One endpoint for all modes. Your UI already sends one of these payloads:

Auto (default)
{
  "prompt": "Explain this like I’m five: what is an LLM router?",
  "mode": "auto"
}
Meaning: “Best AI for your question.”
Single model
{
  "prompt": "Draft a customer email about a delayed shipment.",
  "mode": "single",
  "model": "gpt4"
}
Meaning: user picks one model.
Compare (multi-model)
{
  "prompt": "Summarize this contract in plain English.",
  "mode": "compare",
  "models": ["gpt4", "claude", "gemini"]
}
Meaning: same prompt sent to multiple models.
Example JSON response
{
  "answer": "…"
}
Your UI also supports compare results arrays.

Quick curl example



curl -X POST "https://api.aitransithub.com/v1/route" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "prompt": "Give me 5 bullet points for a product launch plan.",
    "mode": "auto"
  }'


JavaScript fetch example


const url = "https://api.aitransithub.com/v1/route";


const res = await fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
  },
  body: JSON.stringify({ prompt: "Write a 2-sentence elevator pitch.", mode: "auto" })
});


const data = await res.json();
console.log(data.answer);
Authentication: all requests require an API key sent via Authorization: Bearer YOUR_API_KEY.

Compare tools (optional, backend-ready)

The UI supports power actions after a compare run: Pick best, Summarize differences, and Merge best parts. Today, it can use mock logic — later you can route these to your backend.

Summarize differences
Recommended request shape (future-proof)
{
  "task": "compare_summary",
  "mode": "compare",
  "prompt": "…original prompt…",
  "results": [
    {"model": "gpt4", "answer": "…"},
    {"model": "claude", "answer": "…"}
  ]
}
Response can be { "answer": "..." }.
Merge best parts
Recommended request shape (future-proof)
{
  "task": "compare_merge",
  "mode": "compare",
  "prompt": "…original prompt…",
  "results": [
    {"model": "gpt4", "answer": "…"},
    {"model": "claude", "answer": "…"},
    {"model": "gemini", "answer": "…"}
  ]
}
Response can be a single merged answer.
Tip: keep responses streaming-friendly. The UI can render SSE text, chunked text, or JSON.

Streaming (SSE)

For the best ChatGPT-like feel, stream output. The UI supports: text/event-stream (SSE) and text/plain chunked responses.

SSE format

HTTP/1.1 200 OK
Content-Type: text/event-stream

data: Hello
data:  world!
data: \n

Client example (EventSource-style parsing)

// Your UI already handles this internally.
// If you build your own client:
const res = await fetch("/v1/route", { method:"POST", headers:{ "Content-Type":"application/json" }, body: JSON.stringify({ prompt:"Hi", mode:"auto" }) });

const reader = res.body.getReader();
const decoder = new TextDecoder();
let buf = "";

while (true) {
  const { value, done } = await reader.read();
  if (done) break;
  buf += decoder.decode(value, { stream: true });
  // If SSE, parse lines like "data: ..."
}
Fallback: If your backend can’t stream, return JSON: { "answer": "..." } or compare results arrays.

Error handling

Keep errors human-readable. The UI will show a friendly message and keep the conversation intact.

Recommended JSON error
{
  "error": "Rate limit exceeded. Try again in 30 seconds."
}
HTTP status suggestions
  • 400 — invalid request (missing prompt, unknown mode)
  • 401 — auth required (future)
  • 429 — rate limited
  • 500 — backend error
Don’t lose user work: even on errors, keep the chat visible and let the user retry.