Manage API keys and credits across providers
Once you claim a few free AI offers, you end up juggling multiple API keys, base URLs, rate limits, and expiration dates. Here is how to wire them into your tools cleanly and keep your quotas organized without mixing up credentials.
Keys and endpoints
Your API key authenticates requests and bills usage to your account. Your base URL tells the client where to send traffic. Most free offers speak one of three protocols:
- OpenAI Chat Completions (
/v1/chat/completions): the widest standard. Most clients expect/v1at the end of the base URL. - OpenAI Responses (
/v1/responses): used by Codex CLI by default. Not every OpenAI-compatible provider supports it yet. - Anthropic Messages (
/v1/messages): required by Claude Code. The Anthropic SDK appends/v1/messagesitself, so omit/v1fromANTHROPIC_BASE_URL(e.g.https://api.example.com/api).
Connect your tools
- Claude Code. Run it in a dedicated shell with
ANTHROPIC_BASE_URLand the auth variable your provider expects. If it usesANTHROPIC_AUTH_TOKEN, rununset ANTHROPIC_API_KEYfirst so the two variables don’t conflict. - Chat clients. Add a custom provider with its base URL, API key, and exact model ID from the provider’s docs. Check whether the client appends
/v1automatically. - Quick sanity check. Send a one-line
curlrequest before pointing an agent at a repo. See the coding-agent setup guide for copy-paste templates.
If a request fails: 401 usually means a bad key, unaccepted terms, or conflicting auth headers; 404 means a wrong /v1 suffix or unsupported protocol; 429 means rate-limited or out of credit; 400 usually points to a typo in the model ID or exceeding the context window. See the error troubleshooting guide for details.
Track quotas in a simple table
Once you have more than three providers, keep a local note with four columns: provider, quota and reset cycle, expiration date, and status. A 30-day credit (like Cerebras) or 3-month credit (like Oumi) needs a different schedule than a daily-reset tier (like Groq). Check current rules in the free AI offers directory.
- Burn expiring credits first on focused work; keep daily-reset tiers for routine tasks.
- Keep at least one tested backup provider ready in case your primary endpoint hits a rate limit or goes down.
- Prune dead entries from your local config and revoke unused keys in the provider console.
Keep keys and prompts private
Use one key per provider and store secrets in environment variables, a local secret store, or your tool’s auth manager—never in Git, chat logs, or screenshots. If a key leaks, revoke it before generating a new one. Check a provider’s data-retention policy before sending private code, and remember that promotional credits are platform balances, not withdrawable funds.