OpenRouter and free models
What OpenRouter is, how to get an API key, and how to use free LLMs and embedding models in your own projects.
The big idea
There are hundreds of LLMs from many companies, each with its own website, account and bill. OpenRouter is one door to all of them: one account, one API key, one way of calling. Change one word (the model name) and you are talking to a different model.
Free and paid models
- Free models have
:freeat the end of their name, for exampleliquid/lfm-2.5-2.6b:free. They cost nothing but have daily request limits and can be slower or busier. Some free providers may keep your prompts, so never send private data to them. - Paid models, such as GPT from OpenAI or Claude from Anthropic, are usually stronger. You add a little credit to your OpenRouter account and pay per token used. For learning, a few dollars goes a long way.
This course uses free models everywhere, so you can finish it without paying anything. Browse all models at openrouter.ai/models.
Disclaimer about the models in this course. GraphRAG Chats and the examples in this course use
liquid/lfm-2.5-2.6b:freefor answers andliquid/lfm-2.5-embedding-350m:freefor embeddings. Free models are often retired or renamed, so these may no longer exist when you read this. Always check openrouter.ai/models for current free models, and swap in a new name wherever the course uses one. If you change the embedding model, pick one that returns 1024 numbers, or change the vector index size to match (Chapter 8).
Where it lives in GraphRAG Chats
At the top of backend/src/backend/openrouter_client.py you will find two lines that pick the models:
EMBEDDING_MODEL = "liquid/lfm-2.5-embedding-350m:free"
CHAT_MODEL = "liquid/lfm-2.5-2.6b:free"
The first turns text into numbers (Chapter 6). The second writes the answers.
Practice: switch on the AI features
- Sign up at openrouter.ai and create a key at openrouter.ai/keys.
- Paste it into
.envafterOPENROUTER_API_KEY=. Never share this key or commit it to Git. - Restart the app:
docker compose down, thendocker compose up. - Open Grocery Store Catalog and click Generate embeddings.
- Click Search to open the chat panel and ask: chocolate protein bar without any sugar.
- Now ask something the graph cannot know, like what is the shop's phone number?
You are done when step 5 gives an answer with highlighted nodes, and step 6 says the answer is not in the graph.
Check yourself
- What does OpenRouter give you that calling each company directly does not?
- How can you tell a model is free?
- Why should you keep your API key out of Git?
- One key and one way of calling for hundreds of models.
- Its name ends in
:free. - Anyone who finds it can use it, and for paid models, spend your money.
Done reading and tried the practice task? Mark the chapter complete to save your progress.