From user to builder
You've been using Claude as a tool — ask a question, get an answer. This chapter is about a different relationship: you're building a product and Claude is a feature inside it. Your users will interact with AI without knowing they're talking to Claude.
This is what the next generation of software looks like. Not just AI-assisted development, but AI-powered products. And as a UX Engineer, you're positioned to build them.
API keys — what they are and how to keep them safe
An API key is a secret credential that authenticates your requests to a service. Think of it as a password for your application. The Anthropic API key looks like sk-ant-api03-...
The Claude API — messages and responses
The Anthropic API is simple. You send an array of messages (just like a conversation), and you get a response. Here's the minimal request:
export default async function handler(req, res) {
const { userMessage } = req.body;
const response = await fetch('https://api.anthropic.com/v1/messages', {
method: 'POST',
headers: {
'x-api-key': process.env.ANTHROPIC_API_KEY,
'anthropic-version': '2023-06-01',
'content-type': 'application/json',
},
body: JSON.stringify({
model: 'claude-opus-4-6', // the model to use
max_tokens: 1024, // max response length
system: 'You are a helpful product design assistant. Be concise.',
messages: [
{ role: 'user', content: userMessage }
]
})
});
const data = await response.json();
const reply = data.content[0].text;
res.json({ reply });
}
// In your React component or vanilla JS
async function askClaude(question) {
const response = await fetch('/api/ask', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ userMessage: question })
});
const data = await response.json();
return data.reply;
}
System prompts — giving Claude a job
The system parameter lets you define Claude's role before the conversation starts. This is where you give it a persona, constraints, and context. It's the most powerful tool for shaping AI behavior in your product.
// For a writing feedback tool
system: `You are a UX writing expert. Review the user-submitted copy and give
concise feedback on: clarity, action orientation, tone, and length.
Format your response as 3-5 bullet points. Be direct, not fluffy.`
// For an onboarding assistant
system: `You are an onboarding guide for a project management tool.
Help new users understand features. Keep responses under 100 words.
If asked about something unrelated to project management, politely redirect.`
// For an ideas board
system: `You are a product thinking partner. The user will share a product idea.
Respond with: one strength, one potential user problem, and one next step to validate.
Keep the whole response under 80 words.`
Cost considerations
The Claude API is priced per token (roughly per word). For small hobby projects, costs are negligible — a few cents per day of active usage. For products with real users, set a budget and monitor your dashboard.
-
claude-haiku-4-5 — fastest and cheapest. Great for high-volume, shorter tasks (classification, summaries, quick answers).
-
claude-sonnet-4-6 — balanced speed and capability. Best for most product features.
-
claude-opus-4-6 — most capable. Best for complex reasoning tasks where quality matters most.
-
Set
max_tokensappropriately — don't leave it at 4096 if you only need 200-word responses.
-
1Get an Anthropic API key from console.anthropic.com. Add it as an environment variable in your Vercel project: Settings → Environment Variables →
ANTHROPIC_API_KEY. -
2Ask Claude: "Create a Vercel serverless function at api/feedback.js that takes a POST request with a JSON body {idea: string}. It calls the Anthropic API using the model claude-haiku-4-5-20251001, with a system prompt that says you are a product thinking partner who gives 3-bullet feedback on ideas (one strength, one risk, one next step). Return the reply as JSON {feedback: string}."
-
3Add a "Get AI feedback" button to each idea card in your HTML. When clicked, POST the idea text to
/api/feedbackand display the response below the idea. -
4Deploy the updated code to Vercel. Test it in production. You've shipped a real AI-powered feature.
- Never put API keys in client-side JavaScript. Always call AI APIs from serverless functions
- The Claude API is a simple POST request: send messages, get a response
- System prompts define Claude's role, constraints, and output format — craft them carefully
- Use
claude-haiku-4-5for high-volume tasks,claude-sonnet-4-6for balanced quality/cost - Set
max_tokensintentionally to control response length and cost