1.1.0 • Published 1 year ago

@iquly/sdk v1.1.0

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

@iquly/sdk

Official TypeScript SDK for the IQuly AI Tools Platform.

Installation

# Using npm
npm install @iquly/sdk

# Using yarn
yarn add @iquly/sdk

# Using pnpm
pnpm add @iquly/sdk

# Using bun
bun add @iquly/sdk

Quick Start

import { IQuly } from "@iquly/sdk";

// Initialize the client
const client = new IQuly({
  apiKey: "your-api-key",
  // Optional configurations
  baseUrl: "https://iquly.com/api", // Default
  timeout: 30000, // Default: 30 seconds
});

// Get a toolkit
const toolkit = await client.getToolkit("toolkit-id", "provider");

// Execute a function
const result = await client.executeFunction("function-id", {
  // function parameters
});

// Listen to execution events
client.on("execution.complete", ({ functionId, result }) => {
  console.log(`Function ${functionId} completed:`, result);
});

client.on("execution.error", ({ functionId, error }) => {
  console.error(`Function ${functionId} failed:`, error);
});

Features

  • 🔒 Type-safe API with TypeScript support
  • 🚀 Promise-based async/await API
  • 📦 Built-in TypeScript types
  • 🎯 Event-driven architecture
  • ⚡ Automatic request timeout handling
  • 🔄 Vercel AI Tools compatibility

Configuration

The SDK accepts the following configuration options:

interface IQulyConfig {
  apiKey: string; // Required: Your IQuly API key
  baseUrl?: string; // Optional: API base URL (default: https://iquly.com/api)
  timeout?: number; // Optional: Request timeout in ms (default: 30000)
  retryAttempts?: number; // Optional: Number of retry attempts
  debug?: boolean; // Optional: Enable debug mode
}

Error Handling

The SDK provides several custom error types for better error handling:

  • IQulyError: Base error class for all SDK errors
  • AuthenticationError: Thrown when authentication fails
  • RateLimitError: Thrown when rate limit is exceeded
  • ToolExecutionError: Thrown when a tool execution fails
  • ValidationError: Thrown when input validation fails
try {
  await client.executeFunction("function-id", params);
} catch (error) {
  if (error instanceof AuthenticationError) {
    // Handle authentication error
  } else if (error instanceof RateLimitError) {
    // Handle rate limit error
  } else {
    // Handle other errors
  }
}

Events

The SDK emits the following events:

  • execution.complete: Emitted when a function execution completes successfully
  • execution.error: Emitted when a function execution fails
1.1.0

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago