Welcome to Jetson Orin NANO Developer Kit repository
02.OpenRouter large model API aggregation platform
4. OpenRouter Large Model API Aggregation Platform Text Interaction
4. OpenRouter Large Model API Aggregation Platform Text InteractionConcept Introduction1.1 What Is "OpenRouter"?2. Practical Operations2.1 Obtaining API Credentials2.2 Illustrated 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 the three platforms separately, obtain three sets of API keys, and write three different sets of calling code for their different 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 of the above models and hundreds of other open source and closed source models through this single entry point.
The core advantages of integrating OpenRouter into the largemodel project are:
Ultimate flexibility: you can seamlessly switch between any model such as GPT, Claude, and Llama by changing a model name in the configuration file, without changing any code.
Cost effectiveness: OpenRouter provides clear pricing for each model, so you can conveniently compare and select the most cost-effective model to execute a specific task.
Exploring cutting-edge models: many new and excellent open source models are included by OpenRouter as soon as possible, which makes it convenient for developers to try them quickly.
In the largemodel project, set the llm_platform parameter to openrouter to enable this powerful aggregation platform.
2. Practical Operations
2.1 Obtaining API Credentials
Register for OpenRouter: Visit OpenRouter.ai and register an account with Google or an email address. 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 (for example, 5 US dollars) on the "Credits" page before you can start using it. Or you can directly use the models it provides for free, but there is a rate limit.
Create an API Key: On the "Keys" page, click "Create Key" to generate a new API Key, and copy and save it immediately.
2.2 Illustrated Process
First, enter the following website. If the link is invalid, you need to search for the "OpenRouter" platform yourself, and then look for the keywords of large models.

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

Enter free in the search bar, and you can find the models that can be called for free.

Hover the mouse over the clipboard icon next to the model, and you can see the name to use when calling the model; click it once to copy it.

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

Click to apply for an api key

After applying, you will get a string of api key

2.3 Configuration File Modification
Open
large_model_interface.yaml:vim ~/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 configuration (OpenRouter Platform Configuration)openrouter_api_key: "sk-xxxxxxxxxxxxxxxxxxx"openrouter_model: "moonshotai/kimi-k2:free" # Model to use, for example "google/gemini-pro-vision"Open
yahboom.yaml:xxxxxxxxxxvim ~/yahboom_ws/src/largemodel/config/yahboom.yamlSwitch the platform: Change the
llm_platformparameter toopenrouter.xxxxxxxxxxllm_platform'openrouter'
After switching the platform parameters, return to the workspace and compile again for the changes to take effect.