import { QuotaExhaustedError, RateLimitError, AuthError, TransientError, FatalError, AIRequest, AIContentBlock, AIMessage } from './index.js';

type OpenAiCompatCreds = {
    apiKey: string;
    baseUrl?: string;
    fetch?: typeof fetch;
};
type OpenAiChatMessage = {
    role: 'system' | 'user' | 'assistant';
    content: string | Array<{
        type: string;
        text?: string;
        image_url?: {
            url: string;
        };
    }>;
};
type OpenAiChatResponse = {
    model: string;
    choices: Array<{
        message: {
            content: string | null;
        };
        finish_reason: string | null;
    }>;
    usage?: {
        prompt_tokens: number;
        completion_tokens: number;
    };
};
declare function mapMessagesToOpenAi(messages: AIMessage[]): OpenAiChatMessage[];
declare function mapContentToOpenAi(content: string | AIContentBlock[]): string | Array<{
    type: string;
    text?: string;
    image_url?: {
        url: string;
    };
}>;
declare function mapOpenAiResponse(body: OpenAiChatResponse, provider: string, model: string): {
    content: string;
    model: string;
    provider: string;
    usage: {
        promptTokens: number;
        completionTokens: number;
    };
    finishReason: string | undefined;
};
declare function classifyOpenAiCompatError(status: number, message: string, provider: string): QuotaExhaustedError | RateLimitError | AuthError | TransientError | FatalError;
declare function makeOpenAiCompatAdapter(creds: OpenAiCompatCreds): {
    provider: string;
    supportsImage: boolean;
    call(req: AIRequest): Promise<{
        content: string;
        model: string;
        provider: string;
        usage: {
            promptTokens: number;
            completionTokens: number;
        };
        finishReason: string | undefined;
    }>;
};

export { type OpenAiCompatCreds, classifyOpenAiCompatError, makeOpenAiCompatAdapter, mapContentToOpenAi, mapMessagesToOpenAi, mapOpenAiResponse };
