require('dotenv').config();

async function testMiniMaxImage() {
  const minmBase = (process.env.MINIMAX_API_BASE || 'https://api.minimax.io/v1').replace(/\/v1\/?$/, '');
  const apiKey = process.env.MINIMAX_API_KEY;

  console.log('Testando MiniMax Image Generation...');
  console.log('Base URL:', minmBase);
  console.log('Chave presente:', !!apiKey);

  try {
    const res = await fetch(`${minmBase}/v1/image_generation`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        model: 'image-01',
        prompt: 'A cute little cartoon boy in a bright colorful playground, 3D Pixar style, child book illustration, high resolution, 16:9 aspect ratio',
        n: 1
      })
    });

    console.log('Status HTTP:', res.status, res.statusText);
    const text = await res.text();
    console.log('Resposta bruta:', text);
  } catch (err) {
    console.error('Erro na requisição:', err);
  }
}

testMiniMaxImage();
