LoslegenKostenlos loslegen

End-to-end Claude prompting

As part of a company hackathon, your team is prototyping QuickAid, a help-desk bot for event attendees. Step one is to prove you can hit the Claude API from Python, get a live response, and print it to the console. Nail this, and the judges will green-light the rest of your prototype.

Diese Übung ist Teil des Kurses

Introduction to Claude Models

Kurs anzeigen

Anleitung zur Übung

  • Initialize the Anthropic client.
  • Set the parameter to specify the Claude Sonnet model.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

from anthropic import Anthropic
# Initialize the Anthropic client
client = ____(api_key="datacamp-token", base_url=url)

response = client.messages.create(
  	# Set the Claude Sonnet Model
    ____="claude-3-7-sonnet-latest",
    max_tokens=150,
    messages=[
        {"role": "user", "content": "What can you help me with today?"}
    ])

print(____)
Code bearbeiten und ausführen