MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Introduction to Claude Models

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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(____)
Edit dan Jalankan Kode