1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65# Flowise SDK
A TypeScript SDK for interacting with the Flowise API.
## Installation
```bash
npm install flowise-sdk
```
## Usage
```typescript
import { FlowiseClient } from 'flowise-sdk';
const flowise = new FlowiseClient({ baseUrl: 'http://localhost:3000' });
async function main() {
const completion = await flowise.createPrediction({
chatflowId: '<id>',
question: "hello",
streaming: true
});
for await (const chunk of completion) {
console.log(chunk);
}
}
main();
```
## API Reference
### `FlowiseClient`
The main class for interacting with the Flowise API.
#### Constructor
```typescript
new FlowiseClient(baseUrl?: <your-base-url>, apiKey: <chatflow-apikey>)
```
- `baseUrl`: Optional. The base URL for the Flowise API. Defaults to 'http://localhost:3000'
- `apiKey`: Optional. The API Key used to access the chatflow
#### Methods
##### `createPrediction(params: PredictionParams)`
Creates a new prediction.
- `params`: An object containing the following properties:
- `chatflowId`: string - Chatflow ID to execute prediction
- `question`: string - The question to ask.
- `streaming`: boolean (optional) - Whether to stream the response.
- `chatId`: string (optional) - Chat ID of the session
- `overrideConfig`: object (optional) - Override configuration
- `history`: array (optional) - Array of prepended messages
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.