SDK Reference

Documentation for Tora AI's client SDKs

Back to API Reference

JavaScript/TypeScript SDK

The Tora AI JavaScript/TypeScript SDK provides a convenient way to integrate Tora AI's security features into your JavaScript and TypeScript applications.

Installation

npm install @tora/sdk

// or with yarn
yarn add @tora/sdk

Usage

import { ToraClient } from '@tora/sdk';

// Initialize the client
const client = new ToraClient({
  apiKey: process.env.TORA_API_KEY,
  environment: 'production' // or 'development'
});

// Register an agent
async function registerAgent() {
  try {
    const agent = await client.agents.register({
      id: 'agent-123',
      name: 'Assistant Bot',
      capabilities: ['text-generation', 'code-analysis']
    });
    
    console.log('Agent registered:', agent);
    
    // Create a security policy for the agent
    const policy = await client.policies.create({
      name: 'Basic Security Policy',
      agentId: agent.id,
      rules: [
        {
          type: 'rate-limit',
          params: {
            maxRequests: 100,
            timeWindow: '1h'
          }
        }
      ]
    });
    
    console.log('Policy created:', policy);
  } catch (error) {
    console.error('Error:', error);
  }
}

registerAgent();

API Reference

ToraClient

The main client class for interacting with the Tora AI API.

interface ToraClientOptions {
  apiKey: string;
  environment?: 'production' | 'development';
  baseUrl?: string;
  timeout?: number;
}

class ToraClient {
  constructor(options: ToraClientOptions);
  
  // Properties
  agents: AgentClient;
  policies: PolicyClient;
  security: SecurityClient;
  events: EventClient;
  webhooks: WebhookClient;
  system: SystemClient;
}

Python SDK

The Tora AI Python SDK provides a convenient way to integrate Tora AI's security features into your Python applications.

Installation

pip install tora-sdk

# or with poetry
poetry add tora-sdk

Usage

from tora import ToraClient

# Initialize the client
client = ToraClient(
    api_key="your-api-key",
    environment="production"  # or "development"
)

# Register an agent
def register_agent():
    try:
        agent = client.agents.register(
            id="agent-123",
            name="Assistant Bot",
            capabilities=["text-generation", "code-analysis"]
        )
        
        print(f"Agent registered: {agent.id}")
        
        # Create a security policy for the agent
        policy = client.policies.create(
            name="Basic Security Policy",
            agent_id=agent.id,
            rules=[
                {
                    "type": "rate-limit",
                    "params": {
                        "max_requests": 100,
                        "time_window": "1h"
                    }
                }
            ]
        )
        
        print(f"Policy created: {policy.id}")
    except Exception as e:
        print(f"Error: {e}")

register_agent()