JackaL
友一人
- Joined
- Sep 3, 2026
- Messages
- 341
- Reaction score
- 61
[DEVELOPMENT] Connecting Claude 3.5 API to Google Sheets via Apps Script
You don't need expensive Zapier subscriptions to automate data processing. You can write a custom Google Apps Script to send row data directly to Anthropic's Claude 3.5 API and write the response back into your spreadsheet.
The Apps Script Implementation:
In Google Sheets, go to Extensions > Apps Script and paste this code:
You don't need expensive Zapier subscriptions to automate data processing. You can write a custom Google Apps Script to send row data directly to Anthropic's Claude 3.5 API and write the response back into your spreadsheet.
The Apps Script Implementation:
In Google Sheets, go to Extensions > Apps Script and paste this code:
JavaScript:
function callClaudeAPI(promptText) {
var apiKey = "YOUR_ANTHROPIC_API_KEY";
var url = "https://api.anthropic.com/v1/messages";
var payload = {
"model": "claude-3-5-sonnet-20240620",
"max_tokens": 500,
"messages": [{"role": "user", "content": promptText}]
};
var options = {
"method": "post",
"headers": {
"x-api-key": apiKey,
"anthropic-version": "2023-06-01",
"content-type": "application/json"
},
"payload": JSON.stringify(payload)
};
var response = UrlFetchApp.fetch(url, options);
var json = JSON.parse(response.getContentText());
return json.content[0].text;
}
Usage: You can now type=callClaudeAPI(A2)in any cell to automatically process the text in cell A2.