PromptPreview
Chapter 1beginner

Basic Prompt Structure

The Claude for Sheets extension offers several functions you can use to call Claude. One such function is CLAUDEMESSAGES(), which is built to reflect the Messages API structure.

CLAUDEMESSAGES() can take several parameters, in the following order:

  1. Your prompt, in quotation marks
  2. The model version, in quotation marks
  3. Any optional additional parameters, such as temperature, system prompt, max tokens, etc.
Note: Temperature correlates to the degree of variability in Claude's answer. For these exercises, we have set the "temperature" to 0. In Chapter 8, we'll dive deeper into temperature.

Anywhere in this sheet, you can call Claude by using the CLAUDEMESSAGES() formula. The basic formula is structured like this: =CLAUDEMESSAGES("{PROMPT}", "{MODEL_VERSION}", "system", "{SYSTEM_PROMPT}")

For example, to call Claude 3 Haiku with a prompt located in cell A1, you would write: =CLAUDEMESSAGES(A1, "claude-3-haiku-20240307", "system", "Respond only in Esperanto")

How does the CLAUDEMESSAGES() structure correlate with the Messages API structure? Let's look a few examples of prompts sent to CLAUDEMESSAGES() along with the underlying formula.

Examples

Example 1
User Prompt
Hi Claude, how are you?
Response
Response will be generated by the LLM
Example 2
User Prompt
Can you tell me the color of the ocean?
Response
Response will be generated by the LLM
Example 3
User Prompt
What year was Celine Dion born in?
Response
Response will be generated by the LLM
Example 4
User Prompt
What year was Celine Dion born in?
User: Also, can you tell me some other facts about her?
Response
Response will be generated by the LLM
Example 5
User Prompt
What year was Celine Dion born in?
Response
⚠️=CLAUDEMESSAGES prompt should be in "User: ...
Assistant: ..." format, with "User: ..." first and a newline before each subsequent role. For newlines, press Ctrl/Cmd+Enter⚠️
Example 6
System
Your answer should always be a series of critical thinking questions that further the conversation (do not provide answers to your questions). Do not actually answer the user question.
User Prompt
Why is the sky blue?
Response
Response will be generated by the LLM

Playground

Editable

Try modifying these prompts and sending them to your configured LLM provider.

Try it yourself
Try it yourself
Try it yourself
Try it yourself
Try it yourself
Try it yourself
Try it yourself
Try it yourself

Ready to practice what you've learned?