{"id":13466064,"url":"https://github.com/stulzq/azure-openai-proxy","last_synced_at":"2025-04-09T11:03:35.984Z","repository":{"id":148943659,"uuid":"618299849","full_name":"stulzq/azure-openai-proxy","owner":"stulzq","description":"Azure OpenAI Service Proxy. Convert OpenAI official API request to Azure OpenAI API request. Support GPT-4,Embeddings,Langchain. Adapter from OpenAI to Azure OpenAI.","archived":false,"fork":false,"pushed_at":"2024-06-25T16:17:07.000Z","size":451,"stargazers_count":1350,"open_issues_count":18,"forks_count":195,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-02T09:36:30.786Z","etag":null,"topics":["azure","azure-openai","chatgpt","gpt-4","langchain","openai"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stulzq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2023-03-24T07:06:46.000Z","updated_at":"2025-03-24T10:25:48.000Z","dependencies_parsed_at":"2024-06-21T20:30:36.321Z","dependency_job_id":"90e03aa9-8153-4361-9add-f3af3214799f","html_url":"https://github.com/stulzq/azure-openai-proxy","commit_stats":{"total_commits":93,"total_committers":8,"mean_commits":11.625,"dds":"0.23655913978494625","last_synced_commit":"fda64266a9ed19de631401a2866ae08f289556e5"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fazure-openai-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fazure-openai-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fazure-openai-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fazure-openai-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stulzq","download_url":"https://codeload.github.com/stulzq/azure-openai-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027404,"owners_count":21035594,"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":["azure","azure-openai","chatgpt","gpt-4","langchain","openai"],"created_at":"2024-07-31T15:00:38.772Z","updated_at":"2025-04-09T11:03:35.959Z","avatar_url":"https://github.com/stulzq.png","language":"Go","funding_links":[],"categories":["Go","Langchain","Addons, extensions, plug-ins for integrating LLM into third-party applications"],"sub_categories":["Other user interfaces"],"readme":"# azure-openai-proxy\n\n[![License](https://img.shields.io/github/license/koordinator-sh/koordinator.svg?color=4EB1BA\u0026style=flat-square)](https://opensource.org/licenses/Apache-2.0)\n[![GitHub release](https://img.shields.io/github/v/release/stulzq/azure-openai-proxy.svg?style=flat-square)](https://github.com/stulzq/azure-openai-proxy/releases/latest)\n[![Go Report Card](https://goreportcard.com/badge/github.com/stulzq/azure-openai-proxy)](https://goreportcard.com/badge/github.com/stulzq/azure-openai-proxy)\n[![CI](https://img.shields.io/github/actions/workflow/status/stulzq/azure-openai-proxy/ci.yml?label=CI\u0026logo=github\u0026style=flat-square\u0026branch=master)](https://github.com/stulzq/azure-openai-proxy/actions/workflows/ci.yml)\n[![Release](https://img.shields.io/github/actions/workflow/status/stulzq/azure-openai-proxy/release.yml?label=Release\u0026logo=github\u0026style=flat-square\u0026branch=master)](https://github.com/stulzq/azure-openai-proxy/actions/workflows/release.yml)\n[![PRs Welcome](https://badgen.net/badge/PRs/welcome/green?icon=https://api.iconify.design/octicon:git-pull-request.svg?color=white\u0026style=flat-square)](CONTRIBUTING.md)\n[![Docker Pulls](https://img.shields.io/docker/pulls/stulzq/azure-openai-proxy.svg?style=flat-square)]([https://hub.docker.com/u/stulzq](https://hub.docker.com/r/stulzq/azure-openai-proxy/tags))\n\nEnglish|[中文](https://www.cnblogs.com/stulzq/p/17271937.html)\n\nAzure OpenAI Service Proxy, convert OpenAI official API request to Azure OpenAI API request, support all models, support GPT-4,Embeddings.\n\u003eEliminate the differences between OpenAI and Azure OpenAI, acting as a bridge connecting them, OpenAI ecosystem accesses Azure OpenAI at zero cost.\n\n![aoai-proxy.jpg](assets/images/aoai-proxy.jpg)\n\nVerified support projects：\n\n| Name                                                     | Status |\n| -------------------------------------------------------- | ------ |\n| [chatgpt-web](https://github.com/Chanzhaoyu/chatgpt-web) | √   |\n| [chatbox](https://github.com/Bin-Huang/chatbox)          | √    |\n| [langchain](https://python.langchain.com/en/latest/)     | √    |\n| [ChatGPT-Next-Web](https://github.com/Yidadaa/ChatGPT-Next-Web) | √ |\n\n## Get Start\n\n### Retrieve key and endpoint\n\nTo successfully make a call against Azure OpenAI, you'll need the following:\n\n| Name                  | Desc                                                         | Default                                                  |\n| --------------------- | ------------------------------------------------------------ | ----------------------------- |\n| AZURE_OPENAI_ENDPOINT | This value can be found in the **Keys \u0026 Endpoint** section when examining your resource from the Azure portal. Alternatively, you can find the value in **Azure OpenAI Studio** \u003e **Playground** \u003e **Code View**. An example endpoint is: `https://docs-test-001.openai.azure.com/`. | N |\n| AZURE_OPENAI_API_VER  | [See here](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/quickstart?tabs=command-line\u0026pivots=rest-api) or Azure OpenAI Studio | 2024-02-01     |\n| AZURE_OPENAI_MODEL_MAPPER   | This value will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under **Resource Management** \u003e **Deployments** in the Azure portal or alternatively under **Management** \u003e **Deployments** in Azure OpenAI Studio. | N |\n\n`AZURE_OPENAI_MODEL_MAPPER` is a mapping from Azure OpenAI deployed model names to official OpenAI model names. You can use commas to separate multiple mappings.\n\n**Format：**\n\n`AZURE_OPENAI_MODEL_MAPPER`: \\\u003cOpenAI Model Name\\\u003e=\\\u003cAzure OpenAI deployment model name\\\u003e\n\nOpenAI Model Names: https://platform.openai.com/docs/models\n\nAzure Deployment Names: **Resource Management** \u003e **Deployments**\n\n**Example:**\n\n````yaml\nAZURE_OPENAI_MODEL_MAPPER: gpt-3.5-turbo=gpt-35-turbo\n````\n\n![Screenshot of the overview UI for an OpenAI Resource in the Azure portal with the endpoint \u0026 access keys location circled in red.](assets/images/endpoint.png)\n\nAPI Key: This value can be found in the **Keys \u0026 Endpoint** section when examining your resource from the Azure portal. You can use either `KEY1` or `KEY2`. \n\n### Proxy\n\n**HTTP Proxy**\n\nEnv:\n\n````shell\nAZURE_OPENAI_HTTP_PROXY=http://127.0.0.1:1087\n````\n\n\n\n**Socks5 Proxy**\n\nEnv:\n\n````shell\nAZURE_OPENAI_SOCKS_PROXY=socks5://127.0.0.1:1080\n````\n\n\n\n### Use Docker\n\n````shell\n# config by environment \ndocker run -d -p 8080:8080 --name=azure-openai-proxy \\\n  --env AZURE_OPENAI_ENDPOINT=your_azure_endpoint \\\n  --env AZURE_OPENAI_API_VER=your_azure_api_ver \\\n  --env AZURE_OPENAI_MODEL_MAPPER=your_azure_deploy_mapper \\\n  stulzq/azure-openai-proxy:latest\n\n# config by file\ndocker run -d -p 8080:8080 --name=azure-openai-proxy \\\n  -v /path/to/config.yaml:/app/config.yaml \\\n  stulzq/azure-openai-proxy:latest\n````\n\nCall API:\n\n````shell\ncurl --location --request POST 'localhost:8080/v1/chat/completions' \\\n-H 'Authorization: Bearer \u003cAzure OpenAI Key\u003e' \\\n-H 'Content-Type: application/json' \\\n-d '{\n    \"max_tokens\": 1000,\n    \"model\": \"gpt-3.5-turbo\",\n    \"temperature\": 0.8,\n    \"top_p\": 1,\n    \"presence_penalty\": 1,\n    \"messages\": [\n        {\n            \"role\": \"user\",\n            \"content\": \"Hello\"\n        }\n    ],\n    \"stream\": true\n}'\n````\n\n### Use ChatGPT-Next-Web\n\n![chatgpt-web](assets/images/chatgpt-next-web.png)\n\ndocker-compose.yml\n\n````yaml\nversion: '3'\n\nservices:\n  chatgpt-web:\n    image: yidadaa/chatgpt-next-web\n    ports:\n      - 3000:3000\n    environment:\n      OPENAI_API_KEY: \u003cAzure OpenAI API Key\u003e\n      BASE_URL: http://azure-openai:8080\n      CODE: \"\"\n      HIDE_USER_API_KEY: 1\n      HIDE_BALANCE_QUERY: 1\n    depends_on:\n      - azure-openai\n    links:\n      - azure-openai\n    networks:\n      - chatgpt-ns\n\n  azure-openai:\n    image: stulzq/azure-openai-proxy\n    ports:\n      - 8080:8080\n    environment:\n      AZURE_OPENAI_ENDPOINT: \u003cAzure OpenAI API Endpoint\u003e\n      AZURE_OPENAI_MODEL_MAPPER: \u003cAzure OpenAI API Deployment Mapper\u003e\n      # AZURE_OPENAI_MODEL_MAPPER: gpt-4=gpt-4,gpt-3.5-turbo=gpt-35-turbo\n      AZURE_OPENAI_API_VER: \"2024-02-01\"\n    networks:\n      - chatgpt-ns\n\nnetworks:\n  chatgpt-ns:\n    driver: bridge\n````\n\n### Use ChatGPT-Web\n\nChatGPT Web: https://github.com/Chanzhaoyu/chatgpt-web\n\n![chatgpt-web](assets/images/chatgpt-web.png)\n\nEnvs:\n\n- `OPENAI_API_KEY` Azure OpenAI API Key\n- `AZURE_OPENAI_ENDPOINT` Azure OpenAI API Endpoint\n- `AZURE_OPENAI_MODEL_MAPPER` Azure OpenAI API Deployment Name Mappings\n\ndocker-compose.yml:\n\n````yaml\nversion: '3'\n\nservices:\n  chatgpt-web:\n    image: chenzhaoyu94/chatgpt-web\n    ports:\n      - 3002:3002\n    environment:\n      OPENAI_API_KEY: \u003cAzure OpenAI API Key\u003e\n      OPENAI_API_BASE_URL: http://azure-openai:8080\n      # OPENAI_API_MODEL: gpt-4\n      AUTH_SECRET_KEY: \"\"\n      MAX_REQUEST_PER_HOUR: 1000\n      TIMEOUT_MS: 60000\n    depends_on:\n      - azure-openai\n    links:\n      - azure-openai\n    networks:\n      - chatgpt-ns\n\n  azure-openai:\n    image: stulzq/azure-openai-proxy\n    ports:\n      - 8080:8080\n    environment:\n      AZURE_OPENAI_ENDPOINT: \u003cAzure OpenAI API Endpoint\u003e\n      AZURE_OPENAI_MODEL_MAPPER: \u003cAzure OpenAI API Deployment Mapper\u003e\n      AZURE_OPENAI_API_VER: \"2024-02-01\"\n    networks:\n      - chatgpt-ns\n\nnetworks:\n  chatgpt-ns:\n    driver: bridge\n````\n\nRun:\n\n````shell\ndocker compose up -d\n````\n\n### Use Config File\n\nThe configuration file supports different endpoints and API keys for each model.\n\nconfig.yaml\n\n````yaml\napi_base: \"/v1\"\ndeployment_config:\n  - deployment_name: \"xxx\"\n    model_name: \"text-davinci-003\"\n    endpoint: \"https://xxx-east-us.openai.azure.com/\"\n    api_key: \"11111111111\"\n    api_version: \"2024-02-01\"\n  - deployment_name: \"yyy\"\n    model_name: \"gpt-3.5-turbo\"\n    endpoint: \"https://yyy.openai.azure.com/\"\n    api_key: \"11111111111\"\n    api_version: \"2024-02-01\"\n  - deployment_name: \"zzzz\"\n    model_name: \"text-embedding-ada-002\"\n    endpoint: \"https://zzzz.openai.azure.com/\"\n    api_key: \"11111111111\"\n    api_version: \"2024-02-01\"\n````\n\nBy default, it reads `\u003cworkdir\u003e/config.yaml`, and you can pass the path through the parameter `-c config.yaml`.\n\ndocker-compose:\n\n````yaml\nazure-openai:\n    image: stulzq/azure-openai-proxy\n    ports:\n      - 8080:8080\n    volumes:\n      - /path/to/config.yaml:/app/config.yaml\n    networks:\n      - chatgpt-ns\n````\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstulzq%2Fazure-openai-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstulzq%2Fazure-openai-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstulzq%2Fazure-openai-proxy/lists"}