Getting Started
Set up your first AI router and start using ModelPilot in minutes.
- 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
Create Your First Router
- Log in to your ModelPilot dashboard
- Navigate to Routers in the sidebar
- Click "Create New Router"
My First RouterSmart Router RecommendedRecommended: 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.
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%
Get Your API Key
- Navigate to Settings → API Keys
- Click "Generate New API Key"
- Copy and securely store your API key
- Note your Router ID from the router page
Important: Keep your API key secure. Never commit it to version control.
Install the NPM Package
npm install modelpilotOr with yarn:
yarn add modelpilotWrite Your First Code
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();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();Set Up Environment Variables
MODELPILOT_API_KEY=mp_your_api_key_here
MODELPILOT_ROUTER_ID=your_router_id_hereThen use in your code:
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