const url = "https://netmind.api.corbits.dev/chat/completions";
const response = await fetchWithPayer(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "meta-llama/Meta-Llama-3.1-8B-Instruct",
messages: [
{
role: "system",
content: "Act like you are a helpful assistant.",
},
{
role: "user",
content: "Hi there!",
},
],
max_tokens: 512,
}),
});
if (!response.ok) {
const text = await response.text().catch(() => "");
throw new Error(`HTTP ${response.status} ${response.statusText} ${text}`);
}
const data = await response.json();
console.log("Assistant response:", data.choices[0].message.content);