/go-gemini-proxy-openai

Proxy OpenAI client calls to Gemini, for Autogen

Primary LanguageGo

OpenAI Gemini Adapter

Use OpenAI client with Gemini endpoint.

Getting Started

Prerequisites

Obtain an API Key from Google AI Studio: https://aistudio.google.com/app/apikey

Basic Script

Use the OpenAI client to interact with the Gemini endpoint.

from openai import OpenAI

MODEL = "models/gemini-pro"
client = OpenAI(base_url="http://0.0.0.0:8080", api_key="<your_api_key>")


chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model=MODEL,
)
print(chat_completion.choices[0].message.content)