Command Palette

Search for a command to run...

Quickstart

Create a key, send one request, and see it on your balance — the whole path, with the errors that usually stop it.

What you will have at the end

A key that starts with `sk-bf-`, one successful `POST /v1/chat/completions`, and a balance that has gone down by what the call actually cost. None of this needs an SDK; the first request fits in a terminal.

Two hosts answer for this product, and they are not interchangeable. The host you are reading this on serves the site, the catalogue and these pages. The `api.` host in the base URL below serves inference. A client pointed at the site host gets an HTML page back, not a completion.

  • Site host — `idroutebase.com`: catalogue, documentation, account pages.
  • API host — `api.idroutebase.com`: `/v1/models` and the POST endpoints below.

1. Find the base URL

The base URL is an origin plus `/v1`, and you do not add `/v1` a second time. Every sample on this page already places it correctly.

Base URL
https://api.idroutebase.com/v1

The model is chosen in the request body, never in the path. There is one path per operation: `chat/completions` for chat, `completions` for a raw completion, `embeddings` for vectors, and `models` for the catalogue.

2. Create an API key

Sign in, open **API keys** in your account, and create a key with a label that says where it will run — `laptop`, `ci`, `production`. The key is shown once, when it is created. Only a hash is stored afterwards, so it cannot be recovered or displayed again.

  • Put it in an environment variable, not in a source file.
  • Label it by where it runs, so revoking the right one later is obvious.
  • If it is lost, revoke it and create another — there is nothing to look up.
Shell
export IDROUTEBASE_API_KEY="sk-bf-..."

3. Check the balance

Requests are paid for from a prepaid balance. A balance at or below zero is refused with `402 no_balance` before any provider is called, and nothing is charged. Add credit first; the balance page shows what you have and what each request spent.

4. Send the first request

Pass the key as a bearer token, name a model id copied from the Models page, and send the message. Replace `<vendor>/<model-id>` with a real id — the catalogue is the only place that lists callable ones.

cURL
curl https://api.idroutebase.com/v1/chat/completions \  -H "Authorization: Bearer $IDROUTEBASE_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "<vendor>/<model-id>",    "messages": [{ "role": "user", "content": "Hello" }]  }'

The same call through an SDK: point the client at the base URL and the request and response shapes are the ones the SDK already implements.

Python
from openai import OpenAI
client = OpenAI(    base_url = "https://api.idroutebase.com/v1",    api_key  = "sk-bf-...",)
completion = client.chat.completions.create(    model    = "<vendor>/<model-id>",    messages = [{ "role": "user", "content": "Hello" }],)
print(completion.choices[0].message.content)
JavaScript
import OpenAI from "openai";
const client = new OpenAI({  baseURL: "https://api.idroutebase.com/v1",  apiKey: process.env.IDROUTEBASE_API_KEY,});
const completion = await client.chat.completions.create({  model: "<vendor>/<model-id>",  messages: [{ role: "user", content: "Hello" }],});
console.log(completion.choices[0]?.message.content);

5. Check that it worked

A successful call is `200` with text in `choices[0].message.content`. Three things are worth checking the first time, because each one answers a different question.

  • With `curl -i`, the first line is the status. A `200` body piped through a formatter can hide a `401` above it.
  • `GET /v1/models` lists the ids your key may call right now; an id that is not there will be refused.
  • The balance falls by the metered cost, and the usage page shows the request with its token counts.
Check the catalogue
curl https://api.idroutebase.com/v1/models \  -H "Authorization: Bearer $IDROUTEBASE_API_KEY"

Common first errors

  • `401 invalid_api_key` — the variable is empty, the header is not `Bearer <key>`, or the key was revoked. Print the variable's length, not its value.
  • `404 endpoint_not_found` — a doubled version prefix (a base URL that already ends in `/v1`, with `/v1` added again in the path), a path outside `models`, `chat/completions`, `completions`, `embeddings`, or the site host instead of the `api.` host.
  • `400 model_not_found` — the id is not in the catalogue or is not published today. Copy it from the Models page.
  • `400 invalid_json` — the `-d` payload is not valid JSON. On Windows, single quotes around it are the usual cause.
  • `402 no_balance` — the balance is at or below zero, so nothing was sent to a provider.

The Errors page lists every code the API returns with its status and what to do about it. Authentication covers key hygiene and rotation; Streaming covers the event shape, not just the JSON one.