1 min read

Using litellm with Gemini in Open WebUI

Like so many others, I've grown accustomed to using the local model runner Ollama as well as proxy servers like litellm. Occasionally, I use these with the Open WebUI frontend.

This week I've been doing some explorations with the Gemini 1.5 API and since I am not a huge fan of Google MakerSuite I decided to configure litellm to use Gemini within Open WebUI. This enables me to run a local front end, store my prompts and allows me to toggle between local models and the streaming Gemini API.

The litellm docs are pretty clear, and while this isn't challenging to figure out, it's ever so slightly vague so here are the required settings to get it working:

Add a model
gemini/gemini-1.5-pro-latest

Model name
gemini/gemini-1.5-pro-latest

API Base URL
https://generativelanguage.googleapis.com/v1beta/models/

API Key
YOUR_GEMINI_KEY

Assumptions

You've got access to the Gemini API, created an API Key, run the list_models Python method or this cURL command with YOUR_API_KEY to confirm model access:

curl 'https://generativelanguage.googleapis.com/v1beta/models?key=YOUR_API_KEY'

Note: Keep track of new Google models / URLs.