Get startedGet started for free

Text summarization with Claude

You’re the content strategist at the e-gaming firm Nebula Forge Games, preparing to ship the newest edition of Skybound Legends. The development team just published a developer article describing new features, but you need to extract a blurb for social media audiences. Squeeze that article into an engaging 2-sentence teaser that is accessible for social-media audiences.

The anthropic library, client, and article_text string are pre-loaded.

This exercise is part of the course

Introduction to Claude Models

View Course

Exercise instructions

  • Set the system message to establish an engaging, accessible tone for social media audiences.
  • Create a user prompt that asks for a 2-3 sentence summary of the article.
  • Set max_tokens to limit the response to 100 characters.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Set up system message for social media tone
system_msg = "____"

# Create the summarization prompt with length constraint
user_prompt = f"____: {article_text}"

# Make API call with appropriate parameters
response = client.messages.create(
    model="claude-3-7-sonnet-latest",
    max_tokens=____,
    system=system_msg,
    messages=[
        {"role": "user", "content": user_prompt}
    ])
print(response.content[0].text)
Edit and Run Code