{"id":23969016,"url":"https://github.com/rxliuli/openai-api-proxy","last_synced_at":"2025-04-09T23:21:48.914Z","repository":{"id":254582158,"uuid":"846951078","full_name":"rxliuli/openai-api-proxy","owner":"rxliuli","description":"Provides the same proxy OpenAI API interface for different LLM models, and supports deployment to any Edge Runtime environment.","archived":false,"fork":false,"pushed_at":"2024-11-21T15:46:48.000Z","size":307,"stargazers_count":41,"open_issues_count":2,"forks_count":37,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T18:51:15.655Z","etag":null,"topics":["anthropic","gemini","openai","vertex-ai"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rxliuli.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-08-24T12:23:01.000Z","updated_at":"2025-03-10T14:00:57.000Z","dependencies_parsed_at":"2024-11-21T16:31:55.956Z","dependency_job_id":"1cfe354b-4ea0-44cd-b97a-75132312c426","html_url":"https://github.com/rxliuli/openai-api-proxy","commit_stats":null,"previous_names":["rxliuli/openai-api-proxy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxliuli%2Fopenai-api-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxliuli%2Fopenai-api-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxliuli%2Fopenai-api-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxliuli%2Fopenai-api-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxliuli","download_url":"https://codeload.github.com/rxliuli/openai-api-proxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248126413,"owners_count":21051918,"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":["anthropic","gemini","openai","vertex-ai"],"created_at":"2025-01-07T00:57:49.107Z","updated_at":"2025-04-09T23:21:48.881Z","avatar_url":"https://github.com/rxliuli.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAI API Proxy\n\n## Introduction\n\nProvides the same proxy OpenAI API interface for different LLM models, and supports deployment to any Edge Runtime environment.\n\nSupported models\n\n- [x] OpenAI\n- [x] Anthropic\n- [x] Google Vertex Anthropic\n- [x] Google Gemini\n- [x] DeepSeek\n- [x] Groq\n- [x] Cerebras\n- [x] Azure OpenAI\n- [x] Cohere\n- [x] Aliyun Bailian\n- [ ] Ollama\n- [ ] Cloudflare Workers AI\n- [ ] Coze\n\n## Deployment\n\n[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/rxliuli/openai-api-proxy)\n\nEnvironment variables\n\n- `API_KEY`: Proxy API Key, required when calling the proxy API\n- `CORS_ORIGIN`: Allowed CORS domain, e.g. `https://example.com`\n\n- OpenAI: Supports OpenAI models, e.g. `gpt-4o-mini`\n  - `OPENAI_API_KEY`: OpenAI API Key\n- VertexAI Anthropic: Supports Anthropic models on Google Vertex AI, e.g. `claude-3-5-sonnet@20240620`\n  - `VERTEX_ANTROPIC_GOOGLE_SA_CLIENT_EMAIL`: Google Cloud Service Account Email\n  - `VERTEX_ANTROPIC_GOOGLE_SA_PRIVATE_KEY`: Google Cloud Service Account Private Key\n  - `VERTEX_ANTROPIC_REGION`: Google Vertex AI Anthropic Region\n  - `VERTEX_ANTROPIC_PROJECTID`: Google Vertex AI Anthropic Project ID\n- Anthropic: Supports Anthropic models, e.g. `claude-3-5-sonnet-20240620`\n  - `ANTROPIC_API_KEY`: Anthropic API Key\n- Google Gemini: Supports Google Gemini models, e.g. `gemini-1.5-flash`\n  - `GOOGLE_GEN_AI_API_KEY`: Google Gemini API Key\n- DeepSeek: Supports DeepSeek models, e.g. `deepseek-chat`\n  - `DEEPSEEK_API_KEY`: DeepSeek API Key\n- Groq: Supports Groq models, e.g. `llama3-8b-8192`\n  - `GROQ_API_KEY`: Groq API Key\n- Cerebras: Supports Cerebras models, e.g. `llama-3-8b`\n  - `CEREBRAS_API_KEY`: Cerebras API Key\n- Azure OpenAI: Supports Azure OpenAI models, e.g. `gpt-4o-mini`\n  - `AZURE_OPENAI_API_KEY`: Azure OpenAI API Key\n  - `AZURE_OPENAI_ENDPOINT`: Azure OpenAI Endpoint\n  - `AZURE_API_VERSION`: Azure OpenAI API Version\n  - `AZURE_DEPLOYMENT_MODELS`: Azure OpenAI Deployment Models, such as `gpt-4o-mini:gpt-4o-mini-dev,gpt-35-turbo:gpt-35-dev`, represent two models, `gpt-4o-mini` and `gpt-35-turbo`, corresponding to two deployments, `gpt-4o-mini-dev` and `gpt-35-dev` respectively.\n- Cohere: Supports Cohere models, e.g. `command-r`\n  - `COHERE_API_KEY`: Cohere API Key\n- Aliyun Bailian: Supports Aliyun Bailian models, e.g. `qwen-max`\n  - `ALIYUN_BAILIAN_API_KEY`: Aliyun Bailian API Key\n  - `ALIYUN_BAILIAN_MODELS`: Custom supported Aliyun Bailian models, e.g. `qwen-max,qwen-7b-chat`, default to `qwen-max`\n\n## Usage\n\nOnce deployed successfully, you can call different models through OpenAI's API interface.\n\nFor example, calling OpenAI's API interface:\n\n```bash\ncurl http://localhost:8787/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $API_KEY\" \\\n  -d '{\n     \"model\": \"gpt-4o-mini\",\n     \"messages\": [\n       {\n         \"role\": \"user\",\n         \"content\": \"Hello, world!\"\n       }\n     ]\n   }'\n```\n\nOr calling Anthropic's API interface:\n\n```bash\ncurl http://localhost:8787/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $API_KEY\" \\\n  -d '{\n     \"model\": \"claude-3-5-sonnet-20240620\",\n     \"messages\": [\n       {\n         \"role\": \"user\",\n         \"content\": \"Hello, world!\"\n       }\n     ]\n   }'\n```\n\nAnd it can be used in OpenAI's official SDK, for example:\n\n```ts\nconst openai = new OpenAI({\n  baseURL: 'http://localhost:8787/v1',\n  apiKey: '$API_KEY',\n})\n\nconst response = await openai.chat.completions.create({\n  model: 'gpt-4o-mini',\n  messages: [{ role: 'user', content: 'Hello, world!' }],\n})\n\nconsole.log(response)\n```\n\n### OpenAI Compatibility\n\n- [/v1/chat/completions](https://platform.openai.com/docs/api-reference/chat/create)\n- [/v1/models](https://platform.openai.com/docs/api-reference/models)\n\n### Supported Models\n\nDue to some models existing across multiple vendors, certain model names may have prefixes added, such as `groq/llama3-8b-8192`, indicating Groq's `llama3-8b-8192` model.\n\nGet a list of supported models via API:\n\n```bash\ncurl http://localhost:8787/v1/models \\\n  -H \"Authorization: Bearer $API_KEY\" \\\n  -H \"Content-Type: application/json\"\n```\n\n## Motivation\n\nI'm using Vertex AI's Anthropic model, but found that many LLM tools don't support configuring it directly. This prompted me to develop an API proxy. With this proxy, I can seamlessly use other AI models in any tool that supports the OpenAI API.\n\nAlthough there are some commercial services that resell LLM tokens, they usually require routing through their servers. Well, there's no need for another third party to know how I'm using it. This proxy can be deployed to any Edge Runtime environment, such as Cloudflare Workers, which provides up to 100k free requests per day for individuals.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxliuli%2Fopenai-api-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxliuli%2Fopenai-api-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxliuli%2Fopenai-api-proxy/lists"}