export class MinimaxProvider {
    apiKey;
    baseUrl = 'https://api.minimax.chat/v1';
    constructor(apiKey) {
        this.apiKey = apiKey;
    }
    async chat(options) {
        const response = await fetch(`${this.baseUrl}/text/chatcompletion_v2`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${this.apiKey}`
            },
            body: JSON.stringify(options)
        });
        if (!response.ok) {
            throw new Error(`Minimax API error: ${response.status}`);
        }
        return response.json();
    }
    async chatPro(options) {
        const response = await fetch(`${this.baseUrl}/text/chatcompletion_pro`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${this.apiKey}`
            },
            body: JSON.stringify(options)
        });
        if (!response.ok) {
            throw new Error(`Minimax API error: ${response.status}`);
        }
        return response.json();
    }
}
let providerInstance = null;
export function initMinimaxProvider(apiKey) {
    providerInstance = new MinimaxProvider(apiKey);
    return providerInstance;
}
export function getMinimaxProvider() {
    if (!providerInstance) {
        throw new Error('Minimax provider not initialized. Call initMinimaxProvider first.');
    }
    return providerInstance;
}
