Chat Completions To Openai Fixture

Proxies Chat Completions requests to a local Azure replay backend at 127.0.0.1:3000

Versions marked “overview” do not contain this page. Selecting one opens that version’s documentation overview.

Category: Test fixture
Task: Proxies Chat Completions requests to a local Azure replay backend at 127.0.0.1:3000

Prerequisites: The matching test or replay fixture; this is not a standalone deployment configuration.

This configuration comes from the selected release. The example has not been run here; external services are not bundled.

Download the source file.

# Azure OpenAI to Chat Completions local replay fixture
#
# Proxies Chat Completions requests to a local Azure replay backend at
# 127.0.0.1:3000.
#
# The `openai_chat_completions_to_azureai_chat_completions` filter injects the
# required `api-version` query parameter, strips the `model` field
# from the body (Azure uses the deployment name from the URL), and
# normalizes Azure-specific response fields.
#
# Credential injection is handled separately by `azure_ad` or
# `credential_inject` depending on the authentication method.

listeners:
  - name: azure-gateway
    address: "127.0.0.1:8080"
    filter_chains: [azure-transform]

filter_chains:
  - name: azure-transform
    filters:
      # path_rewrite must run before the Azure filter so api-version is
      # appended to the deployment path rather than overwriting it.
      # Azure async content-filter annotations are dropped: they are
      # not representable in Chat Completions and crash OpenAI SDKs.
      - filter: path_rewrite
        replace:
          pattern: "^/v1/chat/completions$"
          replacement: "/openai/deployments/gpt-4o/chat/completions"
        conditions:
          - when:
              path_prefix: "/v1/chat/completions"

      - filter: openai_chat_completions_to_azureai_chat_completions
        api_version: "2024-10-21"
        conditions:
          - when:
              path: "/v1/chat/completions"

      - filter: router
        routes:
          - path_prefix: "/"
            cluster: "azure-backend"

      - filter: load_balancer
        clusters:
          - name: "azure-backend"
            endpoints:
              - "127.0.0.1:3000"

insecure_options:
  allow_private_endpoints: true # example proxies to local backends