/**
 * 测试 minimax-key2 API Key 是否正常
 */
import axios from 'axios';

const KEY2 = 'sk-cp-BOVwOolqOEmHycg8MzDX_UgQ_bDEK3snjPUFuwolUCb_TxMxhhlAfYhTT0_tqRvEz5K56xpl-aOoJtj97MuAY4UIA-PCQLVetUCY56i8LFimNuQqrrq5xWA';

async function test() {
  console.log('测试 minimax-key2 TTS API...\n');

  const body = {
    model: 'speech-2.8-hd',
    text: '你好，欢迎使用AI有声书',
    voice_setting: {
      voice_id: 'audiobook_female_1',
      speed: 1,
      vol: 1,
      pitch: 1,
    },
    audio_setting: {
      audio_sample_rate: 32000,
      bitrate: 128000,
      format: 'mp3',
      channel: 1,
    },
  };

  try {
    const resp = await axios.post('https://api.minimaxi.com/v1/t2a_async_v2', body, {
      headers: {
        'Authorization': `Bearer ${KEY2}`,
        'Content-Type': 'application/json',
      },
      timeout: 30000,
    });
    console.log('✅ 成功:', JSON.stringify(resp.data, null, 2));
  } catch (err: any) {
    console.log('❌ 状态码:', err.response?.status);
    console.log('❌ 响应:', JSON.stringify(err.response?.data, null, 2));
  }
}

test();