/** * Multi-provider API format translation. * * Translates between our universal BrainResponse and the wire formats * for Anthropic, OpenAI, and Google Generative AI. * * Each provider needs: * 1. parseRequest() — incoming API request → normalized ApiRequest * 2. serializeResponse() — BrainResponse → provider-specific SSE/JSON */ import type { ApiRequest, BrainResponse } from "./anthropic.js"; import { toSSE as anthropicToSSE } from "./anthropic.js"; export type ProviderName = "anthropic" | "openai" | "openai-responses" | "google" | "unknown"; /** * Detect which provider format a request is using, based on URL path. */ export declare function detectProvider(method: string, path: string): ProviderName; export { anthropicToSSE }; export declare function parseOpenAIRequest(body: Record): ApiRequest; export declare function openaiToSSE(response: BrainResponse, model: string): string; export declare function parseGoogleRequest(body: Record): ApiRequest; export declare function googleToSSE(response: BrainResponse, _model: string): string; export declare function parseOpenAIResponsesRequest(body: Record): ApiRequest; export declare function openaiResponsesToSSE(response: BrainResponse, model: string): string; export declare function serializeResponse(provider: ProviderName, response: BrainResponse, model: string): { contentType: string; body: string; }; /** * Format an HTTP error body the way each provider's real API would. * This ensures the Anthropic/OpenAI/Google SDKs parse the error correctly * and include meaningful error messages that pi's retry logic can match. */ export declare function serializeProviderError(provider: ProviderName, status: number, message: string): { contentType: string; body: string; }; export declare function parseRequest(provider: ProviderName, body: Record): ApiRequest; //# sourceMappingURL=providers.d.ts.map