@iquly/sdk
v1.1.0
Published
Official SDK for IQuly AI Tools Platform
Maintainers
Readme
@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/sdkQuick 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 errorsAuthenticationError: Thrown when authentication failsRateLimitError: Thrown when rate limit is exceededToolExecutionError: Thrown when a tool execution failsValidationError: 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 successfullyexecution.error: Emitted when a function execution fails
