TypeScript SDK quickstart

Last updated: 2025-01-15
1 min read

TypeScript SDK Quickstart

Build with TaskForceAI using TypeScript.

Installation

npm install @taskforceai/sdk
# or
yarn add @taskforceai/sdk

Setup

import { TaskForceAI } from '@taskforceai/sdk';

const client = new TaskForceAI({
  apiKey: process.env.TASKFORCEAI_API_KEY,
});

Basic Usage

const response = await client.chat.create({
  messages: [
    { role: 'user', content: 'Hello!' }
  ],
});

console.log(response.choices[0].message.content);

Streaming

const stream = await client.chat.create({
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0].delta.content || '');
}

Type Safety

The SDK is fully typed. Use your IDE's autocomplete for available options.

Next Steps

See the [full documentation] (https://docs.taskforceai.chat/docs/typescript-sdk) for advanced usage.

Still need help?

Our support team is available to assist you.

Contact Support