How-to

一份提示词模板:让智能体用你自己的 Anthropic API key 干活

Why we picked it

这是个拿来就能用的提示词模板,教你让智能体走你自己的 Anthropic API 账户干活,key 走安全字段不进聊天记录,还带测试和报错排查步骤。经常跑长任务、嫌订阅额度不够的人照抄一遍就能省不少钱。

Lenny Rachitsky 分享了一份可直接复制的提示词,让 Claude Code 等智能体改用用户自己的 Anthropic API 账户,而不是智能体自带的模型额度。模板覆盖从要 key 到跑通任务的完整 6 步流程:先通过安全 secret 字段(不在聊天中明文)索取 API key 和 workspace ID,只在本地存储且不打印。

Body

技术上,模板要求写一个小 helper 脚本调用 Anthropic Messages API(api.anthropic.com/v1/messages),带 x-api-key 和 anthropic-version 请求头,必要时加 anthropic-workspace-id。然后通过 GET /v1/models 列出该 key 可用的模型供用户选择,发一条测试消息验证连通性,失败时输出具体错误(如 credit balance too low)方便到 console.anthropic.com 修账单。

跑通后的玩法是分工:让指定的 Claude 模型写初稿,智能体本身负责审阅和事实核查,注意过滤 thinking block 只留文本。这套方法适合想用自己的 API 额度跑长任务、又不想烧智能体订阅额度的开发者。

Original · Lenny Rachitsky

Here's the prompt: I want you to use Anthropic's Claude models through my own Anthropic API account for [task, e.g. drafting my podcast guest briefs]. 1. Ask me for my Anthropic API key with a secure secret field (never in chat). If my key belongs to a specific Anthropic workspace, ask for that workspace ID the same way. 2. Store it only on your computer and never print it. Write a small helper script that calls the Anthropic Messages API ( api.anthropic.com/v1/messages ) with the x-api-key and anthropic-version headers, plus the anthropic-workspace-id header if I gave you one. 3. List the models my key can use (GET /v1/models) and show them to me so I can pick one. 4. Send a short test message and confirm it works. If it fails, tell me the exact error (e.g. credit balance too low) so I can fix billing at console.anthropic.com . 5. Once it works, update your skill and any routines so [model] writes the first draft and you review and fact-check it. Some models return a thinking block before the text, so keep only the text blocks. If a call fails, fall back to drafting yourself and tell me why. 6. Save this setup to your memory so it sticks.📊 1 ⚡

Industry Coordinates & Source Verification

This report is categorized under AITOP's "How-to" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include Claude, Anthropic, API, prompt engineering.

Source attribution: curated from Lenny Rachitsky (@lennysan).