//const fetch = require('node-fetch');

const url = 'http://127.0.0.1:11434/api/generate';

const body = {
  model: 'llama3',                 // or llama3:8b
  prompt: 'Say hello from llama3',
  stream: false                    // single JSON result
};

(async () => {
  try {
    const res = await fetch(url, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(body)
    });
    if (!res.ok) throw new Error(await res.text());
    const json = await res.json();

    console.log('RAW JSON:', json);
    console.log('TEXT:', json.response); // read .response here
  } catch (err) {
    console.error('Error:', err);
  }
})();
