Skip to main content
Follow our quickstart guide below or use an interactive notebook.

Installation

To connect to your Kolena Agents using Python, install the kolena-agents client from PyPI using any Python package manager such as pip or poetry:

Initialization

An API Key is required to use the python client. Create and copy a key, then store the value in a KOLENA_API_KEY environment variable:

Usage

Here’s an example of how to use the client to add, download and delete Agent Runs:

Managing Agent Properties

You can attach key-value pairs metadata to your Agents for organizing, filtering, and tracking purposes. Metadata values can be primitives (strings, numbers, booleans, or null) or arrays (lists of primitive values). See the API reference for more details.

Synchronous Usage

You can also add an Agent Run synchronously, which creates a Run and waits for processing of all prompts to complete. Note that this endpoint has rate limits.

Download Templated Output

When an Agent has an Output Template configured, Runs can be downloaded into the Template.

Query Access Logs

This is available on the Enterprise Plan. Contact Kolena if you’re not on an Enterprise plan but would like to try this feature.

View Credit History

Pull credit history to get insights on usage. See the API reference for more details.

Manage API Keys

Programmatically manage API keys for automated rotation and monitoring. See the API reference reference for more details.

Serializing to JSON

All kolena-agents objects are standard Pydantic data objects and can be easily converted to and from JSON:

Webhook

Kolena provides a helper function to handle signature verification and parsing. See Webhook Integration for more information.

Supported Python Versions

Python versions 3.8 and later are supported.