Principles

In the future, there will be many models - from language to image - and providers. How will you pick the best one?

Quick Start

To get started, you can use 1Router via API like this:

fetch("https://1router.com/api/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${1ROUTER_API_KEY}`,
    "HTTP-Referer": `${YOUR_SITE_URL}`, // Optional, for including your app on 1router.com rankings.
    "X-Title": `${YOUR_SITE_NAME}`, // Optional. Shows in rankings on 1router.com.
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "model": "meta-llama/llama-3.1-405b-instruct",
    "messages": [
      {
        "role": "user",
        "content": "What is the meaning of life?"
      }
    ]
  })
});

You can also use 1Router with OpenAI’s client API:

import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "https://1router.com/api/v1",
  apiKey: $ROUTER_API_KEY,
  defaultHeaders: {
    "HTTP-Referer": $YOUR_SITE_URL, // Optional, for including your app on 1router.com rankings.
    "X-Title": $YOUR_SITE_NAME, // Optional. Shows in rankings on 1router.com.
  }
});

async function main() {
  const completion = await openai.chat.completions.create({
    model: "meta-llama/llama-3.1-405b-instruct",
    messages: [
      {
        "role": "user",
        "content": "What is the meaning of life?"
      }
    ]
  });

  console.log(completion.choices[0].message);
}

main();