@flowpilot/sdk
v0.0.3
Published
The official TypeScript/JavaScript SDK for Flow Pilot, enabling seamless integration of AI-powered chat capabilities into your applications.
Downloads
170
Readme
@flowpilot/sdk
The official TypeScript/JavaScript SDK for Flow Pilot, enabling seamless integration of AI-powered chat capabilities into your applications.
Installation
npm install @flowpilot/sdk
# or
yarn add @flowpilot/sdk
Quick Start
import { FlowPilot } from '@flowpilot/sdk';
// Initialize the SDK
const flowPilot = new FlowPilot({
apiKey: 'your-sdk-api-key',
app: {
id: 'your-app-id',
environmentId: 'your-environment-id',
apiBaseURL: 'https://api.your-app.com'
},
getAuthToken: async () => {
// Return your app's auth token
return 'your-auth-token';
}
});
// Start chatting
const response = await flowPilot.chat('Hello!');
console.log(response);
Configuration
The SDK requires the following configuration parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| apiKey
| string
| Your Flow Pilot SDK API key |
| app.id
| string
| Your application ID |
| app.environmentId
| string
| Your environment ID |
| app.apiBaseURL
| string
| Base URL for your application's API |
| getAuthToken
| () => Promise<string>
| Function that returns your app's authentication token |
Chat API
The SDK provides a simple chat interface:
// Basic chat
const response = await flowPilot.chat('What are today\'s tasks?');
// Chat with thread ID for conversation continuity
const response = await flowPilot.chat('What are today\'s tasks?', {
threadId: 'unique-thread-id'
});
Thread Management
- If no
threadId
is provided, a new thread is automatically created - Use the same
threadId
to continue a conversation - Each thread maintains its own conversation context
Error Handling
try {
const response = await flowPilot.chat('Hello');
} catch (error) {
console.error('Chat error:', error);
}
TypeScript Support
The SDK is written in TypeScript and provides full type definitions out of the box.
import { FlowPilot, FlowPilotSDKArgs } from '@flowpilot/sdk';
const config: FlowPilotSDKArgs = {
apiKey: 'your-sdk-api-key',
app: {
id: 'your-app-id',
environmentId: 'your-environment-id',
apiBaseURL: 'https://api.your-app.com'
},
getAuthToken: async () => 'your-auth-token'
};
License
MIT