百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

proxy-to-gemini

> 编程语言
开源

一个代理侧车,用于通过 OpenAI 和 Ollama API 访问 Gemini 模型

195 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个代理侧车,用于通过 OpenAI 和 Ollama API 访问 Gemini 模型

proxy-to-gemini

[!IMPORTANT]
Gemini API officially supports OpenAI API compatibility and this sidecar is no longer needed. See the blog post for more details!

A simple proxy server to access Gemini models by using other well-known APIs like OpenAI and Ollama.

Setup

Obtain a Gemini API key from the AI Studio. Then set the following environmental variable to the key.

bash
$ export GEMINI_API_KEY=

Usage with OpenAI API

Run the binary:

bash
$ docker run -p 5555:5555 -e GEMINI_API_KEY=$GEMINI_API_KEY googlegemini/proxy-to-gemini
2024/07/20 19:35:21 Starting server on :5555

Once server starts, you can access Gemini models through the proxy server by using OpenAI API and client libraries.

…

You can stream the chat responses:

…

You can create embeddings:

bash
$ curl http://127.0.0.1:5555/v1/embeddings \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-004",
    "input": ["hello"]
  }'
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        0.04824496,
        0.0117766075,
        -0.011552069,
        -0.018164534,
        -0.0026110192,
        0.05092675,
        ...
        0.0002852207,
        0.046413545
      ],
      "index": 0
    }
  ],
  "model": "text-embedding-004",
}

Known OpenAI Limitations

  • Only chat completions and embeddings are planned to be supported.
  • Tool support is work in progress.
  • Only text input and output is supported for now.
  • response_format is not supported yet.

Usage with Ollama API

bash
$ docker run -p 5555:5555 -e GEMINI_API_KEY=$GEMINI_API_KEY googlegemini/proxy-to-gemini -api=ollama
2024/07/20 19:35:21 Starting server on :5555

Once server starts, you can access Gemini models through the proxy server by using Ollama API and client libraries.

bash
$ curl http://127.0.0.1:5555/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-1.5-pro",
    "prompt": "Hello, how are you?"
  }'
{"model":"gemini-1.5-pro","response":"I'm doing well, thank you! As an AI, I don't have feelings, but I'm here and ready to assist you. \n\nHow can I help you today? \n","created_at":"2024-07-28T14:57:36.25261-07:00","prompt_eval_count":7,"eval_count":47,"done":true}

Create embeddings:

bash
$ curl http://127.0.0.1:5555/api/embed \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-004",
    "input": ["hello"]
  }'
{"model":"text-embedding-004","embeddings":[[0.04824496,0.0117766075,-0.011552069,-0.018164534,-0.0026110192,0.05092675,0.08172899,0.007869772,0.054475933,0.026131334,-0.06593486,-0.002256868,0.038781915,...]]}

Known Ollama Limitations

  • Streaming is not yet supported.
  • Images are not supported.
  • Response format is not supported.
  • Model parameters not supported by Gemini are ignored.

Notes

The list of available models are listed at Gemini API docs.

This proxy is aiming users to try out the Gemini models easily. Hence, it mainly supports text based use cases. Please refer to the Gemini SDKs for media support.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Go

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言