AgentOps has first party support for AI21 via its Python SDK. Explore development with AI21 by visiting their docs.

Steps to integrate AI21 with AgentOps

1

Install the AgentOps SDK

2

Install the AI21 SDK

We currently support v2.x.x of the AI21 SDK and plan to support v3.x.x in the future.

3

Add AgentOps to your code

Make sure to call agentops.init before calling any openai, cohere, crew, etc models.

Set your API key as an .env variable for easy access.

Read more about environment variables in Advanced Configuration

4

Run your Agent

Execute your program and visit app.agentops.ai/drilldown to observe your Agent! πŸ•΅οΈ

After your run, AgentOps prints a clickable url to console linking directly to your session in the Dashboard

Clickable link to session

Full Examples

Streaming Examples

Task-Specific Models

AI21 v2.x.x provides specialized models called Task Specific Models for specific tasks.

Here’s an example using the contextual answers endpoint:

If you want to stream the response, you can use the stream=True flag. The streaming response is handled by the AI21 SDK.

All of these examples can be found in this notebook.