Connect to the Anthropic (Claude) API in Airtable

Sep 5, 2024Zayyad Muhammad Sani

In this tutorial, you'll learn how to connect to Anthropic's API in Airtable with no code. You'll use Anthropic's generative AI, Claude, to generate social media captions for products in an Airtable base.

The Airtable Claude integration can be used for free, and there's no need for code.

Set up a Products Table

To get started, we'll create and configure the products table.

1. Create a new table called "Products".

2. Add the product names under the "Name" field. You can use these fictional kitchen products if you want:

  • CrispMaster Air Fryer
  • ZenBrew Coffee Maker
  • AquaPure Water Filter

3. Rename the default "Notes" field to "Description".

name-and-description-anthropic.png

4. Create a new Grid view called Needs description with the following filters:

  • Name - is not empty
  • Description - is empty
needs-description-anthropic.png

We've set up the table this way so that the product captions we'll generate later using the Airtable Claude integration move records out of this view. Let's get started with Anthropic.

Generate an Anthropic (Claude) API key

We'll need an Anthropic API key before we can connect to their API in Airtable. Follow these steps to generate your API key:

1. Sign up for an Anthropic developer account.

2. Get $5 free credit for using the API by verifying your phone number or adding billing details.

3. Click "Get API keys" to open the API Keys screen, then click "Create Key".

anthropic-get-api-keys.png

anthropic-create-key.png

4. Name your API key, select a workspace, then click "Create Key".

anthropic-name-and-create-key.png

5. Copy the key and paste it somewhere safe.

anthropic-key-created.png

Next, we'll add Data Fetcher to our Airtable base and access the Anthropic API.

Install Airtable Claude integration

1. Add the Data Fetcher extension to your Airtable base.

2. Sign in to Data Fetcher or sign up if you don’t have an account.

sign up for data fetcher.png

3. Once you're logged in to Data Fetcher, click Create your first request.

create your first request logo 2 smaller.png

Connect to the Anthropic (Claude) API in Airtable

Follow these steps to customize the request you'll make to Anthropic's API:

1. Select Anthropic under Application.

select-anthropic.png

2. Rename the request to "Generate product captions".

rename-request-anthropic.png

3. Copy and paste your Anthropic API key under Authorization

paste-anthropic-key.png

4. Under Endpoint, select "Create a message" to use the Airtable Claude integration.

select-create-message-anthropic.png

5. Click Save and Continue in the bottom right corner to proceed to the next section.

6. Select Claude 3.5 Sonnet under Model.

select-claude-sonnet-anthropic.png

Next, we'll give Claude the instructions for generating social media captions.

Sending Messages to the Claude API

1. Copy and paste the following text under Messages:

"Generate an Instagram caption for "

first-part-of-message-anthropic-product-description.png

We'll complete the phrase above by referencing the products in the table.

2. Click the + button next to Messages

add-field-reference-anthropic-product-description.png

3. In the dialog that opens, select Name under Field and Needs description under Run for every record in view.

insert-reference-anthropic-product-description.png

4. Click Confirm to save, and the dialog will close.

You should now see the "Name" field referenced in the message.

product-name-referenced-anthropic.png

5. Copy and paste the following instructions under Messages to complete the message.

Use a playful and quirky brand voice. Caption should be engaging and include a call-to-action. Max length: 200 characters. Return just the caption, no extra text.
full-message-anthropic-product-description.png

TIP: Adding extra details to your messages will enable Claude to generate more accurate content for your use case.

With the request set up, we'll import the response data from Claude API into our table.

6. Click Save and Run to proceed to the next section.

Map the Product Captions to the Table

After the Airtable Claude integration runs, the Response Field Mapping screen will open. On this screen, you can configure and import fields from the response data into your table.

response-field-mapping-anthropic-product-description.png

This response contains one field, "Message", which we'll map to the "Description" field in the table.

1. Click Existing field under Message, then select "Description".

map-description-anthropic-product-description.png

2. Click Save and Run.

Go back to your default grid view and see the fun captions Claude generated.

captions-generated-anthropic.png

Run Anthropic (Claude) API Requests Automatically

If you frequently add products to your Airtable base, you'll want to use Data Fetcher's Triggers feature to run the request automatically and generate captions.

Triggers are a premium feature, so we'll show you how to upgrade your plan and set up a trigger with the following steps:

1. Open the request in Data Fetcher, scroll down to the Schedule / Trigger / Webhook URL tabs, then select Upgrade under Trigger.

schedule trigger webhook url tabs.png

2. Select a paid plan that suits you, then follow the instructions to make payment.

3. Click + Authorize to give Data Fetcher access to your Airtable base.

trigger tab authorize.png

4. Click I understand, let's Authorize in the warning dialog that pops up.

I understand. Let-s authorize.png

A new window will pop up, asking which bases or workspaces you want Data Fetcher to access.

5. Click Add a base, then select All current and future bases in all current and future workspaces so you won’t have to authorize Data Fetcher anytime you want to use it in another Airtable base.

schedule-authorize-bases.jpg

6. Click Grant Access.

We can now add the trigger:

1. Select Record created.

trigger tab record created.png

2. Select "Products" under Table and "Needs description" under View.

add-trigger-anthropic-product-description.png

3. Click Save at the bottom of the screen.

Add new products to the table and watch Data Fetcher automatically run the request.

Here's a quick summary of how to connect to the Claude API in Airtable:

  • Set up the table you'll use to store AI-generated content.
  • Get an Anthropic API key.
  • Install Data Fetcher.
  • Create an Anthropic (Claude) request in Data Fetcher.
  • Add messages containing instructions for the Claude API and configure other options to customize the request.
  • Run the request and import the message into your table.

That wraps up this tutorial. Check out our blog to see other ways you can use AI in Airtable with Data Fetcher.

Other Recent Posts

How to Import Data into Airtable Without Duplicates

How to Import Data into Airtable Without Duplicates

Oct 7, 2024

Zayyad Muhammad Sani

Custom RequestsData Fetcher
How to Connect to an OAuth 1.0 API in Airtable

How to Connect to an OAuth 1.0 API in Airtable

Sep 20, 2024

Zayyad Muhammad Sani

Custom Requests