The Claude for Sheets extension integrates Claude into Google Sheets, allowing you to execute interactions with Claude directly in cells.
Get your Anthropic API key
Install the Claude for Sheets extension
Install
btton and accept the permissions.Permissions
Connect your API key
Extensions
> Claude for Sheets™
> Open sidebar
> ☰
> Settings
> API provider
. You may need to wait or refresh for the Claude for Sheets menu to appear.
CLAUDE()
.
Simple prompt
=CLAUDE("Claude, in one sentence, what's good about the color blue?")
Claude should respond with an answer. You will know the prompt is processing because the cell will say Loading...
Adding parameters
=CLAUDE(prompt, model, params...)
.
model
is always second in the list.=CLAUDE("Hi, Claude!", "claude-3-haiku-20240307", "max_tokens", 3)
Any API parameter can be set this way. You can even pass in an API key to be used just for this specific cell, like this: "api_key", "sk-ant-api03-j1W..."
CLAUDEMESSAGES
is a function that allows you to specifically use the Messages API. This enables you to send a series of User:
and Assistant:
messages to Claude.
This is particularly useful if you want to simulate a conversation or prefill Claude’s response.
Try writing this in a cell:
User:
or Assistant:
) must be preceded by a single newline. To enter newlines in a cell, use the following key combinations:Example multiturn CLAUDEMESSAGES() call with system prompt
Argument | Description |
---|---|
max_tokens | The total number of tokens the model outputs before it is forced to stop. For yes/no or multiple choice answers, you may want the value to be 1-3. |
temperature | the amount of randomness injected into results. For multiple-choice or analytical tasks, you’ll want it close to 0. For idea generation, you’ll want it set to 1. |
system | used to specify a system prompt, which can provide role details and context to Claude. |
stop_sequences | JSON array of strings that will cause the model to stop generating text if encountered. Due to escaping rules in Google Sheets™, double quotes inside the string must be escaped by doubling them. |
api_key | Used to specify a particular API key with which to call Claude. |
Example: Setting parameters
system
prompt, max_tokens
, and temperature
:temperature
, max_tokens
, and stop_sequences
:api_key
:NAME? Error: Unknown function: 'claude'
#ERROR!, ⚠ DEFERRED ⚠ or ⚠ THROTTLED ⚠
#ERROR!
, ⚠ DEFERRED ⚠
or ⚠ THROTTLED ⚠
cells by selecting from the recalculate options within the Claude for Sheets extension menu.Can't enter API key