Skip to content

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

The Gemini series of large models might be underestimated. Whether in terms of model capabilities, free usage quotas, or service stability, it is no less impressive than other mainstream models. Especially its developer platform, Google AI Studio, not only has a user-friendly interface and easy operation but also offers a very generous free usage quota. For this reason, Gemini has become my primary large model in use today.

It's worth mentioning that Gemini is also compatible with OpenAI's API interface specifications. This means that in many applications that support the OpenAI API, you can seamlessly switch to Gemini with simple configuration changes. This might be something many people are not yet aware of.

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

Register for a Free Google Account and Obtain the Gemini API KEY

  1. First, you need a Google account. If you don't have one yet, you can register for free using a phone number. The entire process is completely free, but please note that you need to have access to a scientific internet connection to access the relevant services.
  2. After registering and logging into your Google account, visit Google AI Studio: https://aistudio.google.com/
  3. Google AI Studio has access restrictions for certain countries/regions. If you see the following prompt page, it means the region of your current "proxy" node is restricted. Try switching to nodes in other countries/regions until you can access it normally. If this interface appears, it means the proxy node you are using is not allowed; please switch to a node in another country
  4. After successful access, you will see an interface similar to the one below, indicating that you can start using Google AI Studio. If you see this interface, it means it's available
  5. Next, we need to obtain the API Key. As shown in the image below, click the Get API key button in the upper right corner of the page. If you haven't created one before, the system may guide you to create a project first and then generate the API Key. Just follow the prompts. Copy the API key here; if no key exists, create one as instructed

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

  1. Open pyVideoTrans and locate the configuration section under 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 you 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 wish to use. You can find these model names in 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 image
  5. Then, select the Gemini model you wish to use currently from the model list. The effect after filling in the information
  6. After completing the above steps, click the "Save" button.
  7. Test Connection: If you have already set up a valid network proxy on the main interface of pyVideoTrans, or if your computer is configured with a global proxy (system proxy), you can now click the "Test" button. If the test passes without errors, it means the configuration is successful, and the Gemini API is ready to use in pyVideoTrans.

What to Do If There Is a Network Connection Error?

If you see a network connection-related error message after clicking "Test," the issue is likely with the network proxy configuration.

  1. First, ensure that the configuration has been saved.
  2. Then, check the scientific internet tool you are using:
    • Is "Auto-configure system proxy" or "Global proxy" mode enabled? If not, try enabling it and test again.
    • Manual Proxy Configuration: If you do not want or cannot enable global proxy, you can find the local HTTP proxy address and port number provided by your scientific internet tool. The format is usually http://IP_address:port. Enter this complete address into the "Network Proxy" text box on the main interface of pyVideoTrans. For example, the default local proxy address for some tools might be http://127.0.0.1:10808. Proxy addresses generally start with http://127.0.0.1, followed by a colon and the port number

Most scientific internet tools provide a local proxy IP address and port number. 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 enter the complete http://127.0.0.1:port_number into the network proxy settings of pyVideoTrans.

Here are some examples of 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 have different default port numbers; 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. If this tool's default port is 7890, then you need to enter 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.