Python SDK
Official Python SDK for Tenzro Cloud. Supports Python 3.10+ with both sync and async clients.
Installation
pip install tenzro-cloud
Quick Start
from tenzro_cloud import Tenzroimport osclient = Tenzro(api_key=os.environ["TENZRO_API_KEY"],project_id=os.environ.get("TENZRO_PROJECT_ID"), # optional default)# Simple chat - just provide a prompt!response = client.ai.chat("What is machine learning?")print(response)
Async Client
from tenzro_cloud import AsyncTenzroimport asyncioasync def main():client = AsyncTenzro(api_key=os.environ["TENZRO_API_KEY"])response = await client.ai.chat("Hello!")print(response)await client.close()asyncio.run(main())
AI Inference
# Simple chatresponse = client.ai.chat("Explain quantum computing")# With optionsresponse = client.ai.chat("Write a haiku",provider="anthropic",model="claude-sonnet-4",temperature=0.9,)# Full control with infer()result = 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,max_tokens=1024,)print(result.content)print(f"Tokens used: {result.usage.total_tokens}")
Vector Database
# Get database by namevectors = client.vec.db("embeddings")# Insert documents - embeddings are auto-generated!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 languageresults = vectors.query(text="How does AI learn?",top_k=5,)for match in results:print(f"{match.metadata['_text']} - score: {match.score}")# Create a new databasedb = client.vec.create_database(db_name="my-embeddings",dimension=768,metric_type="COSINE",)
Key-Value Store
# Get store by namestore = client.kev.store("sessions")# Set value with TTLstore.set("user:123", {"name": "John", "role": "admin"}, ttl=3600)# Get valueuser = store.get("user:123")# Hash operationsstore.hset("user:123", "preferences", {"theme": "dark"})prefs = store.hget("user:123", "preferences")# List operationsstore.lpush("queue", "task-1", "task-2")task = store.rpop("queue")
AI Agents
from tenzro_cloud import tool# Define custom toolssearch_tool = tool(name="search_products",description="Search the product catalog",properties={"query": {"type": "string", "description": "Search query"},"category": {"type": "string", "description": "Product category"},},required=["query"],)# Create an agentagent = client.agents.create(agent_name="Shopping Assistant",endpoint_id="your-endpoint-id",system_prompt="You help customers find products.",orchestration_pattern="SINGLE",tools=[search_tool],)# Activate the agentclient.agents.activate(agent.agent_id)# Chat with the agentresponse = client.agents.chat(agent_id=agent.agent_id,message="Find me wireless headphones",)print(response.content)
Streaming
# Stream responsesfor chunk in client.ai.chat_stream("Write a story about AI"):print(chunk, end="", flush=True)# Or with full controlstream = client.ai.infer_stream(provider="google",model="gemini-2.5-flash",prompt="Write a poem about clouds",)for chunk in stream:print(chunk.content or "", end="", flush=True)
Context Manager
# Automatically close clientwith Tenzro(api_key=api_key) as client:response = client.ai.chat("Hello!")# Async context managerasync with AsyncTenzro(api_key=api_key) as client:response = await client.ai.chat("Hello!")
Available Services
| Service | Description |
|---|---|
client.ai | AI inference, embeddings, endpoints |
client.agents | AI agent creation, activation, chat |
client.workflows | Visual workflow execution |
client.vec | Vector database for embeddings |
client.kev | Key-value store with hashes, lists |
client.data | PostgreSQL databases |
client.graph | Graph database operations |
client.files | Object storage |
client.server | MCP server deployments |
client.hub | Model repository |
client.security | Cryptographic operations |
client.enclaves | Confidential VMs |
Error Handling
from tenzro_cloud import TenzroError, AuthenticationError, RateLimitErrortry:client.ai.chat("Hello")except AuthenticationError:print("Invalid API key")except RateLimitError as e:print(f"Rate limited, retry after: {e.retry_after}")except TenzroError as e:print(f"API error {e.status_code}: {e.message}")