Skip to main content

Installation

npm install @voker/voker
Set the VOKER_API_KEY environment variable to your API key before using the SDK. You can find your key in the Voker dashboard under settings.

Quick start

Replace your existing LLM provider import with the Voker-wrapped version. No other code changes are required.
import { OpenAI } from 'openai'; 
import { OpenAI } from '@voker/voker/ai/provider-openai'; 

const client = new OpenAI();

await client.chat.completions.create({
    vokerAgent: 'customer-support-agent', // required
    vokerSession: 'user-session-1',       // required
    model: 'gpt-4o',
    messages: [{ role: 'user', content: 'Hello, world!' }],
});
The vokerAgent parameter identifies which agent handled the request. The vokerSession parameter ties the call to a specific session. Both are required for Voker to associate the event with the correct agent and session in your dashboard. For provider-specific setup guides, see OpenAI, Anthropic, Gemini, and AI SDK.

Typescript SDK Reference

VokerClient

The Voker Client provides a way to create an update Agents, Agent Versions, People and Events programmatically. Requests are made in the background as to not add latency to your application. This is used by the SDKs but can also be used directly if you want more control over when requests are sent. Instantiate once and reuse throughout your application. Class VokerClient
FieldTypeDescription
eventsVokerClient_EventsAccess events related endpoints.
peopleVokerClient_PeopleAccess people related endpoints.
agentsVokerClient_AgentsAccess agents related endpoints.
agentVersionsVokerClient_AgentVersionsAccess agent versions related endpoints.
start() - Initializes the background worker. Call this once before making any other requests. close() - Waits for all pending background requests to complete and shuts down the worker. Call this before your process exits to avoid dropped events. Class VokerClient_Agents create(payload: CreateAgentPayload) - Creates an agent with the given name. If the agent already exists, the call is a no-op. Class VokerClient_AgentVersions create(agentName: string, payload: CreateAgentVersionPayload) - Creates a new version under the specified agent. Class VokerClient_Events create(payload: ClientCreateEventPayload) - Enqueues an event for background delivery. vokerSession and eventName are required; agent, version, and person association fields are optional. Class VokerClient_People create(payload: CreatePersonPayload) - Creates a person record. If the person already exists, the call is a no-op. update(personId: string, payload: UpdatePersonPayload) - Merges the provided properties into an existing person record.

ApiClient

The API Client provides a way to make requests to the Voker API directly. This is used under the hood by the Voker Client, but can also be used directly if you want more control over how requests are made. Fetching Agents, Agent Versions, and People is a common use cases for using the API Client directly. Class ApiClient
FieldTypeDescription
eventsApiClient_EventsCreate events directly via the API.
peopleApiClient_PeopleGet, create, and update person records.
fingerprintsApiClient_FingerprintsCreate anonymous fingerprint identifiers.
agentsApiClient_AgentsCreate and fetch agent records.
agentVersionsApiClient_AgentVersionsCreate and fetch agent version records.
Class ApiClient_Agents create(payload: CreateAgentPayload) -> Agent - Creates and returns a new agent. get(agentName: string) -> Agent - Returns the agent with the given name. Class ApiClient_AgentVersions create(agentName: string, payload: CreateAgentVersionPayload) -> AgentVersion - Creates and returns a new version under the given agent. get(agentName: string, agentVersionName: string) -> AgentVersion - Returns the specified agent version. Class ApiClient_Events create(payload: CreateEventPayload) - Creates an event directly via the API. Class ApiClient_Fingerprints create() -> Fingerprint - Generates and returns a new anonymous fingerprint identifier. Class ApiClient_People get(personId: string) -> Person - Returns the person with the given ID. create(payload: CreatePersonPayload) -> Person - Creates and returns a new person. update(personId: string, payload: UpdatePersonPayload) -> Person - Merges properties into an existing person and returns the updated record.

Types

These TypeScript types are used as parameters and return values throughout the SDK.

CreateAgentPayload

FieldTypeDescription
agentNamestringUnique identifier name for the agent.
descriptionstring | null | undefinedOptional human-readable description.

CreateAgentVersionPayload

FieldTypeDescription
agentVersionNamestringUnique name for the version within the agent.
descriptionstring | null | undefinedOptional description.

ClientCreateEventPayload

FieldTypeRequiredDescription
vokerSessionstringYesSession identifier to associate this event with.
eventNamestringYesName of the event being recorded.
propertiesRecord<string, any>YesArbitrary key-value metadata for the event.
vokerAgentstring | undefinedNoAgent name to associate this event with.
vokerAgentVersionstring | undefinedNoAgent version name to associate this event with.
vokerPersonstring | undefinedNoPerson ID to associate this event with.

CreatePersonPayload

FieldTypeDescription
personIdstringYour application’s identifier for this person.
propertiesRecord<string, any> | undefinedOptional key-value metadata.

UpdatePersonPayload

FieldTypeDescription
propertiesRecord<string, any>Properties to merge into the person record.

Agent

Represents an AI agent registered in Voker.
FieldTypeDescription
agentNamestringUnique identifier name for the agent.
descriptionstring | nullOptional human-readable description.
agentNumbernumberAuto-assigned numeric identifier.
createdAtDateTimestamp when the agent was created.
deprecatedAtDate | nullTimestamp when the agent was deprecated, if ever.

AgentVersion

Represents a specific version of an agent.
FieldTypeDescription
agentVersionNamestringUnique name for this version within the agent.
descriptionstring | nullOptional description.
agentVersionNumbernumberAuto-assigned numeric identifier.
createdAtDateTimestamp when the version was created.
deprecatedAtDate | nullTimestamp when the version was deprecated, if ever.

Fingerprint

An anonymous identifier used to track activity without a known person ID.
FieldTypeDescription
fingerprintIdstringUnique fingerprint value.

Person

Represents a user or entity tracked in Voker.
FieldTypeDescription
personIdstringYour application’s identifier for this person.
propertiesRecord<string, any> | nullArbitrary key-value metadata.
createdAtDateTimestamp when the person was first created.