When building AI-powered software, prompting or chatting with an LLM directly will only take you so far. You'll want programmatic control over application logic and the flow of data. In other words, you'll want to run code.
Here are some examples:
Ensuring agents perform specific tasks consistently.
Providing access to a specific set of data to query.
Accessing other APIs, services, and tools.
Processing user inputs and query responses before passing to an LLM.
Defining how an LLM's outputs should be formatted and delivered.
Prescribing a series of tasks in a deterministic order.
Connecting multiple application components together.
What are structures?
Griptape structures are Python script micro-applications that use the griptape framework to bring LLMs into your software environment. You can create structures in the form of agents, sequential task pipelines, and parallelized workflows.
Typically, developers can easily write and debug their software locally. However, they would then need to find someplace else to host it for testing and production. With Griptape structures, you can start on your laptop, and then deploy them directly to Griptape Cloud to run them at scale.
How to create a structure
Griptape samples are a quick and easy way to get started with structures. Several samples are available on GitHub for you to try. Of course, you can also write your own custom structure or follow a Griptape Trade School course to build a simple rules-driven chatbot.
Prerequisites:
For this example, you'll be able to compare outputs from OpenAI (GPT), Google (Gemini), or Anthropic (Claude) given the same input. You'll need API keys from at least one of those services to proceed.
You will also need a Griptape Cloud API key. Follow these steps to create one.
Navigate to the API Keys screen.
Click
Create API key
.Enter the name
GT_CLOUD_API_KEY
.Click
Create
to submit the form.Copy the key value. Save it somewhere so that you can paste it later.
Click
I have saved the key
.
Follow these steps to create, deploy, and run a structure. You can follow similar steps to deploy another sample or your own custom structure.
Navigate to the Structures screen.
Click
Create structure
.Select a structure. For this example, choose
OpenAI vs. Google vs. Anthropic Model Comparison
.(Optional) Give the structure a name and description.
In the row labeled
Key: GT_CLOUD_API_KEY
, click the pencil (edit) icon.Select
Create secret
in the dropdown menu, then paste in your Griptape Cloud API keyClick
Save
to store the key as a secret that will be encrypted and used in this structure. For future structures, you will be able to re-use the same key by selectingSecret reference
.Repeat the preceding three steps (5 , 6, and 7) for the row labeled
Key: OPENAI_API_KEY
,Key: ANTHROPIC_API_KEY
, and/orKey: GOOGLE_API_KEY
using the corresponding API keys. You only need to provide one of these unless you want to compare models against each other.Click
Create
to submit the form.
What's Happening?
Once you have created the structure, it will automatically begin deploying to Griptape Cloud. This process should take just a minute or two. While deployment is in progress, you will be directed to the structure detail page where you can observe the deployment status as well as other details such as the GitHub repository and invocation URL.
After deployment is complete, your structure is ready to run!
How to use structures
You can run structures directly from the Griptape Cloud web console, via API, or through third party software applications. For this example, we will use the sample that you deployed above.
Follow these steps to run your structure.
Navigate to the Structures screen.
Select the structure you created from the list.
Click the
Runs
tab.Click
Create run
.In the
Arguments
field, enter the following text. If you want to use a different model, replace the argumentopenai
withanthropic
orclaude
.-p
openai
-s
software programming
-a
Genghis KhanClick
Create
to submit the form.
The structure will then begin running. It should take just a few seconds. During this time, you will see the input arguments and environment variables you provided. When the run completes you will see the resulting output, and you can also access the run logs for debugging purposes.