You use Claude Code with a Claude subscription or with an API key from Anthropic. You create the key in your Anthropic account, and when you work with it you pay for what you use.
Anyone who knows the key can spend from your account. Keep it in a .env file that's listed in .gitignore, so it never goes into a commit. If a key ends up in a public repo, revoke it right away and get a new one.
The permission settings in the template of the free 2-hour program forbid the agent from reading files that start with .env. The app you build there needs no key, and if you need one at all, it's only for Claude Code.