Klu raises $1.7M to empower AI Teams  

Guide: Getting started with Klu Typescript SDK

by Stephen M. Walker II, Co-Founder / CEO

Sure, here's a step-by-step guide on how to create your first Klu action using the TypeScript SDK:

Step 1: Install the Klu TypeScript SDK

First, you need to install the Klu TypeScript SDK. You can do this by running the following command in your terminal:

pnpm i @kluai/core

Step 2: Import Klu

Next, you need to import the Klu module in your TypeScript file:

import Klu from '@kluai/core'

Step 3: Initialize Klu

Now, you need to initialize Klu with your API key:

const klu = new Klu('YOUR_API_KEY')

Step 4: Create an Action

To create an action, you need to use the createAction method. This method takes an object as an argument, which should contain the following properties:

namestringThe name of the action.
descriptionstringA brief description of the action.
promptstringThe prompt that will be sent to the model.
providerstringThe model provider.
modelstringThe model for the action.

Here's an example of how to create an action:

const action = await klu.actions.create({
  name: 'Content Analyzer',
  description: 'Analyzes any given piece of text content.',
  prompt: 'Analyze the following content\nProvide a summary of the main arguments\n======\n{{content}}',
  action_type: 'prompt',
  app_guid: app.guid,
  model_guid: models[0].guid

Step 5: Run the Action

Finally, you can run the action using the runAction method. This method takes the action ID and the input as arguments:

const result = await klu.actions.prompt(action.id, { content: 'Your content here' })

The runAction method will return the generated text.

And that's it! You've just created and run your first Klu action using the TypeScript SDK. Remember to replace 'YOUR_API_KEY' and 'Your content here' with your actual API key and the text you want to analyze, respectively.

If you want to learn more about the Klu Typescript SDK, you can check out the developer docs.

More articles

Prompt Engineering Guide: A Comprehensive Survey of Prompt Techniques

Master the art and science of crafting prompts that precisely convey context and intent to transform how LLM systems interpret and respond to queries.

Read more

Best Open Source LLMs: Comprehensive Guide to Testing, Running, and Selecting

Open source LLMs like Llama 2, Mistral 7B, and Falcon are bringing advanced AI capabilities into the public domain. This guide explores the best open-source LLMs and variants for capabilities like chat, reasoning, and coding while outlining options to test models online or run them locally and in production.

Read more

It's time to build

Collaborate with your team on reliable Generative AI features.
Want expert guidance? Book a 1:1 onboarding session from your dashboard.

Start for free