Official Tools#
Overview#
Gen AI Builder provides a set of official Tools for common tasks. In general, Gen AI Builder-included Tools are designed to be general-purpose and Driver-based for easy integration with different backends.
Tools#
Audio Transcription#
This Tool enables Agents to transcribe speech from text using Audio Transcription Drivers .
from griptape.drivers.audio_transcription.openai import OpenAiAudioTranscriptionDriver
from griptape.structures import Agent
from griptape.tools.audio_transcription.tool import AudioTranscriptionTool
driver = OpenAiAudioTranscriptionDriver(model="whisper-1")
tool = AudioTranscriptionTool(
off_prompt=False,
audio_transcription_driver=driver,
)
Agent(tools=[tool]).run(
"Transcribe the following audio file: /Users/andrew/code/griptape/tests/resources/sentences2.wav"
)
Calculator#
This tool enables LLMs to make simple calculations.
from griptape.structures import Agent
from griptape.tools import CalculatorTool
# Create an agent with the CalculatorTool tool
agent = Agent(tools=[CalculatorTool()])
# Run the agent with a task to perform the arithmetic calculation of \(10^5\)
agent.run("What is 10 raised to the power of 5?")
Computer#
This tool enables LLMs to execute Python code and run shell commands inside a Docker container. You have to have the Docker daemon running in order for this tool to work.
You can specify a local working directory and environment variables during tool initialization:
from griptape.structures import Agent
from griptape.tools import ComputerTool
# Initialize the ComputerTool tool
computer = ComputerTool()
# Create an agent with the ComputerTool tool
agent = Agent(tools=[computer])
agent.run("Make 2 files and then list the files in the current directory")
Date Time#
This tool enables LLMs to get current date and time.
from griptape.structures import Agent
from griptape.tools import DateTimeTool
agent = Agent(tools=[DateTimeTool()])
agent.run("What day is 5 days past christmas in 2026?")
Email#
The EmailTool enables LLMs to send emails.
import os
from griptape.tools import EmailTool
email_tool = EmailTool(
smtp_host=os.environ.get("SMTP_HOST"),
smtp_port=int(os.environ.get("SMTP_PORT", "465")),
smtp_password=os.environ.get("SMTP_PASSWORD"),
smtp_user=os.environ.get("FROM_EMAIL"),
smtp_use_ssl=bool(os.environ.get("SMTP_USE_SSL")),
)
For debugging purposes, you can run a local SMTP server that the LLM can send emails to:
python -m smtpd -c DebuggingServer -n localhost:1025
Extraction#
The ExractionTool enables LLMs to extract structured text from unstructured data.
import schema
from griptape.engines import JsonExtractionEngine
from griptape.structures import Agent
from griptape.tools import ExtractionTool, WebScraperTool
agent = Agent(
input="Load {{ args[0] }} and extract key info",
tools=[
WebScraperTool(off_prompt=True),
ExtractionTool(
off_prompt=False,
extraction_engine=JsonExtractionEngine(
template_schema=schema.Schema(
{
"company_name": str,
"industry": str,
schema.Literal(
"product_features",
description="List of key product features.",
): list[str],
}
).json_schema("Company Info"),
),
),
],
)
agent.run("https://griptape.ai")
File Manager#
This tool enables LLMs to save and load files.
from pathlib import Path
from griptape.structures import Agent
from griptape.tools import FileManagerTool
# Initialize the FileManagerTool tool with the current directory as its base
file_manager_tool = FileManagerTool()
# Add the tool to the Agent
agent = Agent(tools=[file_manager_tool])
# Directly create a file named sample1.txt with some content
filename = "sample1.txt"
content = "This is the content of sample1.txt"
Path(filename).write_text(content)
# Now, read content from the file sample1.txt using the agents command
agent.run("Can you get me the sample1.txt file?")
`
Gen AI Builder Tool#
The GriptapeCloudToolTool integrates with Gen AI Builder’s hosted Tools.
Note: This tool requires a Tool hosted in Gen AI Builder and an API Key for access.
import os
from griptape.structures import Agent
from griptape.tools.griptape_cloud_tool.tool import GriptapeCloudToolTool
agent = Agent(
tools=[
GriptapeCloudToolTool( # Tool is configured as a random number generator
tool_id=os.environ["GT_CLOUD_TOOL_ID"],
)
]
)
agent.run("Generate a number between 1 and 10")
Image Query#
This tool allows Agents to execute natural language queries on the contents of images using multimodal models.
from griptape.drivers.prompt.openai import OpenAiChatPromptDriver
from griptape.structures import Agent
from griptape.tools import ImageQueryTool
driver = OpenAiChatPromptDriver(model="gpt-4.1")
# Create an Image Query Tool configured to use the engine.
tool = ImageQueryTool(
prompt_driver=driver,
)
# Create an agent and provide the tool to it.
Agent(tools=[tool]).run("Describe the weather in the image tests/resources/mountain.png in one word.")
Inpainting Image Generation#
This tool allows LLMs to generate images using inpainting, where an input image is altered within the area specified by a mask image according to a prompt. The input and mask images can be provided either by their file path or by their Task Memory and Off Prompt references.
from griptape.drivers.image_generation.amazon_bedrock import AmazonBedrockImageGenerationDriver
from griptape.drivers.image_generation_model.bedrock_stable_diffusion import (
BedrockStableDiffusionImageGenerationModelDriver,
)
from griptape.structures import Agent
from griptape.tools import InpaintingImageGenerationTool
# Create a driver configured to use Stable Diffusion via Bedrock.
driver = AmazonBedrockImageGenerationDriver(
image_generation_model_driver=BedrockStableDiffusionImageGenerationModelDriver(),
model="stability.stable-diffusion-xl-v1",
)
# Create a tool configured to use the engine.
tool = InpaintingImageGenerationTool(
image_generation_driver=driver,
)
# Create an agent and provide the tool to it.
Agent(tools=[tool]).run(
"Generate an image of a castle built into the side of a mountain by inpainting the "
"image at tests/resources/mountain.png using the mask at tests/resources/mountain-mask.png."
)
Outpainting Image Generation#
This tool allows LLMs to generate images using outpainting, where an input image is altered outside of the area specified by a mask image according to a prompt. The input and mask images can be provided either by their file path or by their Task Memory and Off Prompt references.
from griptape.drivers.image_generation.amazon_bedrock import AmazonBedrockImageGenerationDriver
from griptape.drivers.image_generation_model.bedrock_stable_diffusion import (
BedrockStableDiffusionImageGenerationModelDriver,
)
from griptape.structures import Agent
from griptape.tools import OutpaintingImageGenerationTool
# Create a driver configured to use Stable Diffusion via Bedrock.
driver = AmazonBedrockImageGenerationDriver(
image_generation_model_driver=BedrockStableDiffusionImageGenerationModelDriver(),
model="stability.stable-diffusion-xl-v1",
)
# Create a tool configured to use the engine.
tool = OutpaintingImageGenerationTool(
image_generation_driver=driver,
)
# Create an agent and provide the tool to it.
Agent(tools=[tool]).run(
"Generate an image of a mountain shrouded by clouds by outpainting the "
"image at tests/resources/mountain.png using the mask at tests/resources/mountain-mask.png."
)
Prompt Image Generation#
This tool allows LLMs to generate images from a text prompt.
from griptape.drivers.image_generation.amazon_bedrock import AmazonBedrockImageGenerationDriver
from griptape.drivers.image_generation_model.bedrock_stable_diffusion import (
BedrockStableDiffusionImageGenerationModelDriver,
)
from griptape.structures import Agent
from griptape.tools import PromptImageGenerationTool
# Create a driver configured to use Stable Diffusion via Bedrock.
driver = AmazonBedrockImageGenerationDriver(
image_generation_model_driver=BedrockStableDiffusionImageGenerationModelDriver(),
model="stability.stable-diffusion-xl-v1",
)
# Create a tool configured to use the engine.
tool = PromptImageGenerationTool(
image_generation_driver=driver,
)
# Create an agent and provide the tool to it.
Agent(tools=[tool]).run("Generate an image of a mountain on a summer day.")
Prompt Summary#
The PromptSummaryTool enables LLMs summarize text data.
from griptape.structures import Agent
from griptape.tools import PromptSummaryTool, WebScraperTool
agent = Agent(tools=[WebScraperTool(off_prompt=True), PromptSummaryTool()])
agent.run(
"How can I build Neovim from source for MacOS according to this https://github.com/neovim/neovim/blob/master/BUILD.md"
)
`
Rag#
The RagTool enables LLMs to query modular RAG engines.
Here is an example of how it can be used with a local vector store driver:
from griptape.artifacts import TextArtifact
from griptape.drivers.embedding.openai import OpenAiEmbeddingDriver
from griptape.drivers.prompt.openai import OpenAiChatPromptDriver
from griptape.drivers.vector.local import LocalVectorStoreDriver
from griptape.engines.rag import RagEngine
from griptape.engines.rag.modules import PromptResponseRagModule, VectorStoreRetrievalRagModule
from griptape.engines.rag.stages import ResponseRagStage, RetrievalRagStage
from griptape.structures import Agent
from griptape.tools import RagTool
vector_store_driver = LocalVectorStoreDriver(embedding_driver=OpenAiEmbeddingDriver())
artifact = TextArtifact(
"Griptape builds AI-powered applications that connect securely to your enterprise data and APIs."
"Griptape Agents provide incredible power and flexibility when working with large language models."
)
vector_store_driver.upsert(artifact, namespace="griptape")
rag_tool = RagTool(
description="Contains information about Griptape",
off_prompt=False,
rag_engine=RagEngine(
retrieval_stage=RetrievalRagStage(
retrieval_modules=[
VectorStoreRetrievalRagModule(
vector_store_driver=vector_store_driver, query_params={"namespace": "griptape", "top_n": 20}
)
]
),
response_stage=ResponseRagStage(
response_modules=[PromptResponseRagModule(prompt_driver=OpenAiChatPromptDriver(model="gpt-4.1"))]
),
),
)
agent = Agent(tools=[rag_tool])
agent.run("what is Griptape?")
Query#
The ImageQueryTool enables Agents to query unstructured data for specific information.
from griptape.structures import Agent
from griptape.tools import QueryTool, WebScraperTool
agent = Agent(tools=[WebScraperTool(off_prompt=True), QueryTool()])
agent.run("Tell me about the architecture as described here: https://neovim.io/doc/user/vim_diff.html")
Rest Api#
This tool enables LLMs to call REST APIs.
The RestApiTool tool uses the following parameters:
The following example is built using https://jsonplaceholder.typicode.com/guide/.
My First Post, A Journey.,#
This tool enables LLMs to execute SQL statements via SQLAlchemy .
Depending on your underlying SQL engine, configure your
engine_url and give the LLM a hint about what engine you are using
via engine_name , so that it can create engine-specific statements.
import os
import boto3
from griptape.drivers.sql.amazon_redshift import AmazonRedshiftSqlDriver
from griptape.loaders import SqlLoader
from griptape.structures import Agent
from griptape.tools import SqlTool
session = boto3.Session()
sql_loader = SqlLoader(
sql_driver=AmazonRedshiftSqlDriver(
database=os.environ["REDSHIFT_DATABASE"],
session=session,
cluster_identifier=os.environ["REDSHIFT_CLUSTER_IDENTIFIER"],
)
)
sql_tool = SqlTool(
sql_loader=sql_loader,
table_name="people",
table_description="contains information about tech industry professionals",
engine_name="redshift",
)
agent = Agent(tools=[sql_tool])
agent.run("SELECT * FROM people;")
The StructureRunTool Tool provides a way to run Structures via a Tool. It requires you to provide a Structure Run Drivers to run the Structure in the desired environment.
import os
from griptape.drivers.structure_run.griptape_cloud import GriptapeCloudStructureRunDriver
from griptape.structures import Agent
from griptape.tools import StructureRunTool
base_url = os.environ["GT_CLOUD_BASE_URL"]
api_key = os.environ["GT_CLOUD_API_KEY"]
structure_id = os.environ["GT_CLOUD_STRUCTURE_ID"]
structure_run_tool = StructureRunTool(
description="RAG Expert Agent - Structure to invoke with natural language queries about the topic of Retrieval Augmented Generation",
structure_run_driver=GriptapeCloudStructureRunDriver(
base_url=base_url,
api_key=api_key,
structure_id=structure_id,
),
)
# Set up an agent using the StructureRunTool tool
agent = Agent(tools=[structure_run_tool])
# Task: Ask the Griptape Cloud Hosted Structure about modular RAG
agent.run("what is modular RAG?")
This Tool enables LLMs to synthesize speech from text using Text to Speech Drivers .
import os
from griptape.drivers.text_to_speech.elevenlabs import ElevenLabsTextToSpeechDriver
from griptape.structures import Agent
from griptape.tools.text_to_speech.tool import TextToSpeechTool
driver = ElevenLabsTextToSpeechDriver(
api_key=os.environ["ELEVEN_LABS_API_KEY"],
model="eleven_multilingual_v2",
voice="Matilda",
)
tool = TextToSpeechTool(
text_to_speech_driver=driver,
)
Agent(tools=[tool]).run("Generate audio from this text: Hello, world!")
This Tool allows LLMs to generate variations of an input image from a text prompt. The input image can be provided either by its file path or by its Task Memory and Off Prompt reference.
from griptape.drivers.image_generation.amazon_bedrock import AmazonBedrockImageGenerationDriver
from griptape.drivers.image_generation_model.bedrock_stable_diffusion import (
BedrockStableDiffusionImageGenerationModelDriver,
)
from griptape.structures import Agent
from griptape.tools import VariationImageGenerationTool
# Create a driver configured to use Stable Diffusion via Bedrock.
driver = AmazonBedrockImageGenerationDriver(
image_generation_model_driver=BedrockStableDiffusionImageGenerationModelDriver(
style_preset="pixel-art",
),
model="stability.stable-diffusion-xl-v1",
)
# Create a tool configured to use the engine.
tool = VariationImageGenerationTool(
image_generation_driver=driver,
)
# Create an agent and provide the tool to it.
Agent(tools=[tool]).run(
"Generate a variation of the image located at tests/resources/mountain.png depicting a mountain on a winter day"
)
from griptape.drivers.image_generation.amazon_bedrock import AmazonBedrockImageGenerationDriver
from griptape.drivers.image_generation_model.bedrock_stable_diffusion import (
BedrockStableDiffusionImageGenerationModelDriver,
)
from griptape.structures import Agent
from griptape.tools import FileManagerTool, PromptImageGenerationTool, VariationImageGenerationTool
# Create a driver configured to use Stable Diffusion via Bedrock.
driver = AmazonBedrockImageGenerationDriver(
image_generation_model_driver=BedrockStableDiffusionImageGenerationModelDriver(
style_preset="pixel-art",
),
model="stability.stable-diffusion-xl-v1",
)
# Create a prompt image generation client configured to use the driver.
prompt_tool = PromptImageGenerationTool(image_generation_driver=driver, off_prompt=True)
# Create a variation image generation client configured to use the driver.
variation_tool = VariationImageGenerationTool(
image_generation_driver=driver,
off_prompt=True,
)
file_tool = FileManagerTool()
# Create an agent and provide the tools to it.
agent = Agent(tools=[prompt_tool, variation_tool, file_tool])
# Run the agent using a prompt motivating it to generate an image, then
# create a variation of the image present in task memory.
agent.run(
"Generate an image of a mountain on a summer day. Then, generate a "
"variation of this image depicting the same mountain scene on a winter day."
"Save them images to disk and return the file paths. "
)
The VectorStoreTool enables LLMs to query vector stores.
Here is an example of how it can be used with a local vector store driver:
from griptape.chunkers import TextChunker
from griptape.drivers.embedding.openai import OpenAiEmbeddingDriver
from griptape.drivers.vector.local import LocalVectorStoreDriver
from griptape.loaders import WebLoader
from griptape.structures import Agent
from griptape.tools import VectorStoreTool
NAMESPACE = "griptape"
vector_store_driver = LocalVectorStoreDriver(
embedding_driver=OpenAiEmbeddingDriver(),
)
artifacts = WebLoader().load("https://www.griptape.ai")
chunks = TextChunker().chunk(artifacts)
vector_store_driver.upsert_collection({NAMESPACE: chunks})
vector_db = VectorStoreTool(
description="This DB has information about the Griptape Python framework",
vector_store_driver=vector_store_driver,
query_params={"namespace": NAMESPACE},
)
agent = Agent(tools=[vector_db])
agent.run("what is Griptape?")
This tool enables LLMs to scrape web pages for full text, summaries,
authors, titles, and keywords. It can also execute search queries to
answer specific questions about the page. This tool uses OpenAI APIs for
some of its activities, so in order to use it provide a valid API key in
openai_api_key .
from griptape.structures import Agent
from griptape.tools import PromptSummaryTool, WebScraperTool
agent = Agent(tools=[WebScraperTool(off_prompt=True), PromptSummaryTool(off_prompt=False)])
agent.run("Based on https://www.griptape.ai/, tell me what griptape is")
This tool enables LLMs to search the web.
import os
from griptape.drivers.web_search.google import GoogleWebSearchDriver
from griptape.structures import Agent
from griptape.tools import WebSearchTool
# Initialize the WebSearchTool tool with necessary parameters
web_search_tool = WebSearchTool(
web_search_driver=GoogleWebSearchDriver(
api_key=os.environ["GOOGLE_API_KEY"],
search_id=os.environ["GOOGLE_API_SEARCH_ID"],
results_count=5,
language="en",
country="us",
),
)
# Set up an agent using the WebSearchTool tool
agent = Agent(tools=[web_search_tool])
# Task: Search the web for a specific query
agent.run("Tell me how photosynthesis works")
Extra schema properties can be added to the Tool to allow for more
customization if the Driver supports it. In this example, we add a
sort property to the search Activity which will be added as a
Google custom search query parameter .
import os
import schema
from griptape.drivers.web_search.google import GoogleWebSearchDriver
from griptape.structures import Agent
from griptape.tools import WebSearchTool
agent = Agent(
tools=[
WebSearchTool(
web_search_driver=GoogleWebSearchDriver(
api_key=os.environ["GOOGLE_API_KEY"],
search_id=os.environ["GOOGLE_API_SEARCH_ID"],
),
extra_schema_properties={
"search": {
schema.Literal(
"sort",
description="Date range to search within. Format: date:r:YYYYMMDD:YYYYMMDD",
): str
}
},
)
],
)
agent.run("Search for articles about the history of the internet from 1990 to 2000")