Welcome to RDK X5 MagicBox repository
1. OpenRouter Large Model API Aggregation Platform
OpenRouter Large Model API Aggregation Platform - Text Interaction
OpenRouter Large Model API Aggregation Platform - Text InteractionConcept Introduction1.1 What is "OpenRouter"?2. Practical Operations2.1 Obtaining API Credentials2.2 Step-by-Step Guide with Images2.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 language models". Normally, if you want to use OpenAI's GPT-4, Anthropic's Claude-3, and Google's Gemini, you would need to register accounts on three separate platforms, obtain three sets of API keys, and write three different sets of API call code tailored to each platform's unique format.
OpenRouter solves this problem. It provides a unified API interface (compatible with OpenAI's API format). With just one OpenRouter API key, you can access all the models mentioned above plus hundreds of other open-source and closed-source models through a single entry point.
The core advantages of integrating OpenRouter into the largemodel project are:
- Ultimate Flexibility: You can seamlessly switch between GPT, Claude, Llama, and any other model by simply changing the model name in the configuration file, without modifying any code.
- Cost Efficiency: OpenRouter provides clear pricing for each model, making it easy to compare and select the most cost-effective model for specific tasks.
- Explore Cutting-Edge Models: Many new and excellent open-source models are added to OpenRouter first, allowing developers to quickly try out new releases.
In the largemodel project, you can enable this powerful aggregation platform by configuring the llm_platform parameter to openrouter.
2. Practical Operations
2.1 Obtaining API Credentials
- Register for OpenRouter: Visit OpenRouter.ai and register an account using Google or email. If the link is broken, you need to search for the "OpenRouter" platform yourself.
- Add Credits: OpenRouter uses a prepaid model. You need to add a small amount of credits (e.g., $5) on the "Credits" page before you can start using it. Alternatively, you can use their free models directly, but there are rate limits.
- Create an API Key: On the "Keys" page, click "Create Key" to generate a new API key, and immediately copy and save it.
2.2 Step-by-Step Guide with Images
- First, visit the following website. If the link is broken, you need to search for the "OpenRouter" platform yourself and then look for keywords related to large language models.

- Register and log in to your account
- After registering, click to enter the Model Plaza

- 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 a model, and you can see the name to use when calling the model. Click to copy it.

- Move your mouse to the avatar in the upper right corner, and a menu will expand. You can click on "Keys" to create a key.

- Click to apply for an API key

- After applying, you will receive an API key string

2.3 Configuration File Modification
Open
large_model_interface.yaml:vim ~/yahboomcar_ws/src/largemodel/config/large_model_interface.yamlThen replace
sk-xxxxxxxxxxinopenrouter_api_keywith the API key you just copied.openrouter_modelis used to configure the large model for conversations.xxxxxxxxxx# OpenRouter Platform Configurationopenrouter_api_key: "sk-xxxxxxxxxxxxxxxxxxx"openrouter_model: "moonshotai/kimi-k2:free" # Model to use, e.g., "google/gemini-pro-vision"Open
yahboom.yaml:xxxxxxxxxxvim ~/yahboomcar_ws/src/largemodel/config/yahboom.yamlSwitch Platform: Change the
llm_platformparameter toopenrouter.xxxxxxxxxxllm_platform'openrouter'
After switching the platform parameter, go back to the workspace and recompile for the changes to take effect.