Initial Project Setup and AI SDK Integration

implementationChallenge

Prompt Content

Set up a new Next.js project and integrate the Vercel AI SDK. Initialize a client for Gemini 2.5 Pro. Create a basic chat component that can send prompts to the model and display streaming responses in the UI. Ensure your project structure supports future integration of structured output validation and voice features.

```typescript
// app/api/chat/route.ts
import { GoogleGenerativeAI } from '@google/generative-ai';
import { GoogleGenerativeAIStream, Message, StreamingTextResponse } from 'ai';

const genai = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY || '');

export const runtime = 'edge';

export async function POST(req: Request) {
  const { messages } = await req.json();

  const model = genai.getGenerativeModel({ model: 'gemini-pro' });
  const stream = await model.generateContentStream({
    contents: messages.map((m: Message) => ({ role: m.role, parts: [{ text: m.content }] })),
  });

  return new StreamingTextResponse(GoogleGenerativeAIStream(stream));
}
```

Try this prompt

Open the workspace to execute this prompt with free credits, or use your own API keys for unlimited usage.

Usage Tips

Copy the prompt and paste it into your preferred AI tool (Claude, ChatGPT, Gemini)

Customize placeholder values with your specific requirements and context

For best results, provide clear examples and test different variations