Skip to main content

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
from aixplain.factories import AgentFactory

model_tool = AgentFactory.create_model_tool(
model="679a80334d6aa81bfab338b3", # Grok 2
description="Summarization model"
)
agent.tools.append(model_tool)

You can override the asset’s name and description in the tool definition to make it clearer for the agent.

Browse the marketplace →


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))
agent.save()

Using pipelines as tools

Pipelines offer structured, deterministic behavior. Unlike LLMs, pipelines enforce fixed execution sequences.

translation_tool = AgentFactory.create_pipeline_tool(
pipeline="translation_pipeline_id",
description="Pipeline for multilingual translation"
)
agent.tools.append(translation_tool)

Learn more about pipelines →


Using custom functions as tools

Custom tools are user-defined Python functions that run in a secure sandbox. These are ideal for logic-heavy tasks not available in the marketplace.

def get_today_date(format: str):
from datetime import datetime
return datetime.today().strftime(format)

tool = AgentFactory.create_custom_python_code_tool(
code=get_today_date,
description="Returns today's date"
)
agent.tools.append(tool)

Deploying custom tools

You can deploy a custom function as a private utility asset to reuse it across agents.

from aixplain.factories import ModelFactory

utility = ModelFactory.create_utility_model(
name="Get date",
description="Returns today's date",
code=get_today_date
)
agent.tools.append(AgentFactory.create_model_tool(model=utility.id))

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 the index tool

Vector indices and tabular data can be used to enable agents to search, match, or retrieve structured knowledge.

index_tool = AgentFactory.create_model_tool(
model="index_asset_id",
description="Vector database for semantic search"
)
agent.tools.append(index_tool)

Learn more about indexing →

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.

ParameterDescription
descriptionDescription of the SQL tool, visible to the agent
sourcePath to the file or connection string (e.g., SQLite file, CSV file)
source_typeOne 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_commitAllow 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)
agent.save()

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)
agent.save()

response = agent.run("How many customers registered in the March 2025?")
response.data.output
note

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

This built-in tool lets agents execute code for tasks like math, logic, or error analysis.

interpreter = AgentFactory.create_python_interpreter_tool()
agent.tools.append(interpreter)

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...")