Suanlimao
← Back to all tutorials

Troubleshooting & security

Key safety and best practices

A key is money: how to store it, limit it and what to do after a leak.

About 6 minFor:Everyone who holds a key

Before you start

  • At least one key

Step 1 · STEP 0x01

Store keys properly

terminal
$ export API_KEY=<YOUR_API_KEY>$ echo ".env" >> .gitignore
  • Keep it in an environment variable or a password manager, never in code.
  • Never commit it to git, especially public repos; add .env to .gitignore.
  • Never ship it in web front-end or mobile app code — anyone can extract it.
  • Don't post it in chats, tickets or screenshots.
Many leaks come from “just pasting once”: replace the key with a placeholder before pasting configs into a forum.

Step 2 · STEP 0x02

One key per purpose, with limits

API keys → Edit
1

Budgets (USD)

Set a monthly cap
2

Model allowlist

Only the models this use needs
3

IP allowlist

For servers with a fixed outgoing IP
4

Expiry date

Set one for keys you lend out
5
Save
Diagram — the wording matches the real page, the layout may differ slightly

Even if one key leaks, the loss is capped by its own budget and revoking it does not affect your other tools.

Step 3 · STEP 0x03

Turn on alerts and review regularly

Settings → Email notifications
1

Low balance alert

On
2

Unusual key usage alert

On
3

Top-up received

On
4
Save
Diagram — the wording matches the real page, the layout may differ slightly
  • Glance at the Usage page weekly for unknown models or times.
  • Check Last used on the API keys page and revoke keys you no longer use.
  • Change your password now and then; other devices are signed out after a change.

Step 4 · STEP 0x04

If you suspect a leak, do this in order

API keys
1
Revoke
2
Create key
Diagram — the wording matches the real page, the layout may differ slightly
  • 1. Revoke the key at once; requests using it fail immediately.
  • 2. Create a new key and update your tools.
  • 3. Check the Usage page for unknown requests during the exposure and open a billing ticket for charges you doubt (within 30 days).
  • 4. Find where it leaked (repo, chat, screenshot) and clean it up.
If it was your account password, change it immediately and mention it in a ticket.

✓ How to tell it worked

  • Every key has a name, a budget and suitable limits, and you know the first step after a leak is to revoke.

FAQ

Does the share page leak the key?

No — it only shows how to connect. You send the key separately.

Can several people share one key?

Not recommended. One key each: you revoke only the one that misbehaves and see who used how much.

Related tutorials

Still stuck?

Read the troubleshooting tutorials first. If that does not help, open a ticket with the request_id, time, model and the exact error (never paste your key).