Skip to content

Gemini API Compatible with OpenAI Interface: How to Configure and Use for Free in Compatible Applications

The Gemini series of large models might be underestimated. Whether in terms of model capabilities, free quota, or service stability, it is no less inferior to other mainstream models. In particular, its developer backend, Google AI Studio, is not only user-friendly and easy to operate but also offers a very generous free usage quota. For this reason, Gemini has become my primary large model.

It's worth mentioning that Gemini is also compatible with OpenAI's API interface specification. This means you can seamlessly switch to Gemini in many applications that support the OpenAI API by simply modifying the configuration. Many friends might not be aware of this point.

Below, I will take pyVideoTrans as an example to demonstrate how to configure it to use the Gemini API.

Register for a Free Google Account and Get a Gemini API KEY

  1. First, you need a Google account. If you don't have one, you can register for free using your phone number. The entire process is free of charge, but please note that you need to have a "scientific internet access" environment (VPN or proxy) to access related services.
  2. After registering and logging into your Google account, please visit Google AI Studio: https://aistudio.google.com/
  3. Google AI Studio has access restrictions in some countries/regions. If you see the following prompt page, it means that the region of your current "ladder" node (VPN/proxy server location) is restricted. Please try switching to a node in another country/region until you can access it normally. This interface indicates that the proxy node used is not allowed to access, please switch to another country's node
  4. After successful access, you will see an interface similar to the one below, indicating that you can start using Google AI Studio. Seeing this interface means it is available
  5. Next, we need to get the API Key. As shown in the figure below, click the Get API key button in the upper right corner of the page. If you haven't created one before, the system might guide you to create a project first and then generate an API Key. Please follow the prompts. Click here to copy the api key, if no key exists, create one as instructed

Fill in the Information in pyVideoTrans's OpenAI API and Compatible AI Settings

  1. Open pyVideoTrans, find the configuration section for Menu -- Translation Settings -- OpenAI API and Compatible AI.
  2. Enter the Gemini OpenAI compatible API address https://generativelanguage.googleapis.com/v1beta/openai/ into the API URL input box.
  3. Paste the Gemini API KEY copied in the previous step into the SK input box.
  4. In the Fill in all available models text box below, enter the names of the Gemini models you want to use. You can find these model names from the Google AI Studio interface (e.g., gemini-2.5-flash-preview-04-17,gemini-2.5-pro-preview-05-06,gemini-2.0-flash). If you need to add multiple models, separate them with English commas ,. Copy the desired model names as shown in the figure
  5. Then, select the Gemini model you want to use currently from the model list. Effect after filling
  6. After completing the above entries, click the "Save" button.
  7. Test Connection: If you have set up a valid network proxy on the pyVideoTrans main interface, or your computer has configured a global proxy (system proxy), you can click the "Test" button at this point. If the test passes without errors, it means the configuration is successful and the Gemini API can be used normally in pyVideoTrans.

What to Do if a Network Connection Error Occurs?

If clicking "Test" results in a network connection-related error message, the problem is most likely with the network proxy configuration.

  1. First, ensure that the configuration has been saved.
  2. Then, check the scientific internet access tool you are using:
    • Is "Automatically configure system proxy" or "Global proxy" mode enabled? If not, try enabling it and test again.
    • Manually configure proxy: If you don't want to or cannot enable a global proxy, you can find the local HTTP proxy address and port number provided by your scientific internet access tool. The format is usually http://IP Address:Port Number. Fill this address completely into the "Network Proxy" text box on the pyVideoTrans main interface. For example, the default local proxy address for some tools might be http://127.0.0.1:10808. Proxy address format is generally http://127.0.0.1 followed by an English colon and port number

Most scientific internet access tools provide a local proxy IP address and port number. Among them, the IP address is usually 127.0.0.1 (representing the local machine), and you need to find the specific port number corresponding to the tool. Then fill the complete http://127.0.0.1:Port Number into the network proxy settings of pyVideoTrans.

Here are some examples of default port numbers for common scientific tools:

  • If your tool's default port is 10808, the proxy address is http://127.0.0.1:10808. Different scientific tools provide different default ports, this tool's default port is 10808

  • If your tool's default port is 7890, the proxy address is http://127.0.0.1:7890. This tool's default port is 7890, so you need to fill in http://127.0.0.1:7890

After correctly configuring the proxy, test the connection again, and you should be able to successfully use the Gemini API.