Code Examples

Learn how to integrate EdgeMind into your projects

Basic Chat

Simple chat with the AI model

const response = await fetch('/api/chat', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    messages: [{ role: 'user', content: 'Hello!' }]
  })
});
const data = await response.json();
console.log(data.content);

Math Calculations

// Direct math requests
const response = await fetch('/api/chat', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    messages: [{ role: 'user', content: 'What is 25 + 17?' }]
  })
});
// Returns: "🔢 25 + 17 = 42"