TypeScript SDK

Official TypeScript SDK for Tenzro Cloud. Works with Node.js 18+, Deno, and Bun.

Installation

npm install @tenzro/cloud

Quick Start

import { Tenzro } from '@tenzro/cloud';
const client = new Tenzro({
apiKey: process.env.TENZRO_API_KEY!,
projectId: 'your-project-id', // optional - sets default for all calls
ai: {
provider: 'google',
model: 'gemini-2.5-flash',
},
});
// Simple chat - just provide a prompt!
const response = await client.ai.chat('What is machine learning?');
console.log(response);

AI Inference

// Simple chat with defaults
const answer = await client.ai.chat('Explain quantum computing');
// With options
const response = await client.ai.chat('Write a haiku', {
provider: 'anthropic',
model: 'claude-sonnet-4',
temperature: 0.9,
});
// Full control with infer()
const result = await client.ai.infer({
provider: 'google',
model: 'gemini-2.5-pro',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello!' },
],
temperature: 0.7,
maxTokens: 1024,
});
console.log(result.content);
console.log('Tokens used:', result.usage.totalTokens);

Streaming

// Stream responses
for await (const chunk of client.ai.chatStream('Write a story about AI')) {
process.stdout.write(chunk);
}
// Or with full control
const stream = client.ai.inferStream({
provider: 'google',
model: 'gemini-2.5-flash',
prompt: 'Write a poem about clouds',
});
for await (const chunk of stream) {
process.stdout.write(chunk.content || '');
}

Vector Database

// Get database by name
const vectors = await client.vec.db('embeddings');
// Insert documents - embeddings are auto-generated!
await vectors.upsert({
documents: [
{ id: 'doc-1', text: 'Machine learning transforms data' },
{ id: 'doc-2', text: 'Neural networks are powerful', metadata: { category: 'ai' } },
],
});
// Query with natural language
const results = await vectors.query({
text: 'How does AI learn?',
topK: 5,
});
// Create a new database
const db = await client.vec.createDatabase({
dbName: 'my-embeddings',
dimension: 768,
metricType: 'COSINE',
});

Key-Value Store

// Get store by name
const store = await client.kev.store('sessions');
// Set value with TTL
await store.set('user:123', { name: 'John', role: 'admin' }, { ttl: 3600 });
// Get value
const user = await store.get('user:123');
// Hash operations
await store.hset('user:123', 'preferences', { theme: 'dark' });
const prefs = await store.hget('user:123', 'preferences');
// List operations
await store.lpush('queue', 'task-1', 'task-2');
const task = await store.rpop('queue');

AI Agents

import { Tenzro, tool } from '@tenzro/cloud';
// Define custom tools
const searchTool = tool(
'search_products',
'Search the product catalog',
{
query: { type: 'string', description: 'Search query' },
category: { type: 'string', description: 'Product category' },
},
['query']
);
// Create an agent
const agent = await client.agents.create({
agentName: 'Shopping Assistant',
endpointId: 'your-endpoint-id',
systemPrompt: 'You help customers find products.',
orchestrationPattern: 'SINGLE',
tools: [searchTool],
});
// Activate the agent
await client.agents.activate(agent.agentId);
// Chat with the agent
const response = await client.agents.chat(agent.agentId, {
message: 'Find me wireless headphones',
});
console.log(response.content);

Inference Endpoints

// Create a reusable endpoint with pre-configured settings
const endpoint = await client.ai.createEndpoint({
endpointName: 'customer-support-bot',
provider: 'google',
model: 'gemini-2.5-flash',
systemPrompt: 'You are a helpful customer support agent.',
temperature: 0.7,
});
// Use the endpoint for inference
const response = await client.ai.inferWithEndpoint(endpoint.endpointId, {
prompt: 'How do I reset my password?',
});
// Stream responses from the endpoint
for await (const chunk of client.ai.inferWithEndpointStream(endpoint.endpointId, {
prompt: 'Explain our return policy',
})) {
process.stdout.write(chunk.content || '');
}

Embeddings

// Generate embeddings
const result = await client.ai.embed({
texts: ['Hello world', 'Machine learning is amazing'],
taskType: 'RETRIEVAL_DOCUMENT',
outputDimensionality: 768,
});
console.log(result.embeddings); // [[0.1, 0.2, ...], [0.3, 0.4, ...]]

File Storage

// List buckets
const buckets = await client.files.listBuckets();
// Upload a file
const file = await client.files.upload('bucket-id', {
fileName: 'document.pdf',
content: fileBuffer,
contentType: 'application/pdf',
});
// Get a signed download URL
const url = await client.files.getSignedUrl('bucket-id', 'file-id');

Available Services

ServiceDescription
client.aiAI inference, embeddings, endpoints, image/video generation
client.agentsAI agent creation, activation, chat, tool execution
client.workflowsVisual workflow creation and execution
client.vecVector database for embeddings and semantic search
client.kevKey-value store with hashes, lists, pub/sub
client.dataPostgreSQL databases with query builder
client.graphGraph database for nodes and edges
client.filesObject storage with buckets and signed URLs
client.serverMCP server deployments
client.hubModel repository with ONNX support
client.securityCryptographic keys, encryption, post-quantum KEM
client.enclavesConfidential VMs with AMD SEV-SNP
client.cortexModel training and weights management
client.cortexRuntimeBrowser-based ONNX inference
client.edgeEdge SDK for browser applications

Error Handling

import { TenzroError, AuthenticationError, RateLimitError } from '@tenzro/cloud';
try {
await client.ai.chat('Hello');
} 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 TenzroError) {
console.error(`API error ${error.status}: ${error.message}`);
}
}

Related