There is no "free" version of the API according to the pricing page:
https://openai.com/pricing
There is a free web page interface (https://chat.openai.com), but that is not the API. For the API they give you some tokens at the start if I remember correctly, then you must pay-per-use.
If you want free: use a local LLM (the model runs on your Mac, no costs and no privacy concerns as OpenAI hoovers up all your data), or use a wrapper tool like https://openrouter.ai (that can utilise OpenAI, Claude, or many different open source free models using a single unified API). Sadly there is a small API incompatibility between this workflow and OpenRouter (@vitor may accept a pull request to fix it but I haven't had time...), so that leaves you with: give your credit card details to OpenAI, or use a local model...
@CharlesVermeulen To expand on @iandol's response: OpenAI offer some API free credit on account creation (it's now $5 I believe) which is valid for 3 months, then expires.
If your credit has expired, or you've used it up, you'll see the error message you've received.
Reiterating what has been said before; The ChatGPT web-based interface is separate from the API, so while the website is free, there is a cost to the API, however small, so you'll likely need to add a few dollars of credit here:
https://platform.openai.com/account/billing/overview