/** * Responses namespace — structured response API (Layer 2). * Matches SDK_FACADE_CONTRACT.md responses.create() and responses.stream(). */ import type { TelemetryReporter } from "./telemetry.js"; import type { DeviceContext } from "./device-context.js"; import type { LocalResponsesRuntime, LocalResponsesRuntimeResolver } from "./responses-runtime.js"; import { type RouteMetadata } from "./runtime/routing/request-router.js"; export interface ResponseRequest { model: string; input: string | ContentBlock[] | ResponseInputItem[]; tools?: ToolDef[]; instructions?: string; previousResponseId?: string; maxOutputTokens?: number; temperature?: number; topP?: number; stop?: string[]; stream?: boolean; metadata?: Record; } export interface ContentBlock { type: "text" | "image" | "audio" | "video" | "file"; text?: string; /** Image URL for cloud inference */ imageUrl?: string; /** Base64-encoded binary data */ data?: string; /** MIME type (e.g. "image/png", "audio/wav", "video/mp4") */ mediaType?: string; } /** * Chat-level content part for the OpenAI-compatible messages array. * Supports text, image_url (images and video frames), and input_audio. */ export interface ChatContentPart { type: "text" | "image_url" | "input_audio"; text?: string; image_url?: { url: string; }; input_audio?: { data: string; format: string; }; } export interface ToolDef { type: "function"; function: { name: string; description?: string; parameters?: Record; }; } export interface ResponseToolCall { id: string; name: string; arguments: string; } export interface ResponseOutput { type: "text" | "tool_call"; text?: string; toolCall?: ResponseToolCall; } export interface ResponseInputItem { role: "system" | "user" | "assistant" | "tool"; content?: string | ContentBlock[] | ResponseOutput[] | null; toolCallId?: string; } export interface Response { id: string; model: string; output: ResponseOutput[]; finishReason: string; usage?: ResponseUsage; route?: RouteMetadata; } export interface ResponseUsage { promptTokens: number; completionTokens: number; totalTokens: number; } export interface TextDeltaEvent { type: "text_delta"; delta: string; } export interface ToolCallDeltaEvent { type: "tool_call_delta"; index: number; id?: string; name?: string; argumentsDelta?: string; } export interface DoneEvent { type: "done"; response: Response; } export type ResponseStreamEvent = TextDeltaEvent | ToolCallDeltaEvent | DoneEvent; export interface ResponsesClientOptions { serverUrl?: string; apiKey?: string; telemetry?: TelemetryReporter | null; deviceContext?: DeviceContext | null; localRuntime?: LocalResponsesRuntime | LocalResponsesRuntimeResolver | null; } export declare class ResponsesClient { private serverUrl; private apiKey; private readonly telemetry; private readonly deviceContext; private readonly localRuntime; private responseCache; private readonly MAX_CACHE; constructor(options?: ResponsesClientOptions); /** * Non-streaming response creation. */ create(request: ResponseRequest): Promise; private createCloud; canRunLocally(model: string): boolean; /** * Streaming response creation. Returns async generator of events. */ stream(request: ResponseRequest): AsyncGenerator; private streamCloud; private resolveLocalRuntime; private cacheResponse; private createLocal; private streamLocal; private buildEffectiveRequest; private resolveRoute; private resolveRouteWithInference; private outputQualityEvaluatorForRequest; private parseJsonSchemaMetadata; private buildLocalRuntimePlan; private buildFallbackRouteMetadata; private attachRoute; private reportRouteDecision; private inferenceTelemetryAttrs; private buildRequestBody; private buildMessages; private normalizeInput; private isResponseInputItems; private inputItemToMessage; private assistantInputToMessage; private isResponseOutputItems; private inputContentToMessageContent; private contentBlocksToParts; /** * Map a public ContentBlock to an OpenAI-compatible ChatContentPart. */ private contentBlockToPart; private parseResponse; } export declare function generateId(): string; //# sourceMappingURL=responses.d.ts.map