The section where it stops being a website and starts being a product: wire a chat interface to an AI API and give it a personality.
You've been using Claude through the website. Now you're going to call Claude (or OpenAI) directly from your own code :: so your app can generate text, answer questions, and respond to users in real time.
Go to platform.claude.com → create account → API Keys → Create Key. Copy it somewhere safe. This is different from your claude.ai login :: it's specifically for calling Claude from code.
Treat the key like a password. Never paste it into a chat (including Claude), a screenshot, or a file you push to GitHub. The API is pay-as-you-go: add a small amount of credit, then set a monthly spend limit in the Console's billing settings so a bug can never run up a bill. This is the one section of the primer that is not $0.
A chat interface is just: a text input, a send button, and a message list that updates. The AI call is just a fetch() request :: you learned this last section.
AI API calls need to happen server-side to keep your key safe. Open replit.com (you set this up in Section 00) → New Repl → Node.js. This gives you a free server environment in your browser.
Build me a chatbot app using the Anthropic Claude API in Replit (Node.js). My API key is already stored as a Replit secret named ANTHROPIC_API_KEY. (Do not ask me for the key, and never print it.) The chatbot should have this personality: [describe your bot :: e.g., "a sarcastic movie critic"] System prompt: [describe the bot's rules and personality in detail] Build: a clean chat UI (HTML/CSS), a Node.js server that calls the Claude API, message history so context is maintained. I'm a beginner :: explain each file's purpose with comments.
A system prompt is a set of instructions you give Claude before the conversation starts. It defines the AI's role, knowledge, tone, and rules. This is what turns a generic chatbot into something unique.
// A cooking assistant "You are Chef Marco, an enthusiastic Italian chef. You only talk about food, recipes, and cooking techniques. Always suggest an Italian dish as an example. Keep responses under 150 words. End every message with a relevant food emoji." // A study buddy "You are a patient tutor helping a high school student. Ask questions back to check understanding rather than just giving answers. Use simple language. Never do homework for them :: guide them to the answer instead."
Write a detailed system prompt for a [type] chatbot that: - Has this personality: [describe] - Knows about: [topics] - Should NOT: [limitations] - Responds in this style: [tone/format] Make it specific enough that the AI has a clear, consistent character.
Replit has a "Secrets" feature :: environment variables that your code can read but that don't appear in your code files. This is how you keep API keys private.
Find Secrets in Replit's Tools list (or search for "Secrets"). This is your encrypted secrets store.
Key: ANTHROPIC_API_KEY · Value: your actual API key. Use exactly that name: it is the one the official Anthropic SDK looks for automatically.
process.envconst key = process.env.ANTHROPIC_API_KEY :: reads the secret without it ever appearing in your code. Safe to share the code now.
Make it something you'd actually use or show off :: give it a strong personality and a clear purpose.