TypeScript SDK

Official TypeScript SDK for Tenzro Cloud. Works with Node.js, Deno, Bun, and browser environments.

Installation

npm install tenzro
# or
pnpm add tenzro
# or
yarn add tenzro

Quick Start

import { Tenzro } from 'tenzro';
const tenzro = new Tenzro({
apiKey: process.env.TENZRO_API_KEY!,
});
// AI chat completion
const response = await tenzro.ai.chat({
model: 'gemini-2.5-flash',
messages: [
{ role: 'user', content: 'Hello!' },
],
});
console.log(response.responseText);

Vector Database

// Create vector database
const db = await tenzro.vec.create({
projectId: 'project-id',
db_name: 'embeddings',
dimension: 1536,
});
// Insert vectors
await tenzro.vec.insert(db.vec_db_id, [
{
id: 'doc-1',
vector: embedding,
metadata: { title: 'Document 1' },
},
]);
// Search vectors
const results = await tenzro.vec.search(db.vec_db_id, {
vector: queryEmbedding,
topK: 10,
});

Key-Value Store

// Set value with TTL
await tenzro.kev.set('session:123', userData, {
ttl: 3600, // 1 hour
});
// Get value
const session = await tenzro.kev.get('session:123');
// Delete value
await tenzro.kev.delete('session:123');

AI Agents

// Create agent
const agent = await tenzro.agents.create({
projectId: 'project-id',
agentName: 'assistant',
systemPrompt: 'You are a helpful assistant.',
aiModel: 'gemini-2.5-flash',
});
// Chat with agent
const response = await tenzro.agents.chat(agent.agent_id, {
message: 'Hello!',
conversationId: 'conv-123',
});
console.log(response.response);

Streaming

// Stream AI responses
const stream = await tenzro.ai.stream({
model: 'gemini-2.5-flash',
messages: [{ role: 'user', content: 'Write a story' }],
});
for await (const chunk of stream) {
process.stdout.write(chunk.text);
}

Error Handling

import { APIError, AuthenticationError, RateLimitError } from 'tenzro';
try {
await tenzro.ai.chat({ model: 'gemini-2.5-flash', messages: [] });
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('Invalid API key');
} else if (error instanceof RateLimitError) {
console.error('Rate limited, retry after:', error.retryAfter);
} else if (error instanceof APIError) {
console.error(`API error ${error.status}: ${error.message}`);
}
}

Available Services

ServiceDescription
tenzro.aiAI inference (chat, embeddings, multi-modal)
tenzro.agentsAI agent orchestration with tools and memory
tenzro.vecVector database for embeddings and similarity search
tenzro.kevKey-value store for sessions, cache, and state
tenzro.dataPostgreSQL databases for structured data
tenzro.graphGraph database for relationships and traversals
tenzro.filesObject storage for files and media
tenzro.workflowsVisual workflow execution
tenzro.hubModel hub for browsing and downloading models
tenzro.enclavesSecure enclaves for sensitive data
tenzro.securityCryptographic operations and key management

Related