Skip to content

Unable to use Azure OpenAI provider #10

Open
@lvnr

Description

@lvnr

The example in docs doesn't show an example for Azure OpenAI which requires a few more params to be set to run:
i've tries adding azureResourceName, azureDeploymentId, etc to the config like this:

import { createPortkey } from '@portkey-ai/vercel-provider';
import { streamText } from 'ai';

const portkeyConfig = {
      "provider": "openai", // Choose your provider (e.g., 'anthropic')
      "api_key": "OPENAI_API_KEY",
      "override_params": {
        "model": "gpt-4o" // Select from 250+ models
  }
};

const portkey = createPortkey({
  apiKey: 'YOUR_PORTKEY_API_KEY',
  azureResourceName: process.env.AZURE_OPENAI_RESOURCE_NAME,
  azureDeploymentId: process.env.AZURE_OPENAI_DEPLOYMENT_ID,
  azureApiVersion: process.env.AZURE_OPENAI_API_VERSION,
  azureModelName: model,
  Authorization: `Bearer ${process.env.AZURE_OPENAI_API_KEY}`,
  config: portkeyConfig,
});

Now this is what I see in Portkey Logs:

{
  "url": "https://undefined.openai.azure.com/openai/deployments/undefined/chat/completions?api-version=undefined",
  "method": "POST",
  "headers": {
    "accept": "*/*",
    "accept-encoding": "gzip, br",
    "accept-language": "*",
    "cf-connecting-ip": "5.77.203.18",
    "cf-ipcountry": "AM",
    "cf-ray": "9390224c4f037d29",
    "cf-visitor": "{\"scheme\":\"https\"}",
    "connection": "Keep-Alive",
    "content-length": "3085",
    "content-type": "application/json",
    "host": "api.portkey.ai",
    "sec-fetch-mode": "cors",
    "user-agent": "node",
    "x-forwarded-proto": "https",
    "x-portkey-strict-open-ai-compliance": "false",
    "x-real-ip": "5.77.203.18"
  },
  "body": {
    ...
  },
  "portkeyHeaders": {
    "x-portkey-api-key": "******",
    "x-portkey-azure-api-version": "2025-01-01-preview",
    "x-portkey-azure-deployment-id": "gpt-4o-mini",
    "x-portkey-azure-endpoint-name": "https://denzo-dev.openai.azure.com/openai/deployments/gpt-4o-mini/chat/completions?api-version=2025-01-01-preview",
    "x-portkey-azure-model-name": "gpt-4o-mini",
    "x-portkey-azure-resource-name": "denzo-dev",
    "x-portkey-config": "{\"provider\":\"azure-openai\",\"model\":\"gpt-4o-mini\",\"api_key\":\"********\",\"override_params\":{\"model\":\"gpt-4o-mini\",\"stream_options\":{\"include_usage\":true}},\"metadata\":{\"_user_id\":\"\",\"chat_id\":\"\",\"environment\":\"development\"}}",
    "x-portkey-package-version": "portkey-1.7.2",
    "x-portkey-runtime": "node",
    "x-portkey-runtime-version": "v18.18.2",
    "x-portkey-trace-id": "..."
  }
}

Note that the URL has undefined in all parametrized places, even though portkeyHeaders seems to have all the params picked up.

Not sure if i'm doing something wrong or if it's a bug in the lib.

The endpoint is working fine, since I tried using it without the vercel provider lib and with a virtual key, which worked ok.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions