Skip to main content
IronLabs Custom Router lets you train a personalized model selection system on your own data. The router learns from your examples to automatically pick the most appropriate AI model for each task — improving accuracy and reducing costs.

Python SDK

pip install ironlabs

Node.js SDK

npm install ironlabs

When to use Custom Router

  • Cost optimization — route simple tasks to cheaper models, reserve powerful ones for complex requests
  • Domain specialization — match prompts to models that excel in your domain (code, legal, creative writing, etc.)
  • Multi-model pipelines — let the router decide which model handles each stage instead of hardcoding choices
  • Replace guesswork — use a data-driven system trained on your own examples instead of manual model selection

Prerequisites

Before you start, make sure you have:
  • An IronLabs API key from the Settings page
  • A training data file hosted at a publicly accessible URL (GitHub, S3, CDN, etc.)

Installation

Install the SDK for your language:

Initialize the client

Set your API key as an environment variable:
Then initialize the trainer in your code:
The client automatically picks up IRONLABS_API_KEY from your environment — no need to pass it explicitly.

Training a Custom Router

1

Prepare training data

Training data maps prompts to the ideal models for each. Supported formats are JSON and CSV — host your file at any publicly accessible URL (GitHub, S3, CDN, etc.).
You can pass multiple file URLs to combine datasets from different sources.
2

Start training

Pass one or more data URLs to kick off a training job.
Response:
3

Check training status

Poll until the job reaches completed or failed. Training typically takes a few minutes.
Response:
4

Get model details

Retrieve metadata and performance metrics for your trained model.
Response:
5

Run inference

Use your trained router to select the best model for new prompts.
Response:
Each prediction includes:
  • top_model — the recommended model for this input
  • top_prob — confidence score (0–1)
  • models — full ranked list with individual confidence scores

Complete example


Loading an existing model

Reuse a previously trained model without going through training again.

Batch processing

The predict endpoint supports up to 500 inputs per request. For larger datasets, split into chunks.

Supported data formats

Model lifecycle