import type { APIConnectOptions } from '@livekit/agents';
import { ConnectionPool, llm, stream } from '@livekit/agents';
import { WebSocket } from 'ws';
import type { ChatModels, Reasoning } from '../models.js';
import type { WsResponseCreateEvent, WsServerEvent } from './types.js';
/**
 * Build the Responses-API WebSocket URL.
 *
 * Includes the model on the upgrade URL for OpenAI-compatible gateways
 * (which can only see the URL at the WebSocket upgrade, not the subsequent
 * `response.create` frame) so they can route by model. OpenAI's native
 * endpoint gets the model in the `response.create` frame, so the query
 * parameter is intentionally omitted for direct connections.
 *
 * The scheme of `baseURL` is respected: `http://` maps to `ws://`
 * and `https://` maps to `wss://`.
 *
 * @internal
 */
export declare function buildResponsesWsUrl(baseURL: string | undefined, model: string): string;
export declare class ResponsesWebSocket {
    #private;
    constructor(ws: WebSocket);
    /**
     * Send a response.create event.  Returns a typed `StreamChannel<WsServerEvent>`
     * that yields validated server events until the response terminates.
     */
    sendRequest(payload: WsResponseCreateEvent): stream.StreamChannel<WsServerEvent>;
    close(): void;
}
export interface WSLLMOptions {
    model: string | ChatModels;
    apiKey?: string;
    baseURL?: string;
    temperature?: number;
    parallelToolCalls?: boolean;
    toolChoice?: llm.ToolChoice;
    store?: boolean;
    metadata?: Record<string, string>;
    strictToolSchema?: boolean;
    /** Specifies the processing tier (e.g. 'auto', 'default', 'priority', 'flex'). */
    serviceTier?: string;
    /** Upper bound for the number of tokens that can be generated for a response. */
    maxOutputTokens?: number;
    /** Configuration options for reasoning models. */
    reasoning?: Reasoning | null;
}
export declare class WSLLM extends llm.LLM {
    #private;
    /**
     * Create a new instance of the OpenAI Responses API WebSocket LLM.
     *
     * @remarks
     * `apiKey` must be set to your OpenAI API key, either using the argument or
     * by setting the `OPENAI_API_KEY` environment variable.
     *
     * A persistent WebSocket connection to `/v1/responses` is maintained and
     * reused across turns, reducing per-turn continuation overhead for
     * tool-call-heavy workflows.
     */
    constructor(opts?: Partial<WSLLMOptions>);
    label(): string;
    get model(): string;
    prewarm(): void;
    close(): Promise<void>;
    aclose(): Promise<void>;
    /** Called by LLMStream once response.completed fires to atomically persist both the
     *  response ID and its corresponding chat context for the next turn's diff. */
    _onResponseCompleted(responseId: string, chatCtx: llm.ChatContext): void;
    _setPendingToolCalls(callIds: Set<string>): void;
    chat({ chatCtx, toolCtx: toolCtxInput, connOptions, parallelToolCalls, toolChoice, extraKwargs, }: {
        chatCtx: llm.ChatContext;
        toolCtx?: llm.ToolContextLike;
        connOptions?: APIConnectOptions;
        parallelToolCalls?: boolean;
        toolChoice?: llm.ToolChoice;
        extraKwargs?: Record<string, unknown>;
    }): WSLLMStream;
}
export declare class WSLLMStream extends llm.LLMStream {
    #private;
    constructor(llm: WSLLM, { pool, model, chatCtx, fullChatCtx, toolCtx, connOptions, modelOptions, prevResponseId, strictToolSchema, }: {
        pool: ConnectionPool<ResponsesWebSocket>;
        model: string | ChatModels;
        chatCtx: llm.ChatContext;
        fullChatCtx: llm.ChatContext;
        toolCtx?: llm.ToolContext;
        connOptions: APIConnectOptions;
        modelOptions: Record<string, unknown>;
        prevResponseId?: string;
        strictToolSchema: boolean;
    });
    protected run(): Promise<void>;
}
//# sourceMappingURL=llm.d.ts.map