How to Get Started with Azure OpenAI Proxy

May 10, 2024 | Data Science

In the booming landscape of AI services, having a seamless connector between different platforms is vital. The Azure OpenAI Proxy emerges as a powerful solution to bridge the gap between OpenAI’s official API and Azure’s offerings. This article guides you through setting up and troubleshooting the Azure OpenAI Proxy, paving the way for a smooth experience.

What is Azure OpenAI Proxy?

The Azure OpenAI Proxy transforms OpenAI API requests into Azure OpenAI API requests, enabling users to access Azure’s OpenAI services like GPT-4 and Embeddings effortlessly. Think of it as a translator who ensures two different languages (OpenAI and Azure OpenAI) can communicate without any hiccups.

Getting Started

To utilize the Azure OpenAI Proxy, you’ll need to follow several steps to configure it properly. Let’s break these down chronologically.

Step 1: Retrieve Key and Endpoint

  • Access the **Keys & Endpoint** section in the Azure portal to find:
    • AZURE_OPENAI_ENDPOINT: e.g., https://docs-test-001.openai.azure.com
    • AZURE_OPENAI_API_VER: Set it to 2024-02-01.
    • AZURE_OPENAI_MODEL_MAPPER: This maps your Azure model names to OpenAI model names. Example:
    • AZURE_OPENAI_MODEL_MAPPER: gpt-3.5-turbo=gpt-35-turbo

Step 2: Configure Proxies (if needed)

If you’re using proxies, set them with the following:


AZURE_OPENAI_HTTP_PROXY=http://127.0.0.1:1087
AZURE_OPENAI_SOCKS_PROXY=socks5://127.0.0.1:1080

Step 3: Run Docker

To run the Azure OpenAI Proxy, execute the following commands according to your configuration preference:

  • Config by Environment:
  • docker run -d -p 8080:8080 --name=azure-openai-proxy \
       --env AZURE_OPENAI_ENDPOINT=your_azure_endpoint \
       --env AZURE_OPENAI_API_VER=your_azure_api_ver \
       --env AZURE_OPENAI_MODEL_MAPPER=your_azure_deploy_mapper \
       stulzq/azure-openai-proxy:latest
  • Config by File:
  • docker run -d -p 8080:8080 --name=azure-openai-proxy \
       -v pathtoconfig.yaml:appconfig.yaml \
       stulzq/azure-openai-proxy:latest

Step 4: Call the API

With the server running, you can now make API calls. Here’s an example using curl:

curl --location --request POST localhost:8080/v1/chat/completions \
-H "Authorization: Bearer Azure OpenAI Key" \
-H "Content-Type: application/json" \
-d '{
   "max_tokens": 1000,
   "model": "gpt-3.5-turbo",
   "temperature": 0.8,
   "top_p": 1,
   "presence_penalty": 1,
   "messages": [{
       "role": "user",
       "content": "Hello"
   }],
   "stream": true
}'

Understanding the Configuration with an Analogy

Think of setting up the Azure OpenAI Proxy as organizing a relay race. Each runner (step) in the relay must know their roles to successfully pass the baton (API call) to the next runner (function). Here’s how it breaks down:

  • Retrieving Keys & Endpoints: Like preparing your runners with the knowledge of how far they need to run (key locations).
  • Configuring Proxies: Ensuring all runners can communicate without blockers—like setting the right pace and path (proxy settings).
  • Running Docker: It’s like starting the race where everyone is in sync (the Docker setup runs smoothly).
  • Calling the API: Passing the baton properly to ensure the end goal is reached (successfully invoking the API).

Troubleshooting Tips

In the journey of setting up your Azure OpenAI Proxy, challenges may arise. Here are some common troubleshooting ideas:

  • Invalid API Key or Endpoint: Double-check if you have accurately copied the keys and endpoint addresses from your Azure portal.
  • Docker Container Not Running: Ensure that Docker is installed correctly and that there are no conflicting services on the exposed ports.
  • Request Timeout: This can happen due to network issues or server load. Consider adjusting your proxy settings or increasing the timeout limits.
  • Authorization Errors: Ensure the `Authorization: Bearer` token is correct in your API call requests.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

Setting up the Azure OpenAI Proxy can open new doors for developers and AI enthusiasts alike. By effectively bridging OpenAI’s capabilities with Azure, it promotes an expansive range of possibilities.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox