Quick Start
Create Your First Agent
Section titled “Create Your First Agent”-
Import Viber
import { Agent, Space, streamText } from 'viber'; -
Define an Agent
const agent = new Agent({name: 'Assistant',model: 'openai:gpt-4o',systemPrompt: 'You are a helpful assistant.',}); -
Stream a Response
const result = await agent.streamText({messages: [{ role: 'user', content: 'Hello!' }],});for await (const chunk of result.textStream) {process.stdout.write(chunk);}
Framework Integration
Section titled “Framework Integration”import { useAgent } from 'viber/react';
function Chat() { const { messages, sendMessage } = useAgent({ model: 'openai:gpt-4o', });
return ( <div> {messages.map((m) => ( <p key={m.id}>{m.content}</p> ))} </div> );}<script lang="ts"> import { createAgentStore } from 'viber/svelte';
const agent = createAgentStore({ model: 'openai:gpt-4o', });</script>
{#each $agent.messages as message} <p>{message.content}</p>{/each}Next Steps
Section titled “Next Steps”- Learn about Agents and how to configure them
- Explore the Tool Framework for extending agent capabilities
- Understand Spaces for organizing workspaces