Skip to main content
Like this? Get an agent to make it.

How do you use the Agentica SDK?

Prerequisites:
  • Install agentica
  • Add your AGENTICA_API_KEY
There are two main ways to use the Agentica SDK. They are:
  • creating an agentic function
  • spawning an agent with the spawn function
See the references for more details.

What can you use the Agentica SDK for?

Below are a few examples that we believe highlight some of the best features of the Agentica SDK!

Grab and go

Install any prerequisites, copy and off you go.
Prerequisites:
  • Run pip install slack-sdk or uv add slack-sdk
  • Add your SLACK_BOT_TOKEN
Read these instructions to generate a SLACK_BOT_TOKEN !
Prerequisites:
  • Run pip install matplotlib pandas ipynb jupyter or uv add matplotlib pandas ipynb jupyter
  • Download the CSV and save as /movie_metadata.csv
  • Run jupyter notebook data_science.ipynb
data_science.ipynb
Prerequisites:
  • If on macOS, install system dependencies with brew install pkg-config cairo meson ninja
  • Run pip install exa-py validators markdown xhtml2pdf
  • Create an EXA account, create an EXA_SERVICE_API_KEY and run export EXA_SERVICE_API_KEY="<your-key-here>"
View the generated report

Walk-throughs

Prerequisites:
  • Run pip install slack-sdk or uv add slack-sdk
  • Add your SLACK_BOT_TOKEN
Python objects are tools. They are there to be manipulated and used. The Agentica Python SDK lets agents do just that, including using functions, classes and objects from any Python SDK.
As a simple example, let’s say you want to use the Slack client from the Slack SDK to send someone a message with some custom business logic inside it. Let’s start by creating a client.
Read these instructions to generate a SLACK_BOT_TOKEN !
Then isolate the relevant Slack methods.
And simply pass them to your agentic function using the @agentic decorator. Note that the prompt to the model is specified in the docstring and the method definition is empty.
For more information on what objects you can pass in via the @agentic decorator, see the references.If you prefer more agentic syntax, try the following:
Prerequisites:
  • Run pip install matplotlib pandas ipynb jupyter or uv add matplotlib pandas ipynb jupyter
  • Download the CSV and save as /movie_metadata.csv
Let’s take an example from the DSEval benchmark and use an agent in Agentica to answer questions on a dataset in a Jupyter notebook. Let’s start by importing a few things.
Now let’s get an agent to help us answer a question on the dataset and stream in its thinking.
Let’s print the result.
Now let’s make a plot with the returned data, since it has passed us back the appropriate object!
Movies by genreBut what if we want only the genres with over 1000 movies? Our agent still has access to our result in its execution environment and can manipulate that variable by reference!
Now we can remake the plot!
Top 5 movies by genreFor more information on what objects you can pass to spawn, see the references.
Prerequisites:
  • If on macOS, install system dependencies with brew install pkg-config cairo meson ninja
  • Run pip install exa-py validators markdown xhtml2pdf or uv add exa-py validators markdown xhtml2pdf
  • Create an EXA account, create an EXA_SERVICE_API_KEY and run export EXA_SERVICE_API_KEY="<your-key-here>"
Let’s replicate the Anthropic’s deep research multi-agent system. The high level architecture and the iterative process are outlined in the images below.Let’s start building.
We are depending on markdown, xhtml2pdf as external dependencies. Additionally, agentica.std.web exports web-search utilities based on Exa.
  • If you use web_search / web_fetch directly, you need EXA_API_KEY.
  • This demo creates ephemeral Exa keys per subagent, which requires EXA_SERVICE_API_KEY.
Let’s create a simple storage class that can save and load research artifacts.
We need to be able to save and read a plan as a .txt file in the storage directory. Likewise, we need to be bale to make a pdf out of the final markdown report.
The lead researcher should be able to create and run as many subagents as it deems necessary  to work on independent tasks (with web search).
Let’s add some bonus features:
  • the lead researcher should have the option to reuse a subagent with persistent context e.g. asking a subagent to redo a task that it got wrong
  • subagents should save the web search results that they use specifying what they have used for the citation agent to review
 The citation agent should be able to list and look back through web searches made by subagents as well as save the final report as an .md file.
Finally, let’s put it all together, making sure that
  • the citation agent is always called after the research report is generated by the lead researcher, and
  • the user has the opportunity to ask follow-up questions after receiving the research report.
Let’s go back and define the premise prompts for all the agents.
We can now run the session with a user query!
View the generated report