/**
 * Shared utilities for OpenAI Completions and Responses providers.
 *
 * This module consolidates code that is identical (or near-identical) across
 * openai-completions.ts and openai-responses.ts to reduce duplication while
 * preserving the subtle behavioural differences of each provider.
 */
import type OpenAI from "openai";
import type { Api, AssistantMessage, Context, Model } from "../types.js";
import type { AssistantMessageEventStream } from "../utils/event-stream.js";
/**
 * Lazy-load the OpenAI SDK default export.
 * Shared between Completions and Responses providers so the module is only
 * imported once regardless of which provider is used first.
 */
export declare function getOpenAIClass(): Promise<typeof OpenAI>;
export interface CreateClientOptions {
    /** Extra headers from the options bag (merged last, can override defaults). */
    optionsHeaders?: Record<string, string>;
    /** Provider-specific client constructor options (e.g. timeout, maxRetries for Z.ai). */
    extraClientOptions?: Record<string, unknown>;
}
/**
 * Create an OpenAI SDK client instance.
 *
 * Handles:
 * - API key resolution (explicit > env)
 * - GitHub Copilot dynamic headers
 * - Options header merging
 * - Lazy SDK loading
 */
export declare function createOpenAIClient<TApi extends Api>(model: Model<TApi>, context: Context, apiKey: string | undefined, options?: CreateClientOptions): Promise<OpenAI>;
/**
 * Build the initial AssistantMessage output object used by all OpenAI stream
 * handlers.  Every field is initialised to its zero/default value.
 */
export declare function buildInitialOutput<TApi extends Api>(model: Model<TApi>): AssistantMessage;
/**
 * Shared post-stream checks.  Call after the provider-specific stream loop
 * finishes successfully (before pushing the "done" event).
 *
 * Throws if the request was aborted or the output indicates an error.
 */
export declare function assertStreamSuccess(output: AssistantMessage, signal?: AbortSignal): void;
/**
 * Emit the "done" event and close the stream.
 */
export declare function finalizeStream(stream: AssistantMessageEventStream, output: AssistantMessage): void;
/**
 * Handle an error during streaming.
 *
 * Cleans up any leftover `index` properties on content blocks, sets the
 * appropriate stop reason and error message, then emits the "error" event.
 */
export declare function handleStreamError(stream: AssistantMessageEventStream, output: AssistantMessage, error: unknown, signal?: AbortSignal, 
/** Extra error metadata to append (e.g. OpenRouter raw metadata). */
extraMessage?: string): void;
/**
 * Clamp reasoning effort for models that don't support all levels.
 * gpt-5.x models don't support "minimal" -- map to "low".
 *
 * Used by both openai-responses.ts and azure-openai-responses.ts.
 */
export declare function clampReasoningForModel(modelName: string, effort: string): string;
//# sourceMappingURL=openai-shared.d.ts.map