Using the SDK
Basic examples and walkthroughs to get you using the SDK immediately.
Installing the SDKGenerate API Key
Initialize the client
import PropulsionAI from 'propulsionai';
const client = new PropulsionAI({
bearerToken: process.env['PROPULSIONAI_BEARER_TOKEN'],
});
Chat
async function main() {
const completionCreateResponse = await client.chat.completions.create({
deployment: '<deployment_id>',
messages=[
{
"role": "user",
"content": "Hello, How are you?",
}
],
stream: false
});
console.log(completionCreateResponse.choices);
}
main();
Streaming Chat
async function main() {
const completionCreateResponse = await client.chat.completions.create({
deployment: '<deployment_id>',
messages=[
{
"role": "user",
"content": "Hello, How are you?",
}
],
stream: true
});
for await (const part of stream) {
process.stdout.write(part.choices[0]?.delta?.content || '');
}
}
main();
Last updated