Skip to main content
This is for the “I have nothing yet” case. If you already have an app calling OpenAI or Anthropic and just want to point it at Routor, see the Quickstart instead - it’s a 3-line change. This guide builds a small script from a blank folder so you can see every piece.

What You’ll Build

A tiny Node.js script that sends a few different questions to Routor and prints which model answered each one, what tier it was classified into, and how much cheaper it was than always using a flagship model.

Prerequisites

  • Node.js 18 or later (node --version to check)
  • A terminal

Step 1 - Get an API Key

  1. Sign up at routor.io - free, no credit card. New accounts start with a small welcome credit, so you can run this guide without topping up first.
  2. In the dashboard, go to API Keys and create one. It starts with sk-routor-.
  3. Copy it now - it’s only shown once.

Step 2 - Set Up the Project

Routor is OpenAI-compatible, so the official openai package is all you need - no Routor-specific SDK to install. Set your key as an environment variable instead of hardcoding it:

Step 3 - Write the Script

Create index.js:
package.json needs "type": "module" for top-level await and import - npm init -y doesn’t add this by default, so add it yourself:

Step 4 - Run It

You’ll see three answers print, each with a line showing which model Routor picked for that specific question. The trivial question and the proof question are unlikely to route to the same model - that’s the point. You never chose a model in the code above; model: "auto" is the only routing-related line.

Step 5 - See the Full Decision

Every response’s response.routor object carries the full decision, not just the model name:
tier and category tell you how the prompt was classified, confidence is how sure the classifier was, savingsPct is versus the baseline comparison model, and qualityPct is the routed model’s benchmark score relative to that same baseline (negative means somewhat below it, which is expected and fine for genuinely simple requests). You can also check any prompt’s routing decision before spending a real request, using the Debug Endpoint - useful while you’re still deciding whether the defaults fit your use case. Your dashboard’s Logs page shows the same information for every request you’ve made, in one place.

Where to Go Next