2.0.0-rc-5 • Published 5 months ago

@flowpilot/sdk v2.0.0-rc-5

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

@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:

ParameterTypeDescription
apiKeystringYour Flow Pilot SDK API key
app.idstringYour application ID
app.environmentIdstringYour environment ID
app.apiBaseURLstringBase 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

2.0.0-rc-5

5 months ago

2.0.0-rc-4

5 months ago

2.0.0-rc-3

5 months ago

2.0.0-rc-2

5 months ago

2.0.0-rc-1

5 months ago

1.0.0

5 months ago

0.0.6

6 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago