Skip to main content

Getting Started

Set up your first AI router and start using ModelPilot in minutes.

What You'll Learn
  • How to create and configure your first router
  • How to install and use the ModelPilot npm package
  • Basic concepts of intelligent AI routing
  • Best practices for optimization

Prerequisites

ModelPilot Account

Node.js 16+

For npm package

Basic AI/LLM Knowledge

Helpful but not required

1

Create Your First Router

Access the Dashboard
  1. Log in to your ModelPilot dashboard
  2. Navigate to Routers in the sidebar
  3. Click "Create New Router"
Configure Basic Settings
My First Router
Smart Router Recommended
How to Select the Best Models
Choosing the right models for your router maximizes performance and cost-efficiency

Recommended: Use All Available Models

For Smart Router mode, we recommend selecting "All Available Models" in the dashboard. This allows the router to:

  • • Automatically access newly added models
  • • Make optimal selections from the complete model catalog
  • • Adapt to your workload with maximum flexibility

When to Limit Model Selection:

Compliance Requirements

Data residency or regulatory constraints require specific providers

Cost Controls

Exclude expensive premium models to enforce budget limits

Testing Specific Models

Compare performance between particular models side-by-side

💡 Tip: The router automatically selects the best model for each request based on your optimization weights. You don't choose models per request.

Set Optimization Preferences
Use dashboard sliders to balance these factors (must total 100%)

Quality

Prioritizes response accuracy and sophistication. Higher values prefer premium models for better outputs.

Cost

Prioritizes affordability. Higher values prefer cheaper models to minimize API expenses.

Speed

Prioritizes fast response times. Higher values prefer models with lower latency for real-time applications.

Carbon

Prioritizes environmental impact. Higher values prefer models with lower COâ‚‚ emissions.

Default: Quality 40%, Cost 30%, Speed 20%, Carbon 10%

2

Get Your API Key

API Key Setup
  1. Navigate to Settings → API Keys
  2. Click "Generate New API Key"
  3. Copy and securely store your API key
  4. Note your Router ID from the router page

Important: Keep your API key secure. Never commit it to version control.

3

Install the NPM Package

bash
npm install modelpilot

Or with yarn:

bash
yarn add modelpilot
4

Write Your First Code

Basic Chat Completion
javascript
import ModelPilot from 'modelpilot';

const client = new ModelPilot({
  apiKey: 'mp_your_api_key_here',
  routerId: 'your_router_id_here',
});

async function chatExample() {
  const completion = await client.chat.completions.create({
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'What is the capital of France?' },
    ],
  });

  console.log(completion.choices[0].message.content);
  // Output: "The capital of France is Paris."
}

chatExample();
Streaming Response
javascript
async function streamingExample() {
  const stream = await client.chat.completions.create({
    messages: [
      { role: 'user', content: 'Tell me a short story about a robot.' },
    ],
    stream: true,
  });

  for await (const chunk of stream) {
    const content = chunk.choices[0]?.delta?.content || '';
    process.stdout.write(content);
  }
}

streamingExample();
5

Set Up Environment Variables

Create .env File
bash
MODELPILOT_API_KEY=mp_your_api_key_here
MODELPILOT_ROUTER_ID=your_router_id_here

Then use in your code:

javascript
import ModelPilot from 'modelpilot';

const client = new ModelPilot({
  apiKey: process.env.MODELPILOT_API_KEY,
  routerId: process.env.MODELPILOT_ROUTER_ID,
});

Next Steps

Need Help?

Join our community or reach out to support