@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
68 lines (67 loc) • 3.41 kB
TypeScript
import { type AIProviderName } from "../constants/enums.js";
import type { NeurolinkCredentials, OpenAICompatChatRequest } from "../types/index.js";
import { OpenAIChatCompletionsProvider } from "./openaiChatCompletionsBase.js";
/**
* Azure OpenAI Provider — direct HTTP, no AI SDK.
*
* Supports both classic Azure OpenAI Service endpoints
* ("*.openai.azure.com", "*.cognitiveservices.azure.com") and the newer
* Azure AI Foundry endpoints ("*.services.ai.azure.com").
*
* All request/stream/tool-loop orchestration lives in
* `OpenAIChatCompletionsProvider`; this class overrides the URL builder and
* auth headers to accommodate Azure's deployment-based routing and
* `api-key` header (rather than Bearer tokens).
*
* @see https://learn.microsoft.com/azure/cognitive-services/openai/
*/
export declare class AzureOpenAIProvider extends OpenAIChatCompletionsProvider {
protected readonly azureDeployment: string;
protected readonly azureApiVersion: string;
protected readonly azureResourceOrigin: string;
protected readonly azureDeploymentPathPrefix: string;
protected readonly useMaxCompletionTokensOverride?: boolean;
constructor(modelName?: string, sdk?: unknown, _region?: string, credentials?: NeurolinkCredentials["azure"]);
/**
* Azure OpenAI natively supports `response_format: json_schema` together
* with tool calling in one request, so structured output stays
* wire-enforced mid-loop instead of deferring to post-hoc coercion.
*/
protected suppressResponseFormatWithTools(): boolean;
protected getProviderName(): AIProviderName;
/**
* The "default model" for Azure is the deployment name — it's the
* identifier callers pass to select a deployment.
*/
protected getDefaultModel(): string;
protected formatProviderError(error: unknown): Error;
/**
* Builds the full Azure deployment chat completions URL.
*
* Pattern:
* {resourceOrigin}{deploymentPathPrefix}/deployments/{deployment}/chat/completions?api-version={apiVersion}
*
* Examples:
* Classic: https://myresource.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-04-01-preview
* Foundry: https://myhost.services.ai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-04-01-preview
*/
protected getChatCompletionsURL(modelId: string): string;
/**
* Azure uses `api-key` rather than the standard `Authorization: Bearer`
* header expected by OpenAI-compatible endpoints.
*/
protected getAuthHeaders(): Record<string, string>;
/**
* Newer Azure deployments (o-series, gpt-5+) reject `max_tokens` and require
* `max_completion_tokens`. The `@ai-sdk/openai` path this migration replaced
* renamed the field automatically; replicate that here.
*
* Capability is taken from the explicit `useMaxCompletionTokens` override
* (credentials / `AZURE_OPENAI_USE_MAX_COMPLETION_TOKENS`) when set — Azure
* deployment names are user-defined, so a `chat-prod` gpt-5 deployment can't
* be detected from the name. When unset, fall back to a best-effort
* model-name heuristic for the common case where the deployment echoes the
* model (e.g. `gpt-5.4`).
*/
protected adjustRequestBody(body: OpenAICompatChatRequest, modelId: string): OpenAICompatChatRequest;
}