{"id":25832600,"url":"https://github.com/lenml/generative-ai-openai-api-server","last_synced_at":"2026-04-11T16:33:03.308Z","repository":{"id":266642464,"uuid":"897509785","full_name":"lenML/generative-ai-openai-api-server","owner":"lenML","description":"converts Gemini API to OpenAI API format.","archived":false,"fork":false,"pushed_at":"2025-01-14T09:49:12.000Z","size":178,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T10:55:00.634Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lenML.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-02T18:52:10.000Z","updated_at":"2025-01-14T09:49:16.000Z","dependencies_parsed_at":"2024-12-12T12:29:49.007Z","dependency_job_id":null,"html_url":"https://github.com/lenML/generative-ai-openai-api-server","commit_stats":null,"previous_names":["lenml/generative-ai-openai-api-server"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenML%2Fgenerative-ai-openai-api-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenML%2Fgenerative-ai-openai-api-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenML%2Fgenerative-ai-openai-api-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenML%2Fgenerative-ai-openai-api-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lenML","download_url":"https://codeload.github.com/lenML/generative-ai-openai-api-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241245496,"owners_count":19933295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-28T21:40:03.929Z","updated_at":"2025-11-24T19:05:57.598Z","avatar_url":"https://github.com/lenML.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Generative AI OpenAI API Server\n\nA lightweight server that translates Gemini API calls into OpenAI API-compatible format.\n\n## Features\nThis project provides an alternative to using Google's `/v1beta/openai/` endpoint by addressing its limitations, offering enhanced functionality, and extending support for key features.\n\n### Why not use `/v1beta/openai/` directly?\nWhile Google does provide a partially OpenAI-compatible API, there are significant limitations:\n1. **Unsupported Endpoints**: Many endpoints, such as `/v1/models`, are not available.\n2. **Limited Parameters**: Important parameters like `\"frequency_penalty\"`, `\"presence_penalty\"`, and `\"stop\"` are not supported. When unsupported parameters are included, the API throws an error instead of gracefully ignoring them.\n3. **Missing Advanced Features**: Features like context caching and advanced safety configurations from Gemini API are absent.\n\nThis server addresses these issues by acting as a middleware between your application and the Gemini API.\n\n\n## Getting Started\n\n### Prerequisites\n- Download the latest release binary.\n\n### Steps to Use\n1. Create a configuration file (`genai.config.json`).\n2. Run the server. The default port is `4949`.\n\n#### Custom Config\n```\nmain.exe -c my_owner.config.json\n```\n\n## Configuration\n\nThe server uses a JSON-based configuration file. Below is a basic example:  \n```json\n{\n  \"api_keys\": [\"sk-xxx\"],\n  \"server\": {\n    \"port\": 4949\n  }\n}\n```  \n\n### Full Configuration Options\nHere is a complete list of configurable parameters:\n```ts  \ntype Params = {\n  api_keys: string[];\n  server?: {\n    port?: number;\n  };\n  no_docs?: boolean;\n  retry?: {\n    enabled?: boolean;\n    retries?: number;\n    factor?: number;\n    minTimeout?: number;\n    maxTimeout?: number;\n  };\n  debug?: {\n    stream?: {\n      log?: boolean;\n    };\n  };\n  bodyLimit?: number;\n  // error catcher settings\n  error?: {\n    /**\n     * throw: 默认模式，直接报错走 fastify 的 error catch\n     * json: 将会以 json 形式返回错误\n     * str: 将会以 str 形式返回错误，并且只保留 message\n     */\n    mode?: \"throw\" | \"json\" | \"str\";\n  };\n};\n```\n\n## Supported Endpoints\n\nThe server currently supports the following endpoints:\n- **`/v1/models`**: Retrieve available model list.\n- **`/v1/embeddings`**: Generate vector embeddings for input text.\n- **`/v1/chat/completions`**: Chat-based text completions.\n\n\u003e **Note**: `/v1/completions` is not supported because Gemini models do not support completion functionality, and Google's PaLM model (which does) is likely to be deprecated.\n\n\n## Roadmap\n\n- [x] v1\n- [x] 支持配置多个 api key ，并且可以轮询\n  - [ ] 权重分配\n  - [ ] 重试/调度/logs\n- [ ] 支持配置和切换代理\n\n## Building the Project\n\n```\npnpm run build:ci\n```\n\n\n## License\n\nThis project is licensed under the **MIT License**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenml%2Fgenerative-ai-openai-api-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flenml%2Fgenerative-ai-openai-api-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenml%2Fgenerative-ai-openai-api-server/lists"}