Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions orcarouter_chat/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ORCAROUTER_API_KEY=sk-orca-replace-me
8 changes: 8 additions & 0 deletions orcarouter_chat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
assets/external/
.states
.web
*.db
__pycache__/
*.py[cod]
.env
.venv/
50 changes: 50 additions & 0 deletions orcarouter_chat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# OrcaRouter chat

A minimal Reflex chat app that calls [OrcaRouter](https://www.orcarouter.ai),
an OpenAI-compatible LLM gateway, and lets you switch between adaptive routing
(`orcarouter/auto`) and specific upstream models from a dropdown -- same API
key, same endpoint.

The model dropdown is populated at startup from OrcaRouter's public pricing
catalog (`https://www.orcarouter.ai/api/pricing`, no auth required), so new
models added on the server side show up the next time you click **Refresh**.
If the catalog endpoint is unreachable the app falls back to a curated list of
flagship models.

## Setup

1. Get an API key at <https://www.orcarouter.ai/console> (the key starts with
`sk-orca-`).
2. Copy the example env file and paste your key:
```bash
cp .env.example .env
# then edit .env and set ORCAROUTER_API_KEY=sk-orca-...
```
3. Install dependencies and run:
```bash
pip install -r requirements.txt
reflex run
```

Open <http://localhost:3000>, pick a model from the dropdown, and start
chatting.

## What this example demonstrates

- Using OrcaRouter as a drop-in OpenAI-compatible provider
(`AsyncOpenAI(base_url="https://api.orcarouter.ai/v1", api_key=...)`).
- Switching between `orcarouter/auto` (adaptive routing) and specific upstream
models (`openai/...`, `anthropic/...`, ...) without changing client code.
- Passing OrcaRouter-specific routing preferences via the `extra_body` field
(`{"models": [...], "route": "fallback"}`).
- Attaching attribution headers (`HTTP-Referer`, `X-Title`) so OrcaRouter can
report which client originated the request.
- Skipping `temperature` for reasoning models (Claude Opus, GPT-5 family,
DeepSeek reasoner) which reject the parameter.

## References

- OrcaRouter docs: <https://docs.orcarouter.ai>
- Routing strategies and `orcarouter/auto`:
<https://www.orcarouter.ai/console/routing>
- Full model catalog: <https://www.orcarouter.ai/models>
Binary file added orcarouter_chat/assets/favicon.ico
Binary file not shown.
Empty file.
Loading