Connect To Your Agent
AI SDK
Using Vercel AI SDK with GAIA
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Using Vercel AI SDK with GAIA
npm install ai
import { createOpenAI } from '@ai-sdk/openai';
const gaia = createOpenAI({
baseURL: 'http://localhost:3000/api/v1',
apiKey: 'gaia_your_api_key'
});
import { streamText } from 'ai';
export async function POST(req: Request) {
const { messages } = await req.json();
const result = await streamText({
model: gaia('proj_abc123'), // your project ID
messages
});
return result.toDataStreamResponse();
}
'use client';
import { useChat } from 'ai/react';
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit } = useChat({
api: '/api/chat'
});
return (
<div>
{messages.map(m => (
<div key={m.id}>
<strong>{m.role}:</strong> {m.content}
</div>
))}
<form onSubmit={handleSubmit}>
<input value={input} onChange={handleInputChange} />
<button type="submit">Send</button>
</form>
</div>
);
}
