Skip to main content
All CollectionsGriptape Cloud
Get Started with Structures
Get Started with Structures

Learn about Griptape structures and how to use them

D
Written by Derek Pai
Updated over 2 weeks ago

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.

  1. Navigate to the API Keys screen.

  2. Click Create API key.

  3. Enter the name GT_CLOUD_API_KEY.

  4. Click Create to submit the form.

  5. Copy the key value. Save it somewhere so that you can paste it later.

  6. 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.

  1. Navigate to the Structures screen.

  2. Click Create structure.

  3. Select a structure. For this example, choose OpenAI vs. Google vs. Anthropic Model Comparison.

  4. (Optional) Give the structure a name and description.

  5. In the row labeled Key: GT_CLOUD_API_KEY, click the pencil (edit) icon.

  6. Select Create secret in the dropdown menu, then paste in your Griptape Cloud API key

  7. Click 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 selecting Secret reference.

  8. Repeat the preceding three steps (5 , 6, and 7) for the row labeled Key: OPENAI_API_KEY, Key: ANTHROPIC_API_KEY, and/or Key: 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.

  9. 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.

  1. Navigate to the Structures screen.

  2. Select the structure you created from the list.

  3. Click the Runs tab.

  4. Click Create run.

  5. In the Arguments field, enter the following text. If you want to use a different model, replace the argument openai with anthropic or claude.

    -p
    openai
    -s
    software programming
    -a
    Genghis Khan

  6. Click 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.

Did this answer your question?