Build Agents
Learn how to build agents with Clarifai
Clarifai provides a streamlined developer experience that allows you to quickly prototype, build, and deploy agentic AI applications.
We provide an OpenAI-compatible API endpoint, which allows you to seamlessly integrate with popular agent development toolkits that support the OpenAI's API standard. This empowers you to create powerful, flexible, and tool-using AI agents with minimal configuration.
Let’s illustrate how you can build agents with the various toolkits we support.
LiteLLM is a library that offers a unified API for working with various LLM providers. When using an agent toolkit that supports LiteLLM to access Clarifai's models, specify the model using the openai/
prefix followed by the Clarifai model URL — for example:
openai/deepseek-ai/deepseek-chat/models/DeepSeek-R1-Distill-Qwen-7B
.
Install the latest version of the Clarifai Python SDK package by running pip install --upgrade clarifai
. Also, go to the Security section in your personal settings page and generate a Personal Access Token (PAT) to authenticate with the Clarifai platform.
OpenAI
You can use the OpenAI Agents SDK to build agentic AI apps that make use of Clarifai models.
Installation
The following command will install the openai-agents
package and the optional litellm
dependency group.
- Bash
pip install "openai-agents[litellm]"
After the installation, you can use the LitellmModel class in the OpenAI Agents SDK to access Clarifai models via LiteLLM.
Build an Agent
When building an agent with the OpenAI Agents SDK, the most common properties you'll configure are:
instructions
— Also known as the system prompt or developer message, this defines the agent’s behavior and tone.model
— Specifies which LLM to use. In this case, it points to a Clarifai-hosted model.tools
— Define the actions your agent can take, such as calling APIs or fetching data. These can be implemented as regular Python functions.
You'll also need the Runner
class to run your agent.