Glossary
What is an API key?
In short
An API key is a secret string. An AI service uses it to learn which program is calling and which account to charge for the requests.
Infrastructure · API key
MMOOZZGG.com editorsChecked: 2 min read
For a child
Imagine the key to your locker in the school changing room. While you have it, nobody can take your jacket. If you lose the key or give it to a stranger, anyone can open the locker. Programs also have such keys for smart helpers. People keep them in a safe place, never show them to anyone and change the lock at once if a key goes missing.
In plain words
When your program calls a cloud AI model, it adds a long string of letters and numbers to the request. From it, the service learns who is calling, what this client may do and which account to charge. The key works like a password without a login: whoever has it can use your access. So nobody puts it into the code of a website or a mobile app, sends it in chats or posts it to a shared repository. For example, a support bot keeps the key on the company server, and the customer’s browser never sees it.
For business
A leaked key means other people’s requests at your cost and access to the data that passes through this account. Hence a few simple rules. Each employee and each system gets its own key, with separate keys for development, testing and production, so you can switch one off without stopping the rest. Keys live in a secrets store, not in settings files, and you change them regularly: Anthropic’s guidance gives once every 90 days as an example. Set a spending limit for the account and watch the usage chart, because a sharp spike is often the first sign of a leak. When an employee or a contractor leaves, revoke their keys the same day. Write these rules into the AI use policy before the first agent goes live.
For a specialist
An API key is a long-lived bearer credential: the server accepts a request simply because the string is presented, usually in an HTTP header, with no proof of ownership. So the main ways keys leak are ordinary: writing the key into source code, committing it to a repository, logs and URLs. Google Cloud advises against passing a key in query parameters, where it ends up in the address. It also advises removing keys from client code and proxying calls through your own server, adding usage restrictions, deleting unused keys and, for most APIs, replacing keys in production with short-lived service account credentials and IAM. Secrets are kept in a KMS or a secrets manager, rotated on a schedule and separated by environment. Leak detection relies on scanning: GitHub secret scanning checks the whole Git history on all branches and passes partner secrets it finds to their providers; Anthropic automatically deactivates a published key on such a signal.
Example
A developer accidentally pushed a settings file with a cloud model key to a public repository. A scanning service found the key, the provider switched it off and sent an email, and the team issued a new key at once and moved it to a secrets store.
Related terms
Questions and answers
Sources
Not sure whether your company needs this?
AI solutions map