Skip to content
All use cases
Side-project chatbot

Build a free chatbot for a side project

Stream replies from anyrouter/free with the AI SDK. No credit deduction, and one model id that fails over between free models.

01

The problem

What this is for

A demo chatbot dies the day its one free model gets rate-limited, and a paid key on a public page is a bill waiting to happen.

02

What to do

Three steps, then copy

  1. 1.Create a key and keep it on your server. Go ($2/mo) or a donated key raises the free cap to 1,000 requests/day.
  2. 2.npm install @anyr/ai-sdk-provider ai, then stream with anyrouter/free.
  3. 3.Read the model field in the response or Dashboard → Logs to see which free model answered.
streamText
ts
import { createAnyRouter } from "@anyr/ai-sdk-provider"
import { streamText } from "ai"

const anyrouter = createAnyRouter()

const result = streamText({
  model: anyrouter("anyrouter/free"),
  system: "You are a friendly help bot for my project.",
  prompt: "How do I reset my password?",
})

for await (const textPart of result.textStream) {
  process.stdout.write(textPart)
}
curl · anyrouter/free
bash
curl https://anyrouter.dev/api/v1/chat/completions \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anyrouter/free",
    "messages": [{ "role": "user", "content": "Say hello in one sentence." }]
  }'

Ready to try it

The guide has the full walkthrough. Sign up if you still need a key.