Tools
Tools extend an agent’s capabilities beyond pure language understanding by enabling it to interact with external systems, retrieve data, and perform structured actions. Instead of relying solely on LLM output, tools allow agents to:
- Access APIs, databases, and search engines
- Analyze or transform structured and unstructured content
- Handle media formats like audio, video, and images
- Execute deterministic workflows or scripts
- Connect to enterprise systems like CRMs or file storage
By integrating tools, agents evolve from passive responders to active problem-solvers. This page explains the types of tools supported on aiXplain, how to add them to agents, and how to guide agents to use them effectively.
Using marketplace assets as tools
Any asset in the aiXplain marketplace can be added to an agent as a tool. Supported types include:
- AI models – LLMs, image models, speech models, etc.
- Utilities – APIs, crawlers, webhooks
- Pipelines – Multi-step workflows with deterministic execution
- Index – A searchable vector database for retrieval-based tasks.
from aixplain.factories import ModelFactory, AgentFactory
model = ModelFactory.get("679a80334d6aa81bfab338b3") # Grok 2
model_tool = AgentFactory.create_model_tool(
model=model,
description="Synthesizer model"
)
agent.tools.append(model_tool)
You can override the asset’s name
and description
in create_model_tool
to make it clearer for the agent.
Configuring tools
When added to an agent, a tool exposes the following assets attributes:
- name, description – visible to the agent during reasoning
- required parameters – visible and modifiable by the agent at runtime
- optional parameters – only visible if a default value is set, and read-only at runtime
# Load the asset (e.g., a search API utility)
search_utility = ModelFactory.get("6736411cf127849667606689") #Tavily Search API
# Inspect the parameters available in the model
model_params = search_utility.get_parameters()
print(model_params)
# Set optional parameters (only visible to the agent if a value is provided)
model_params.numResults = 7
model_params.include_domains = ["yelp.com"]
model_params.exclude_domains = ["google.com"]
print(model_params)
# Add the tool to your agent
agent.tools.append(AgentFactory.create_model_tool(model=search_utility.id))
Using pipelines as tools
Pipelines offer structured, deterministic behavior. Unlike LLMs, pipelines enforce fixed execution sequences.
from aixplain.factories import PipelineFactory, AgentFactory
pipeline = PipelineFactory.get("<pipeline_id>")
translation_tool = AgentFactory.create_pipeline_tool(
pipeline=pipeline,
description="Pipeline for multilingual translation"
)
agent.tools.append(translation_tool)
Using custom functions as tools
Custom tools are user-defined Python functions that run in a secure sandboxed environment, ensuring both security and isolation from the underlying system. They are ideal for implementing custom logic or integrating APIs that are not available in the marketplace.
# Custom function to get today's date
def get_today_date(format: str):
"""Returns today's date in the specified format.
Parameters:
----------
format : str
The date format string (e.g., '%Y-%m-%d', '%d/%m/%Y').
Returns:
-------"""
from datetime import datetime
return datetime.today().strftime(format)
# Import factories
from aixplain.factories import ModelFactory, AgentFactory
# Step 1: Create and deploy the utility model
utility = ModelFactory.create_utility_model(
name="Get Date",
description="Returns today's date based on the requested format.",
code=get_today_date
)
# Deploy the model to make it reusable
utility.deploy()
# Step 2: Create a new agent
agent = AgentFactory.create(
name="Date Finder Agent",
description="An agent that can retrieve today's date.",
instructions="Retrieve today's date using your tools in this format %Y-%m-%d.",
tools=[
# Step 3: Wrap the deployed utility as a tool, and add it to the agent
AgentFactory.create_model_tool(model=utility.id)
]
)
# Step 4: Query the agent
response = agent.run("What's the date today?")
response
Notes:
- All imports and installations must be inside the function body.
Example:import os
os.system("pip install googlemaps")
import googlemaps - A custom utility must define at least one parameter.
Agents treat both required and default parameters in a custom utility as required inputs when executing the function. - Size limits apply.
Utilities run in a sandboxed environment but can access the internet for tasks such as calling APIs or installing Python packages. - Define clear docstrings and type hints.
When onboarding a custom utility, include descriptive docstrings and proper type hints to help agents dynamically interpret and adjust input parameters. - Custom utilities are onboarded as private assets.
Once created, they appear in your dashboard and can be accessed at:
https://platform.aixplain.com/discover/utility/<utility.id>
The lifecycle of utility is: create() → run() → deploy() → save() → delete()
Using data assets as tools
Data assets allow agents to query both structured and unstructured data sources. For example, an agent can pull customer records from a structured CRM database or extract policy information from unstructured sources like PDFs, emails, or knowledge base articles.
By integrating data assets, agents can ground their responses in trusted knowledge, retrieve contextually relevant information, and help reduce hallucinations. This foundation is critical for building Agentic RAG systems—agents that reason, retrieve, and respond using verified, context-aware information.
Using indices as tools
Indices can be used to enable agents to search, match, or retrieve unstructured data (like text and images) during task execution. This is the foundation for building retrieval-augmented generation (RAG) systems, knowledge-based agents, and dynamic retrieval pipelines.
Agents can query an index to:
- Find relevant documents or records
- Ground their answers with external knowledge
- Perform similarity search over text embeddings (support for images and graphs coming soon)
aiXplain indices support multiple embedding types for different languages, data sizes, and modalities, starting with text embeddings and soon expanding to image and graph.
from aixplain.factories import IndexFactory, AgentFactory
# Get an index
index = IndexFactory.get("<index_id>")
# Wrap it as a tool
index_tool = AgentFactory.create_model_tool(
model=index,
description="University guidelines 2025"
)
# Add it to an agent
agent.tools.append(index_tool)
The agent can now use the index for retrieval tasks when answering user queries.
Using the SQL tool (alpha release)
Structured data can be queried directly using SQL or similar query languages, enabling agents to retrieve precise, filtered information from relational databases—ideal for accessing user records, inventory, transactions, or other well-defined entities.
create_sql_tool
creates a SQL tool for querying structured data sources such as SQLite, CSV, or PostgreSQL.
Parameter | Description |
---|---|
description | Description of the SQL tool, visible to the agent |
source | Path to the file or connection string (e.g., SQLite file, CSV file) |
source_type | One of csv , sqlite , or a supported DatabaseSourceType |
schema | (Optional) Schema description of the database |
tables | (Optional) List of table names to expose to the agent |
enable_commit | Allow agent to modify the database (e.g., INSERT , UPDATE ) (default: False ) |
Example: use an SQLite file
from aixplain.factories import AgentFactory
# Create an SQL tool with a CSV file
sql_tool = AgentFactory.create_sql_tool(
source="/content/customers.db",
source_type="sqlite",
enable_commit=True, # Allow modifications to the database
description="Database about customers."
)
# Add the tool to your agent
agent.tools.append(sql_tool)
response = agent.run("Create a table called Customers with the following columns: id, name, email, registration date") # Create table
response = agent.run("Insert the following data into the Customers table: 1, John, john@me.com, 2025-03-01") # Insert into table
response = agent.run("Tell me about John from the database") # Read from table
Example: use a CSV file
from aixplain.factories import AgentFactory
csv_tool = AgentFactory.create_sql_tool(
source="/content/customers.csv",
source_type="csv",
enable_commit=False,
description="Database about customers."
)
agent.tools.append(csv_tool)
response = agent.run("How many customers registered in the March 2025?")
response.data.output
In the alpha release, the SQL tool enables read and write access to the database. However, downloading the database is not yet supported—this functionality is coming soon.
Using the python code interpreter tool
The Python Code Interpreter Tool enables agents to dynamically execute Python code, making them useful for solving mathematical problems, running computations, handling errors, and even installing missing Python libraries when needed.
You can improve robustness by allowing the agent to fix errors and install missing libraries dynamically:
from aixplain.factories import AgentFactory
agent = AgentFactory.create(
name="Python Developer",
description="A Python developer agent.",
instructions="""A Python developer agent. If you encounter an error, try to fix it.
If a missing package is required, install it using os.system('pip install package_name').
Install the package in the same code cell where you use it.
""",
tools=[
AgentFactory.create_python_interpreter_tool()
]
)
response = agent.run("How is the friendship paradox explained on Wikipedia? Use the Wikipedia Python library.")
response
The code is executed in a sandboxed environment to ensure security and isolation from the underlying system.
How it worked:
- The agent first attempted to run Python code using the wikipedia library but failed because the package was not installed (
ModuleNotFoundError
). - Following its instructions, the agent automatically installed the missing wikipedia package using pip.
- After installation, it retried the original code and successfully retrieved the requested information about the friendship paradox from Wikipedia.
- The agent compiled the successful output and returned it to the user, while logging each step (failure, fix, retry, success) in the execution trace.
Summary:
The Python Code Interpreter Tool extends agent capabilities beyond static reasoning:
- Execute Python code dynamically.
- Solve mathematical, logical, and data-related tasks.
- Handle errors gracefully.
- Install missing Python packages automatically.
This allows your aiXplain agents to act not just as responders but also as problem-solvers and automation engines.
Best practices
Design distinct tool signatures
- Use action-based names like
summarize_text
,translate_email
- Provide helpful parameter names with example values
- Avoid overlapping responsibilities across tools
Give usage guidance in instructions
- Use
translate_text
when the user asks for translation - Use
extract_keywords
when identifying key topics in a document
Use few-shot examples
User: Translate this email to French
Tool: translate_text(text="Hello", target_language="fr")
User: What are the main topics in this report?
Tool: extract_keywords(text="Market trends...")