This guide will walk you through setting up your account, generating API credentials, and making your first request using Javascript, Python, or standard CLI tools.
Step 1: Generate an API Key
- Sign in to your Michi Dashboard.
- Create a new Project.
- Under API Keys, generate a new key.
Ensure you copy the API key immediately and store it securely. You will use it to authorize requests as a Bearer token.
Select your preferred language below to view the client implementation code:
💻 Javascript / Node.js
First, install the standard openai library:
Initialize the client with the Michi endpoint:
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.MICHI_API_KEY, // Your Michi Key
baseURL: "https://api.michiai.co"
});
async function run() {
const stream = await client.chat.completions.create({
model: "openai/gpt-4o-mini", // Route to GPT-4o Mini
messages: [{ role: "user", content: "How does routing work?" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
}
run();
🐍 Python
Install the package:
Implement the completions request:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("MICHI_API_KEY"),
base_url="https://api.michiai.co"
)
response = client.chat.completions.create(
model="claude/claude-3-5-sonnet", # Route to Claude 3.5 Sonnet
messages=[
{"role": "user", "content": "Explain fallbacks in routing."}
]
)
print(response.choices[0].message.content)
🛠️ CLI / Curl
For shell scripting or command line utilities:
curl -X POST https://api.michiai.co/chat/completions \
-H "Authorization: Bearer $MICHI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"messages": [
{
"role": "user",
"content": "Hi! Pick the most cost-effective model."
}
]
}'
Step 3: Monitor Live Telemetry
Once you make your first request, open the Logs tab in your dashboard to view:
- Exact response latencies (in milliseconds)
- Total prompt & completion tokens
- Dynamic cost calculation based on selected models
- Routing status (e.g. which model was selected)