uezo / aiproxy

🦉AIProxy is a reverse proxy for ChatGPT API that provides monitoring, logging, and filtering requests and responses.
Apache License 2.0
38 stars 1 forks source link

Add support for Azure OpenAI Service #32

Closed uezo closed 3 months ago

uezo commented 3 months ago

Just the chat completion is supported for now.

To use Azure OpenAI, use AzureOpenAIProxy instead of ChatGPTProxy.

from aiproxy.chatgpt import AzureOpenAIProxy

aoai_proxy = AzureOpenAIProxy(
    api_key="YOUR_API_KEY",
    resource_name="YOUR_RESOURCE_NAME",
    deployment_id="YOUR_DEPLOYMENT_ID",
    api_version="2024-02-01",   # https://learn.microsoft.com/ja-jp/azure/ai-services/openai/reference#chat-completions
    access_logger_queue=worker.queue_client
)
aoai_proxy.add_route(app)

Clients do not need to be aware that it is Azure OpenAI; use the same code for ChatGPT API.