Quickstart

Quickstart

Follow these steps to make your first request using KushRouter with both OpenAI and Anthropic-compatible endpoints.

1) Get an API key

Create an API key in the dashboard. Keep it secret.

2) Call OpenAI Chat Completions (streaming)

import OpenAI from 'openai';
 
const openai = new OpenAI({
  apiKey: process.env.KUSHROUTER_API_KEY!,
  baseURL: 'https://api.kushrouter.com/api/openai/v1',
});
 
const stream = await openai.chat.completions.create({
  model: 'gpt-5-mini-2025-08-07',
  messages: [
    { role: 'user', content: 'Say hello from a quickstart!' }
  ],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices?.[0]?.delta?.content ?? '');
}

3) Call OpenAI Responses (non-streaming)

curl https://api.kushrouter.com/api/openai/v1/responses \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-2024-11-20",
    "input": "Say hello"
  }'

4) Call Anthropic Messages (streaming)

import Anthropic from '@anthropic-ai/sdk';
 
const anthropic = new Anthropic({
  apiKey: process.env.KUSHROUTER_API_KEY!,
  baseURL: 'https://api.kushrouter.com/api/anthropic/v1',
});
 
const r = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  max_tokens: 128,
  messages: [{ role: 'user', content: [{ type: 'text', text: 'Say hello' }] }],
  stream: true,
});
for await (const e of r) {
  if (e.type === 'content_block_delta' && e.delta?.type === 'text_delta') {
    process.stdout.write(e.delta.text);
  }
}

5) Next steps