Welcome to RDK X5 Board 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 Operation2.1 Obtain API Credentials2.2 Graphic and Text Process2.3 Configuration File Modification
Since Tongyi Qianwen, Xunfei Spark, and Baidu Qianfan AI large models require a Chinese ID card for registration, only international users are supported to use the openrouter online platform.
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 for accounts on three platforms, obtain three sets of API Keys, and write three different sets of calling code for their respective API formats.
OpenRouter solves this problem. It provides a unified API interface (compatible with OpenAI's API format). 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 any model such as GPT, Claude, Llama, etc. by modifying a model name in the configuration file without changing any code.
Cost-effectiveness: OpenRouter provides clear pricing for each model, so you can easily compare and choose the most cost-effective model to perform specific tasks.
Explore cutting-edge models: Many new and excellent open source models will be included in OpenRouter as soon as they are released, making it convenient for developers to try them out quickly.
In the largemodel project, by configuring the llm_platform parameter to openrouter, you can enable this powerful aggregation platform.
2. Practical Operation
2.1 Obtain API Credentials
Register with OpenRouter: Visit OpenRouter.ai, and register for an account using Google or email. If the link is invalid, you need to search for the "OpenRouter" platform yourself.
Top up: OpenRouter uses a prepaid model. You need to top up a small amount (e.g., $5) on the "Credits" page to start using it. Or you can directly use its free model, but there is a rate limit.
Create API Key: On the "Keys" page, click "Create Key" to generate a new API Key, and copy and save it immediately.
2.2 Graphic and Text Process
First, go to the following website. If the link is invalid, you need to search for the "OpenRouter" platform yourself, and then look for the keyword of the large model.

Register and log in to your account.
After registering your account, click to enter the model square.

You can enter
freein the search bar to find models that can be called for free.

Place the mouse on the clipboard icon next to the model to see the name to use when calling the model. Click it to copy.

Move the mouse to the right of the avatar in the upper right corner, it will expand, you can click Keys to create a key.

Click to apply for an API key.

After applying, you will get a string of API keys.

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