const query = [
"Which grocers would try a new chip flavor, and when should I bring a sample?",
"Ask independent grocers in Austin, Texas about a Dill Pickle sample.",
"Find out when to visit before the snack buyer places the next order.",
].join("\n");
const apiKey = process.env.THRED_API_KEY;
if (!apiKey) throw new Error("Set THRED_API_KEY");
const response = await fetch("https://api.thred.dev/v1/search", {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query,
results: 3,
}),
});
if (!response.ok) throw new Error(`Thred returned HTTP ${response.status}`);
const { id }: { id: string } = await response.json();
console.log(id);