一份提示词模板:让智能体用你自己的 Anthropic API key 干活
这是个拿来就能用的提示词模板,教你让智能体走你自己的 Anthropic API 账户干活,key 走安全字段不进聊天记录,还带测试和报错排查步骤。经常跑长任务、嫌订阅额度不够的人照抄一遍就能省不少钱。
Lenny Rachitsky 分享了一份可直接复制的提示词,让 Claude Code 等智能体改用用户自己的 Anthropic API 账户,而不是智能体自带的模型额度。模板覆盖从要 key 到跑通任务的完整 6 步流程:先通过安全 secret 字段(不在聊天中明文)索取 API key 和 workspace ID,只在本地存储且不打印。
技术上,模板要求写一个小 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 额度跑长任务、又不想烧智能体订阅额度的开发者。
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 ⚡
本条情报归属 AITOP「技巧」核心栏目,重点聚焦北美前沿实验室与硅谷科技巨头。在跨区域产业观察坐标中,该动态直接关联「AI 开发者工具链、Coding Agent 与工程化实践」研究主线,反映出当前技术演进与商业落地的最新风向。涉及核心实体与技术议题包括:Claude、Anthropic、API、提示词工程,读者可通过下方标签进入对应专题页查阅历史脉络与关联对比。
信源核验说明:本文原始线索采编自「Lenny Rachitsky」(@lennysan),经 AITOP 多维评分管线结构化提炼。