Skip to content

User-Provided Azure OpenAI API Credentials #14

@herin7

Description

@herin7

Feature Request: User-Provided Azure OpenAI API Credentials

Overview

Currently, the application uses hardcoded Azure OpenAI credentials from environment variables. We want to implement a feature that allows users to provide their own Azure OpenAI API credentials through the frontend, which will be passed to the backend for LLM operations.

✨ Motivation

  • Users may want to use their own Azure OpenAI keys instead of relying on shared credentials.
  • This promotes transparency, flexibility, and improved access control.
  • However, users must feel confident that their credentials will not be leaked or misused.

🔐 Security & Trust Requirements

  • No logging or server-side storage of credentials.
  • Credentials must be used only for the current session/request and discarded immediately after use.
  • Frontend UI should clearly state that credentials are not stored or shared.
  • Inputs should be securely handled via HTTPS and never exposed in localStorage or sessionStorage.
  • Validate input formats and show helpful error messages if credentials are invalid.

Technical Requirements

Backend Changes

  1. Modify the /api/chat endpoint to accept Azure OpenAI credentials in the request payload
  2. Update the stream_llm_response function to use provided credentials instead of environment variables
  3. Add input validation for the API credentials
@app.route('/api/chat', methods=['POST'])
async def chat():
    data = request.get_json()
    
    # New credential fields
    azure_endpoint = data.get("azureEndpoint")
    api_key = data.get("apiKey")
    deployment = data.get("deployment")
    api_version = data.get("apiVersion", "2023-05-15")
    
    # Validate credentials
    if not all([azure_endpoint, api_key, deployment]):
        return jsonify({"error": "Missing required Azure OpenAI credentials"}), 400
        
    # Rest of the existing function...

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions