# 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.

Stream anyrouter/free replies with the AI SDK

**Slug**: `free-chatbot`  
**URL**: https://anyrouter.dev/use-cases/free-chatbot  
**Markdown**: https://anyrouter.dev/use-cases/free-chatbot.md  
**Short link**: https://anyrouter.dev/u/free-chatbot  

## Why use this

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.

## Set it up

1. Create a key and keep it on your server, never in the browser.
2. npm install @anyr/ai-sdk-provider ai, then stream with anyrouter/free.
3. Read the model field in the response or Dashboard → Logs to see which free model answered.

## Code

### 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." }]
  }'
```

## Related

- [free-llm-api](https://anyrouter.dev/use-cases/free-llm-api)
- [ai-sdk](https://anyrouter.dev/use-cases/ai-sdk)
- [go-plan](https://anyrouter.dev/use-cases/go-plan)
