API Reference / API Overview

Core Exports

The main viber package exports the following:


Agent

The primary class for creating AI agents.

Constructor

new Agent(config: AgentConfig)

AgentConfig

PropertyTypeRequiredDescription
namestringAgent identifier
modelstringLLM model (e.g., openai:gpt-4o)
systemPromptstringAgent instructions
toolsTool[]Available tools
temperaturenumberCreativity (0-1)
maxTokensnumberResponse limit

Methods

streamText(options)

Stream a text response.

const result = await agent.streamText({
  messages: Message[],
  onToolCall?: (call) => void,
});

generateText(options)

Generate a complete text response (non-streaming).

const result = await agent.generateText({
  messages: Message[],
});

Space

Workspace management for organizing artifacts and history.

Constructor

new Space(config: SpaceConfig)

Methods

MethodReturnsDescription
saveArtifact(name, content)Promise<void>Save an artifact
readArtifact(name)Promise<string>Read an artifact
listArtifacts()Promise<string[]>List all artifacts
getHistory()Promise<Message[]>Get conversation history
clearHistory()Promise<void>Clear history

tool()

Define a tool for agents.

const myTool = tool({
  name: string,
  description: string,
  parameters: ZodSchema,
  execute: (params) => Promise<any>,
});

Framework Adapters

React (viber/react)

Svelte (viber/svelte)

Server (viber/server)