import { streamText } from "ai"import { createOpenAI } from "@ai-sdk/openai"import { supermemoryTools } from "@supermemory/tools/ai-sdk"const openai = createOpenAI({ apiKey: "YOUR_OPENAI_KEY"})const result = await streamText({ model: openai("gpt-4-turbo"), prompt: "Remember that my name is Alice", tools: supermemoryTools("YOUR_SUPERMEMORY_KEY")})
const result = await streamText({ model: openai("gpt-4"), prompt: "What are my dietary preferences?", tools: supermemoryTools("API_KEY")})// The AI will automatically call searchMemories tool// Example tool call:// searchMemories({ informationToGet: "dietary preferences and restrictions" })
const result = await streamText({ model: anthropic("claude-3-sonnet"), prompt: "Remember that I'm allergic to peanuts", tools: supermemoryTools("API_KEY")})// The AI will automatically call addMemory tool// Example tool call:// addMemory({ memory: "User is allergic to peanuts" })
const result = await streamText({ model: openai("gpt-4"), prompt: "Get the details of memory abc123", tools: supermemoryTools("API_KEY")})// The AI will automatically call fetchMemory tool// Example tool call:// fetchMemory({ memoryId: "abc123" })
import { searchMemoriesTool, addMemoryTool, fetchMemoryTool} from "@supermemory/tools/ai-sdk"// Use only search toolconst result = await streamText({ model: openai("gpt-4"), prompt: "What do you know about me?", tools: { searchMemories: searchMemoriesTool("API_KEY", { projectId: "personal" }) }})// Combine with custom toolsconst result = await streamText({ model: anthropic("claude-3"), prompt: "Help me with my calendar", tools: { searchMemories: searchMemoriesTool("API_KEY"), // Your custom tools createEvent: yourCustomTool, sendEmail: anotherCustomTool }})