DEV Community

routerbasecom
routerbasecom

Posted on

Use RouterBase as an OpenAI-compatible API gateway

Many AI applications begin with one provider and then need more flexibility: fallback models, model experiments, or different models for different product workflows.

RouterBase gives developers an OpenAI-compatible API shape at https://routerbase.com/v1, so the first experiment can stay small: change the base URL, set a RouterBase API key, and choose a model id.

Minimal curl request

curl https://routerbase.com/v1/chat/completions \
  -H "Authorization: Bearer $ROUTERBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-2.5-flash",
    "messages": [
      { "role": "user", "content": "Explain RouterBase in one sentence." }
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

Node.js example

const response = await fetch("https://routerbase.com/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ROUTERBASE_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: process.env.ROUTERBASE_MODEL || "google/gemini-2.5-flash",
    messages: [
      { role: "user", content: "Draft a short product update." }
    ]
  })
});

if (!response.ok) {
  throw new Error(`RouterBase request failed: ${response.status}`);
}

console.log(await response.json());
Enter fullscreen mode Exit fullscreen mode

Practical rollout advice

Start with a low-risk workflow, keep the model id configurable, and compare output quality, latency, cost, and error rate before routing more traffic through the new setup.

Good first workflows:

  • Internal release note drafts
  • Support ticket summaries
  • Model comparison prompts
  • Non-critical classification tasks

Useful links

Top comments (0)