Docs

The future will bring us hundreds of language models and dozens of providers for each. How will you choose the best?

Prioritize price or performance. RouterAI provide front-end models that are the best for your use case.

Seamlessly integrated API. Integrate to use AI with RouterAI's partners without efforts.


Supported Models

We currently support selecting supported models in the playground and using them on partner platforms.


OAuth PKCE

Users can connect to RouterAI in one click using Proof Key for Code Exchange (PKCE).

  1. Send your user to https://routerai.net/auth?callback_url=YOUR_SITE_URL
  • You can optionally include a code_challenge (random password up to 256 digits) for extra security.
  • For maximum security, we recommend also setting code_challenge_method to S256, and then setting code_challenge to the base64 encoding of the sha256 hash of code_verifier, which you will submit in Step 2. More info in Auth0's docs.
  1. Once logged in, they'll be redirected back to your site with a code in the URL. Make an API call (can be frontend or backend) to exchange the code for a user-controlled API key. And that's it for PKCE!
  • Look for the code query parameter, e.g. ?code=....
fetch('https://routerai.net/api/v1/auth/keys', {
  method: 'POST',
  body: JSON.stringify({
    code: $CODE_FROM_QUERY_PARAM,
    code_verifier: $CODE_VERIFIER, // Only needed if you sent a code_challenge in Step 1
  }),
});
  1. A fresh API key will be in the result under "key". Store it securely and make OpenAI-style requests:
fetch("https://routerai.net/api/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${RouterAI_API_KEY}`,
    "HTTP-Referer": `${YOUR_SITE_URL}`, // Optional, for including your app on routerai.net rankings.
    "X-Title": `${YOUR_SITE_NAME}`, // Optional. Shows in rankings on routerai.net
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "model": "gpt-3.5-turbo-0301",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"},
    ],
  })
});

You can use JavaScript or any server-side framework.