TypeScript SDK
Official TypeScript SDK for Tenzro Cloud. Works with Node.js, Deno, Bun, and browser environments.
Installation
npm install tenzro# orpnpm add tenzro# oryarn add tenzro
Quick Start
import { Tenzro } from 'tenzro';const tenzro = new Tenzro({apiKey: process.env.TENZRO_API_KEY!,});// AI chat completionconst response = await tenzro.ai.chat({model: 'gemini-2.5-flash',messages: [{ role: 'user', content: 'Hello!' },],});console.log(response.responseText);
Vector Database
// Create vector databaseconst db = await tenzro.vec.create({projectId: 'project-id',db_name: 'embeddings',dimension: 1536,});// Insert vectorsawait tenzro.vec.insert(db.vec_db_id, [{id: 'doc-1',vector: embedding,metadata: { title: 'Document 1' },},]);// Search vectorsconst results = await tenzro.vec.search(db.vec_db_id, {vector: queryEmbedding,topK: 10,});
Key-Value Store
// Set value with TTLawait tenzro.kev.set('session:123', userData, {ttl: 3600, // 1 hour});// Get valueconst session = await tenzro.kev.get('session:123');// Delete valueawait tenzro.kev.delete('session:123');
AI Agents
// Create agentconst agent = await tenzro.agents.create({projectId: 'project-id',agentName: 'assistant',systemPrompt: 'You are a helpful assistant.',aiModel: 'gemini-2.5-flash',});// Chat with agentconst response = await tenzro.agents.chat(agent.agent_id, {message: 'Hello!',conversationId: 'conv-123',});console.log(response.response);
Streaming
// Stream AI responsesconst 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
| Service | Description |
|---|---|
tenzro.ai | AI inference (chat, embeddings, multi-modal) |
tenzro.agents | AI agent orchestration with tools and memory |
tenzro.vec | Vector database for embeddings and similarity search |
tenzro.kev | Key-value store for sessions, cache, and state |
tenzro.data | PostgreSQL databases for structured data |
tenzro.graph | Graph database for relationships and traversals |
tenzro.files | Object storage for files and media |
tenzro.workflows | Visual workflow execution |
tenzro.hub | Model hub for browsing and downloading models |
tenzro.enclaves | Secure enclaves for sensitive data |
tenzro.security | Cryptographic operations and key management |
Related
- React SDK - React hooks and components
- Python SDK
- Rust SDK