Welcome to RDK S100(P) Board repository
1.OpenRouter large model API aggregation platform
4. OpenRouter Large Model API Aggregation Platform Text Interaction Tutorial
4. OpenRouter Large Model API Aggregation Platform Text Interaction TutorialConcept Introduction1.1 What is "OpenRouter"?2. Practical Operations2.1 Obtain API Credentials2.2 Graphical Process2.3 Configuration File Modification
Concept Introduction
1.1 What is "OpenRouter"?
OpenRouter is a large model API aggregation platform. You can think of it as a "universal remote control for large models". Normally, if you want to use OpenAI's GPT-4, Anthropic's Claude-3, and Google's Gemini, you need to register accounts on three platforms separately, obtain three sets of API Keys, and write three different sets of calling code for their respective API formats.
However, OpenRouter solves this problem. It provides a unified API interface (compatible with OpenAI's API format), where you only need one OpenRouter API Key to call all the above models and hundreds of other open-source and closed-source models through this single entry point.
The core advantages of integrating OpenRouter in the largemodel project are:
- Ultimate Flexibility: You can seamlessly switch between GPT, Claude, Llama, and any other models by simply modifying a model name in the configuration file, without changing any code.
- Cost-effectiveness: OpenRouter provides clear pricing for each model, allowing you to easily compare and select the most cost-effective model to perform specific tasks.
- Explore Cutting-edge Models: Many new and excellent open-source models are included on OpenRouter as soon as they are released, allowing developers to quickly try them out.
In the largemodel project, you can enable this powerful aggregation platform by configuring the llm_platform parameter to openrouter.
2. Practical Operations
2.1 Obtain API Credentials
- Register for OpenRouter: Visit OpenRouter.ai and register an account using Google or email. If the link is not working, you need to search for "OpenRouter" platform yourself.
- Top Up: OpenRouter uses a prepayment model. You need to top up a small amount (e.g., $5) on the "Credits" page before you can start using it. Alternatively, you can use the free models they provide, but there are rate limits.
- Create API Key: On the "Keys" page, click "Create Key" to generate a new API Key and immediately copy and save it.
2.2 Graphical Process
- First, visit the following website. If the link is not working, you need to search for "OpenRouter" platform yourself, then look for large model keywords.

- Register and log in to your account
- After registering your account, click to enter the model marketplace

- You can type "free" in the search bar to find models that can be called for free.

- Hover your mouse over the clipboard icon next to the model to see the name used when calling the model, click once to copy it.

- Move your mouse to the top right corner next to the avatar, it will expand, you can click Keys to go in and create a key.

- Click to apply for API key

- After applying, you will get a string of API key

2.3 Configuration File Modification
Open
large_model_interface.yaml:# Open configuration filevim ~/yahboom_ws/src/largemodel/config/large_model_interface.yamlThen change sk-xxxxxxxxxx in openrouter_api_key to the API key you just copied.
openrouter_model is used to configure the large model for conversation.
xxxxxxxxxx# OpenRouter platform configurationopenrouter_api_key: "sk-xxxxxxxxxxxxxxxxxxx"openrouter_model: "moonshotai/kimi-k2:free" # Model to use, for example "google/gemini-pro-vision"Open
yahboom.yaml:xxxxxxxxxx# Open yahboom configuration filevim ~/yahboom_ws/src/largemodel/config/yahboom.yamlSwitch Platform: Modify the
llm_platformparameter toopenrouter.xxxxxxxxxx# Set large model platform to openrouterllm_platform'openrouter'
After switching the platform parameters, return to the workspace and recompile to take effect.