Skip to content

Azure OpenAI (cognitiveservices) Chat Completions returns 404 with openai-completions API #52444

@pyrotank41

Description

@pyrotank41

Description

When configuring an Azure OpenAI provider with api: "openai-completions", the gateway returns HTTP 404: Resource not found because the underlying pi-ai library uses the standard OpenAI SDK client which doesn't append the required ?api-version= query parameter for Azure cognitiveservices endpoints.

Steps to Reproduce

  1. Configure openclaw.json with an Azure OpenAI provider:
{
  "models": {
    "providers": {
      "azure-openai": {
        "baseUrl": "https://{resource}.cognitiveservices.azure.com/openai",
        "api": "openai-completions",
        "headers": { "api-key": "${AZURE_OPENAI_API_KEY}" },
        "models": [{
          "id": "model-router",
          "api": "openai-completions"
        }]
      }
    }
  }
}
  1. Send a message via the agent
  2. Get HTTP 404: Resource not found

Root Cause

The openai-completions provider in @mariozechner/pi-ai uses the standard OpenAI client which constructs:

.../openai/deployments/{model}/chat/completions

But Azure requires:

.../openai/deployments/{model}/chat/completions?api-version=2025-01-01-preview

Note: openai-responses API type already has dedicated Azure support via azure-openai-responses.js, but the Responses API is not available on all Azure deployments (e.g., model-router).

Fix

Upstream PR submitted to pi-mono: earendil-works/pi#2525

Workaround: Apply a post-install patch in the Dockerfile to use AzureOpenAI SDK client for Azure providers in the openai-completions provider.

Environment

  • OpenClaw 2026.3.14
  • @mariozechner/pi-ai 0.61.1
  • Azure OpenAI (cognitiveservices) with model-router deployment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions