/** * Anthropic-to-OpenAI Protocol Translation Proxy * * Translates Claude CLI's Anthropic Messages API requests into OpenAI Chat Completions API format. * Used in direct API key mode to bypass CLIProxy entirely. * * Request flow: * Claude CLI (Anthropic format) → this proxy → OpenAI-compatible endpoint * * Response flow: * OpenAI-compatible endpoint → this proxy (translates SSE) → Claude CLI (Anthropic format) * * Handles: * - Path rewriting: /v1/messages → /v1/chat/completions * - Auth translation: x-api-key → Authorization: Bearer * - Request body: Anthropic messages/tools/system → OpenAI format * - Streaming response: OpenAI SSE chunks → Anthropic SSE events * - Non-streaming response: OpenAI completion → Anthropic message * - Tool calls and tool results */ export interface AnthropicToOpenAIProxyConfig { /** The user's OpenAI-compatible endpoint base URL (e.g., http://api.drlj.cn/openai) */ targetBaseUrl: string; /** Bearer token for the target endpoint */ apiKey: string; /** Enable verbose logging */ verbose?: boolean; /** Request timeout in ms */ timeoutMs?: number; /** * Use OpenAI Responses API (default: true). * When true: uses /v1/responses with codex-specific params (prompt_cache_key, reasoning.summary, session headers). * When false: uses /v1/chat/completions only (generic OpenAI-compatible endpoints). */ useResponsesApi?: boolean; } export declare class AnthropicToOpenAIProxy { private server; private port; private readonly config; private readonly httpAgent; private readonly httpsAgent; private readonly maxNetworkRetries; /** Track last Responses API response ID for conversation chaining */ private lastResponseId; constructor(config: AnthropicToOpenAIProxyConfig); private log; private isRetryableNetworkError; private isRetryableStatusCode; private getRetryDelayMs; start(): Promise; stop(): void; private readBody; private handleModelsRequest; private handleRequest; private handleStreaming; /** For non-streaming requests: call API with stream=true, collect text, return Anthropic JSON */ private handleNonStreamingViaStream; } //# sourceMappingURL=anthropic-to-openai-proxy.d.ts.map