Guide: Getting started with Klu Python SDK

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

Step 1: Install the Klu SDK

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

pip install klu

Step 2: Import Klu

Next, you need to import the Klu module in your Python script:

from klu import Klu

Step 3: Initialize Klu

Now, you need to initialize Klu with your API key. You can find your API key in your Klu workspace settings.

klu = Klu('YOUR_API_KEY')

Step 4: Create an Action

To create an action, you need to define a prompt template, model config, and additional Klu-specific configurations. Here's an example:

action = klu.actions.create(
    name='Content Analyzer',
    description='Analyzes any given piece of text content',
    prompt_template='Analyze the following content: {{content}}',
    action_type="prompt",
    app_guid=app.guid,
    model_guid=models[0].guid
)

Step 5: Run the Action

Finally, you can run the action with your input:

result = klu.actions.prompt(action=action.guid,input={'content': 'Your text here'})
print(result)

This will print the generated text to the console.

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

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

More articles

Guide: How to Fine-tune OpenAI GPT-4

Learn how to fine-tune OpenAI GPT-4 using your own data – with steps for data preparation, training, evaluation, and deployment to create customized LLM deployments for your specific applications.

Read more

Guide: Simplifying GPT-3.5 Turbo Fine-tuning with Klu.ai

Discover the streamlined process of fine-tuning OpenAI GPT-3.5 Turbo with Klu.ai. Learn how to easily prepare your data, train, evaluate, and deploy your custom LLM with our comprehensive guide.

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