"""check_setup.py, M4 step 1: prove your API key works with one tiny call.

Run this FIRST, after putting your key in .env. It makes the smallest possible
request so you confirm everything is wired up before building the chatbot.

Run (inside your activated virtual environment, from this folder):
    python check_setup.py
"""

import os
from dotenv import load_dotenv          # reads key=value pairs from a .env file
import anthropic                        # the official Claude SDK

# --- 1. Load secrets from .env into the environment --------------------------
load_dotenv()                           # looks for a file named .env in this folder

api_key = os.getenv("ANTHROPIC_API_KEY")
if not api_key:
    print("No ANTHROPIC_API_KEY found.")
    print("Copy .env.example to .env and paste your key into it, then run again.")
    raise SystemExit(1)
if not api_key.startswith("sk-ant-"):
    print("Warning: that doesn't look like an Anthropic key (it should start with 'sk-ant-').")

# --- 2. Create the client (it reads ANTHROPIC_API_KEY from the environment) --
client = anthropic.Anthropic()

# --- 3. Make the smallest possible request -----------------------------------
response = client.messages.create(
    model="claude-opus-4-8",            # the model doing the thinking
    max_tokens=100,                     # cap the reply length
    messages=[{"role": "user", "content": "Say hello in one short, friendly sentence."}],
)

# --- 4. Read the reply -------------------------------------------------------
# response.content is a list of blocks; the first is the text reply.
print("It works! Claude says:")
print(response.content[0].text)
