```tsx
import { useMemo, useState } from 'react';
import { useChat } from '@ai-sdk/react';
import { GenkitChatTransport } from '@genkit-ai/vercel-ai/client';
function Chat() {
// The chat id is sent to the agent as its sessionId, so it must be a UUID.
const chatId = useMemo(() => crypto.randomUUID(), []);
const [input, setInput] = useState('');
const { messages, sendMessage, status } = useChat({
id: chatId,
transport: new GenkitChatTransport({ url: '/api/weatherAgent' }),
});
return (
<>
{messages.map((message) => (
{message.role}:
{/* A UIMessage is a list of typed parts; render the text ones. */}
{message.parts.map((part, i) =>
part.type === 'text' ? {part.text} : null,
)}
))}
>
);
}
```