Docs / API Reference
Edit on GitHub

Core Exports

import {
  Viber,
  Agent,
  streamText,
  generateText,
} from "openviber";

Viber

The primary class for running agents with context injection.

Constructor

new Viber(config: AgentConfig, options?: ViberOptions)

ViberOptions

PropertyTypeDescription
modelstringOverride model
agentIdstringAgent identifier
configPartial<AgentConfig>Config overrides

Methods

streamText(options)

Stream a text response with context injection.

const result = await viber.streamText({
  messages: Message[],
  plan?: string,           // Plan context (markdown)
  memory?: string,         // Memory excerpt
  artifacts?: ArtifactRef[], // Artifact references
  metadata?: Record<string, any>,
});

generateText(options)

Generate a complete text response (non-streaming).

const result = await viber.generateText({
  messages: Message[],
  plan?: string,
  memory?: string,
  artifacts?: ArtifactRef[],
});

getAgent()

Get the underlying Agent instance.

const agent = viber.getAgent();

getSummary()

Get agent summary information.

const summary = viber.getSummary();
// { id, name, description, tools, llmModel, agentId }

Agent

The core agent class for LLM interaction.

Constructor

new Agent(config: AgentConfig)

AgentConfig

PropertyTypeRequiredDescription
namestringAgent identifier
descriptionstringAgent description
providerstringLLM provider
modelstringModel identifier
systemPromptstringAgent instructions
toolsstring[]Available tools
skillsstring[]Loaded skills
temperaturenumberCreativity (0-1)
maxTokensnumberResponse limit

Methods

streamText(options)

Stream a text response.

const result = await agent.streamText({
  messages: ViberMessage[],
  system?: string,
  spaceId?: string,
  metadata?: Record<string, any>,
});

for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}

generateText(options)

Generate a complete text response.

const result = await agent.generateText({
  messages: ViberMessage[],
  system?: string,
});

Message Types

ViberMessage

interface ViberMessage {
  role: "user" | "assistant" | "system";
  content: string | ContentPart[];
  metadata?: Record<string, any>;
}

ArtifactRef

interface ArtifactRef {
  id: string;
  title?: string;
  type?: string;  // "file" | "screenshot" | "log"
  ref?: string;   // Path or URL
}

Daemon Runtime

runTask

Execute a task through the daemon runtime.

import { runTask } from "openviber";

const { streamResult, agent } = await runTask(
  "Build a landing page",
  {
    taskId: "task-123",
    singleAgentId: "developer",
    model: "anthropic/claude-sonnet-4-20250514",
  },
  messages
);

loadAgentConfig

Load agent configuration from file.

import { loadAgentConfig } from "openviber";

const config = await loadAgentConfig("developer");
// Loads from ~/.openviber/agents/developer.yaml

AI SDK Re-exports

OpenViber re-exports key Vercel AI SDK functions:

import { streamText, generateText } from "openviber";

// Use directly
const result = await streamText({
  model: openai("gpt-4o"),
  messages: [{ role: "user", content: "Hello" }],
});