Calling OpenRouter large model aggregation service

Calling OpenRouter large model aggregation serviceIntroduceregisteruseCommon Errors1. Request error: -12. 401 No auth credentials found3. Stuck at "Parsing non-streaming response - Status code: 200"4. The reply is emptyThe list of currently available models is as follows:

 

Introduce

This tutorial has a high degree of operational difficulty

OpenRouter is a platform that aggregates a large number of mainstream AI language model APIs. Through the services provided by OpenRouter, we can easily switch/call various large models.

Models | OpenRouter

image-20250424161820114

Due to the policies of various large model providers, some models on OpenRouter are inaccessible, which is normal.

The charges for different large models are also determined by the policies of the large model providers.

In most cases, the free models are sufficient for testing or simple use.

register

image-20250424162436160

image-20250424162510853

image-20250424162614157

You can register using github / Google / MetaMask wallet or other email addresses

After clicking Continue, OpenRouter will send a verification link to your email.

image-20250424162942152

Click this blue button

image-20250424163045934

 

Or an email like this: image-20250513150709710

Click on the blue "API dashboard"

image-20250513150922639

This pop-up interface indicates that the registration is successful.

Next, let’s create an API key

image-20250424163511720

image-20250424163542995

The first line is the API name, which can be filled in at will

The second line is the API consumption limit and can be left blank

This API Key will only be displayed once after it is generated. Please copy the API Key immediately and write it down.

Click the button on the right to copy

image-20250424163807391

use

Let’s randomly choose a model to test

https://openrouter.ai/models

Find the models page and enter free here

image-20250424164406466

image-20250424185948787

Let’s take Google’s Gemini 2.0 model as an example

Note: Some models may fail in actual searches. Here we can just find a test marked with free.

Clicking this model may cause a black screen or freeze in some cases, but it does not affect our use.

We just need to add a /api after the link and press Enter.

For example, the link in our browser now is:

We need to change to

Then press Enter to access

Let's scroll down and find this paragraph

image-20250424190102056

Copy this model name

Then we open [Source Code Summary / 11.Network / 08.LLM / llm_test.py]

Fill in the WIFI name and password in the network_use_wlan method

The spark_api_key parameter is set to the API Key we just saved

Other parameter settings are as follows

Then we click Run

If you encounter the following error when running for the first time

This is normal, we just need to run it again

Under normal circumstances, we can see the following information output:

This means the interaction is successful!!

Common Errors

Calling the OpenRouter large model is a relatively complicated process. During the calling process, we are likely to encounter various problems.

Below we list some common abnormal situations

1. Request error: -1

Occasional errors, more likely to occur when power is first turned on

Please rerun the program

2. 401 No auth credentials found

Please check if the API KEY is entered correctly.

3. Stuck at "Parsing non-streaming response - Status code: 200"

If the program gets stuck at this step, try changing the model

4. The reply is empty

The list of currently available models is as follows:

Most models are usable. I only tested a few of the most popular models.