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 callsai: {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 defaultsconst answer = await client.ai.chat('Explain quantum computing');// With optionsconst 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 responsesfor await (const chunk of client.ai.chatStream('Write a story about AI')) {process.stdout.write(chunk);}// Or with full controlconst 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 nameconst 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 languageconst results = await vectors.query({text: 'How does AI learn?',topK: 5,});// Create a new databaseconst db = await client.vec.createDatabase({dbName: 'my-embeddings',dimension: 768,metricType: 'COSINE',});
Key-Value Store
// Get store by nameconst store = await client.kev.store('sessions');// Set value with TTLawait store.set('user:123', { name: 'John', role: 'admin' }, { ttl: 3600 });// Get valueconst user = await store.get('user:123');// Hash operationsawait store.hset('user:123', 'preferences', { theme: 'dark' });const prefs = await store.hget('user:123', 'preferences');// List operationsawait store.lpush('queue', 'task-1', 'task-2');const task = await store.rpop('queue');
AI Agents
import { Tenzro, tool } from '@tenzro/cloud';// Define custom toolsconst searchTool = tool('search_products','Search the product catalog',{query: { type: 'string', description: 'Search query' },category: { type: 'string', description: 'Product category' },},['query']);// Create an agentconst agent = await client.agents.create({agentName: 'Shopping Assistant',endpointId: 'your-endpoint-id',systemPrompt: 'You help customers find products.',orchestrationPattern: 'SINGLE',tools: [searchTool],});// Activate the agentawait client.agents.activate(agent.agentId);// Chat with the agentconst 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 settingsconst 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 inferenceconst response = await client.ai.inferWithEndpoint(endpoint.endpointId, {prompt: 'How do I reset my password?',});// Stream responses from the endpointfor await (const chunk of client.ai.inferWithEndpointStream(endpoint.endpointId, {prompt: 'Explain our return policy',})) {process.stdout.write(chunk.content || '');}
Embeddings
// Generate embeddingsconst 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 bucketsconst buckets = await client.files.listBuckets();// Upload a fileconst file = await client.files.upload('bucket-id', {fileName: 'document.pdf',content: fileBuffer,contentType: 'application/pdf',});// Get a signed download URLconst url = await client.files.getSignedUrl('bucket-id', 'file-id');
Available Services
| Service | Description |
|---|---|
client.ai | AI inference, embeddings, endpoints, image/video generation |
client.agents | AI agent creation, activation, chat, tool execution |
client.workflows | Visual workflow creation and execution |
client.vec | Vector database for embeddings and semantic search |
client.kev | Key-value store with hashes, lists, pub/sub |
client.data | PostgreSQL databases with query builder |
client.graph | Graph database for nodes and edges |
client.files | Object storage with buckets and signed URLs |
client.server | MCP server deployments |
client.hub | Model repository with ONNX support |
client.security | Cryptographic keys, encryption, post-quantum KEM |
client.enclaves | Confidential VMs with AMD SEV-SNP |
client.cortex | Model training and weights management |
client.cortexRuntime | Browser-based ONNX inference |
client.edge | Edge 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}`);}}