DEVSAIO

How to create, limit and rotate API keys safely

Separate keys per project, monthly spending limits and quick rotation keep your AI bill and your data safe.

DEVSAIO team · 2 min read
Share on X

An API key is the password to your balance. A few habits make a leaked key a non-event instead of an expensive surprise.

Make one key per project

Create keys from API Keys in your dashboard. Instead of one key everywhere, make one per app or machine: website-prod, telegram-bot, laptop. When you look at Usage Logs you'll see which key spent what, and if one leaks you only revoke that one.

Set a monthly limit

Each key can have a monthly spending limit. Once a key has spent that much in the calendar month (UTC), further requests with it are refused, while your other keys keep working. Good starting points:

  • Personal testing: a few dollars
  • A side project in production: what you'd be comfortable losing in a bad month
  • Anything that runs unattended (cron jobs, bots): always set one

Store keys outside your code

bash
# .env (add .env to .gitignore!)
DEVSAIO_API_KEY=sk-...
python
import os
from openai import OpenAI

client = OpenAI(base_url="https://devsaio.lol/v1", api_key=os.environ["DEVSAIO_API_KEY"])

Warning: Never put a key in browser JavaScript, a mobile app bundle or a public repository. Anyone can read those. Call the API from your server instead.

Rotate without downtime

  1. Create a new key.
  2. Deploy it to your app.
  3. Watch Usage Logs until the old key has no traffic.
  4. Revoke the old key.

If a key leaks

Revoke it immediately from the dashboard; it stops working at once. Then create a replacement and check the usage log for requests you don't recognise. Read the full API key security checklist for more.

Try it with one API key

Claude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.

Keep reading