Getting started
API keys and security
Create, scope, rotate and revoke AILabStore API keys, and keep them out of your source code, logs and browsers.
6 min read · Updated November 1, 2026
Your AILabStore API key is a bearer credential: anyone who holds it can spend your token credits. This guide covers how keys work, how to store them safely, and what to do if one leaks.
How AILabStore keys work
- Keys are created in Portal → API keys and start with the prefix
als_live_. - The full key is displayed once, at creation. AILabStore stores only a SHA-256 hash and the first 12 characters (the prefix) so you can recognise the key later.
- Each key shows when it was created and when it was last used.
- Revoking a key takes effect immediately. Requests using a revoked key return
401. - The number of active keys depends on your packages: Starter includes 2, Pro includes 20.
Because we only store a hash, support cannot recover a lost key. Create a new one and revoke the old one instead.
Store keys in environment variables
Never paste a key directly into source code. Read it from the environment:
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.ailabstore.cc/v1",
api_key=os.environ["AILABSTORE_API_KEY"],
)
import OpenAI from "openai";
const apiKey = process.env.AILABSTORE_API_KEY;
if (!apiKey) throw new Error("AILABSTORE_API_KEY is not set");
const client = new OpenAI({ baseURL: "https://api.ailabstore.cc/v1", apiKey });
For local development, keep keys in a .env file and make sure it is ignored by git:
echo "AILABSTORE_API_KEY=als_live_..." >> .env
echo ".env" >> .gitignore
In production, use your platform's secret manager: Docker secrets, Kubernetes Secrets, AWS Secrets Manager, Google Secret Manager, Vercel or Fly.io environment variables. Inject the key at runtime rather than baking it into images.
Never expose keys in the browser
A key embedded in front-end JavaScript, a mobile app bundle or a desktop app can be extracted in minutes. Always call AILabStore from a server you control and expose your own narrow endpoint to clients:
// app/api/summarise/route.ts (Next.js route handler, runs on the server)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.ailabstore.cc/v1",
apiKey: process.env.AILABSTORE_API_KEY,
});
export async function POST(req: Request) {
const { text } = await req.json();
if (typeof text !== "string" || text.length > 20_000) {
return Response.json({ error: "Invalid input" }, { status: 400 });
}
const r = await client.chat.completions.create({
model: "anthropic/claude-haiku-5.5",
messages: [{ role: "user", content: `Summarise in 3 bullets:\n\n${text}` }],
max_tokens: 300,
});
return Response.json({ summary: r.choices[0].message.content });
}
Your endpoint can then enforce authentication, input limits and per-user rate limits before any tokens are spent.
Use one key per environment and service
Separate keys make incidents smaller and usage easier to understand:
| Key name | Used by |
|---|---|
local-alice |
One developer's machine |
ci |
Automated tests |
prod-api |
Production backend |
prod-n8n |
Managed n8n workflows |
If ci leaks from a build log, you revoke one key without touching production.
Rotate keys regularly
A simple zero-downtime rotation:
- Create a new key in Portal → API keys.
- Deploy it to your secret manager alongside the old one.
- Roll your services so they read the new key.
- Watch the old key's Last used timestamp. Once it stops changing, revoke it.
We recommend rotating production keys at least every 90 days and whenever someone with access leaves the team.
Keep keys out of logs
HTTP client debug logging often prints headers. Redact the Authorization header before logging requests, and never log full request objects in production:
import logging, re
class RedactKeys(logging.Filter):
pattern = re.compile(r"als_live_[A-Za-z0-9]+")
def filter(self, record):
record.msg = self.pattern.sub("als_live_[REDACTED]", str(record.msg))
return True
logging.getLogger().addFilter(RedactKeys())
Scan repositories for leaked keys
Add a secret scanner to your pre-commit hooks and CI. A simple pattern catches AILabStore keys:
git grep -nE "als_live_[A-Za-z0-9]{16,}" || echo "No keys found"
Tools such as gitleaks or GitHub secret scanning can use the same regular expression as a custom pattern.
If a key leaks
- Revoke it immediately in Portal → API keys. This is instant.
- Create a replacement and redeploy affected services.
- Review Portal → Usage for unexpected models or spikes around the time of exposure.
- Remove the key from git history if it was committed (rotating is still required, because clones may exist).
- Contact [email protected] if you see usage you did not make. Include the key prefix, never the full key.
How AILabStore protects your data
- All API traffic is encrypted with TLS.
- We do not store prompt or completion content by default; we keep the metadata needed for billing (model, token counts, timestamps).
- Keys are stored as hashes.
- Card details are handled by our payment processor and never touch our servers.
See the Security page for more detail.