How Neuro Cart uses the Vercel AI SDK and Cohere to power intelligent features across the platform using Next.js Server Actions.
| Layer | Technology |
|---|---|
| SDK | ai (Vercel AI SDK v6) |
| Provider | @ai-sdk/cohere (Command A) |
| Runtime | Next.js Server Actions ("use server") |
Unlike traditional setups that use API routes, Neuro Cart uses Server Actions for AI operations. This allows for direct calls from Client Components while maintaining server-side security for API keys.
graph LR
A[React Client] -->|Server Action| B[AI Service]
B -->|generateText| C[Cohere Command A]
C -->|Response| B
B -->|Return JSON/Text| A
The AI logic is organized by app in app/actions/ai.ts:
apps/store/app/actions/ai.tsapps/seller/app/actions/ai.tsapps/admin/app/actions/ai.ts
Used in the Store for smart search:
export async function searchProducts(query: string) {
const { text } = await generateText({
model: cohere("command-a-03-2025"),
prompt: `Based on the user query: "${query}", identify the most relevant product category and keywords...`,
});
// Parse and return results
}Used in the Admin dashboard for moderation:
export async function analyzeContent(
content: string,
contentType: "product" | "review",
) {
const { text } = await generateText({
model: cohere("command-a-03-2025"),
prompt: `Analyze the following ${contentType} for policy violations...`,
});
return JSON.parse(text);
}| Dashboard | Features |
|---|---|
| Store | Smart search, product recommendations, listing summarization |
| Seller | AI product copy generation, SEO tag generation, sales pattern analysis |
| Admin | Automated content moderation, platform-wide insights, fraud pattern detection |
To adjust the AI behavior, modify the prompt strings inside the corresponding ai.ts file for the specific feature.