OpenAI SDK: Use the Azure deployment relevant to a specific model namev3.6+

Configure a header capture to insert the requested model name directly into the plugin configuration for Kong AI Gateway deployment with Azure OpenAI, as a string substitution.

For this plugin to work properly, you need a Gateway Route with the following configuration:

routes:
  - name: azure-chat-model-from-path
    paths:
       - "~/azure/.*"

Using the below configuration, you can target an Azure model deployment named west-europe-gpt-4o with the following sample request:

cat <<EOF > request.json
{
"messages": [
  {
    "role": "user",
    "content": [
      {
        "type": "text",
        "text": "This is my question."
      }
    ]
  }
]
}
EOF

curl http://localhost:8000/1/chat/completions \
-H "x-test: azure-chat-open-model-managed-identity" \
-H "x-model-name: gpt-4o" \
-d @request.json

Prerequisites

  • Azure OpenAI Service account

Set up the plugin

Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!