import type { BatchJobRef, BatchJobState, BatchProviderCallContext } from '../types/batch.js'; /** What every OpenAI batch adapter needs to reach the API. */ export interface OpenAIBatchClientOptions { /** OpenAI API key. */ apiKey: string; /** API base URL. Defaults to `https://api.openai.com/v1`. */ baseUrl?: string; /** Sent as the `OpenAI-Organization` header. */ organization?: string; /** Headers added to every request. */ headers?: Record; /** Replaces the global `fetch`. */ fetch?: typeof fetch; } /** OpenAI's batch object, as far as the adapters read it. */ export interface OpenAIBatchPayload { id?: string; status?: string; output_file_id?: string | null; error_file_id?: string | null; created_at?: number; completed_at?: number; expires_at?: number; request_counts?: { total?: number; completed?: number; failed?: number; }; errors?: { data?: Array<{ message?: string; code?: string; }>; }; } /** One line of a batch's output or error file. */ export interface OpenAIBatchLine { custom_id?: string; response?: { status_code?: number; body?: Record; }; error?: { message?: string; code?: string; } | null; } /** * OpenAI's Batch API wire protocol, shared by the completion and embedding adapters: a JSONL upload, * a batch pointing at it, and JSONL downloads of what succeeded and what failed. */ export declare class OpenAIBatchClient { private readonly options; constructor(options: OpenAIBatchClientOptions); /** Uploads the lines as a JSONL file and creates a batch over them. */ create(lines: readonly unknown[], batch: { endpoint: string; completionWindow?: string; metadata?: Record; }, context: BatchProviderCallContext): Promise<{ batch: OpenAIBatchPayload; fileId: string; }>; /** Reads a batch. */ read(id: string, context: BatchProviderCallContext): Promise; /** Cancels a batch. */ cancel(id: string, context: BatchProviderCallContext): Promise; /** * Every line a finished batch wrote: the output file holds what succeeded and the error file what * failed, so both are read, or a failed request would be missing from the results altogether. */ lines(id: string, context: BatchProviderCallContext): Promise; /** A batch as the neutral state. */ state(ref: BatchJobRef, batch: OpenAIBatchPayload): BatchJobState; private json; private send; } /** A failed line's reason: the error the line carries, or the error body of its response. */ export declare function lineError(line: OpenAIBatchLine): { message: string; code?: string; status?: number; } | undefined;