Skip to content

Latest commit

 

History

History
83 lines (62 loc) · 2.48 KB

File metadata and controls

83 lines (62 loc) · 2.48 KB

Azure OpenAI Proxy for Zed

A Proxy for Zed to use Azure OpenAI API, using NodeJS (with zero runtime node_module dependencies).

Streamline communication between Zed and Azure OpenAI with this lightweight proxy server, designed for Node.js users. Easily set up and run with environment variables for hassle-free integration.

Features

  • Converts requests from Zed into Azure OpenAI's expected format.
  • Streams events seamlessly for real-time interactions.
  • Easily configurable via CLI environment variables.

Environment Variables

The script will automatically include the following keys:

Command Line Examples Setting Environment Variables in Linux/Mac:

# Temporary (current session only)
export AZURE_API_ENDPOINT=https://<subdomain>.openai.azure.com/openai/deployments/<deployment>
export AZURE_API_VERSION=2025-01-01-preview
export AZURE_API_KEY=your-api-key
export PROXY_PORT=8000
node proxy.js

Or instead you can also pass environment variables inline during execution:

AZURE_API_ENDPOINT=https://<subdomain>.openai.azure.com/openai/deployments/<deployment> \
AZURE_API_VERSION=2025-01-01-preview \
AZURE_API_KEY=your-api-key \
PROXY_PORT=8000 node proxy.js

Zed Settings

Finally, add the following model configuration to Zed's settings.json file:

  "language_models": {
    "openai": {
      "version": "1",
      "api_url": "http://localhost:8000", // adjust to your port
      "available_models": [
        {
          "api_version": "2025-01-01-preview", // change to your desired API version
          "display_name": "gpt-4o", // change to your desired display name
          "name": "gpt-4o" // this is your model name in Azure
        }
      ]
    }
  }

And, finally in the Assistant panel's configuration, add random text in the API key for OpenAI. Such as sk_azure, which will allow it to work.

Project Structure

azure-openai-zed-proxy/
├── .husky/             # Commit hooks
├── proxy.js             # Original source file
├── package.json         # NPM package configuration
└── node_modules/

Contribution

Feel free to open issues or submit pull requests to improve the functionality.

Development

  1. Use nvm to set your node version to LTS.
  2. Clone the repo
  3. Either set the environment variables as above, or create a .env file in the project root.
  4. npm install
  5. Run the project using node proxy.js or node --env-file=.env proxy.js if using a .env file.

License

MIT