An AI API key connects a request to provider authority and account context. Treat the key, endpoint and workload owner as one operating configuration, with billing and capacity controls checked separately.
Definition with a live example
The key is a credential, not the model itself. A request still needs the correct endpoint, model identifier and payload. A valid credential can therefore be followed by a model-access, billing or validation failure. Preserve that distinction in diagnostics so every rejected request does not trigger another key creation.
OpenAI’s production guidance recommends protected key configuration and project separation for application environments. Official documentation.
| Model | Official identifier | Modalities | Context tokens | Input USD / 1M | Output USD / 1M | Status |
|---|---|---|---|---|---|---|
| gpt-5.6-luna | gpt-5.6-luna | text | 1,050,000 | $0.2 | $1.2 | Active |
| gpt-5.6-sol | gpt-5.6-sol | text | 1,050,000 | $4 | $20 | Active |
| gpt-5.6-terra | gpt-5.6-terra | text | 1,050,000 | $2 | $12 | Active |
| gpt-6-astra | gpt-6-astra | text | 1,050,000 | $10 | $50 | Active |
Last verified · Source ↗
The live list shows the models a request can select in the reference. Actual account access still needs verification. Choose a small eligible model request and inspect its response before assigning the key to an unattended worker. A model catalog is not a list of permissions automatically attached to every credential.
Give the credential an application purpose and an owner. Record which project or workspace owns its usage, which process loads it and how the process can be stopped. Keep this record free of the secret value. It should help another maintainer rotate access without searching unrelated scripts or asking for a copied production credential.
The account hierarchy matters. A project, workspace or organization can attach its own permission and spending controls to the request. A key label helps people recognize the workload, but the provider’s documented scope determines the authority. Inspect those controls before assuming a new key is isolated from other account usage.

How it affects cost / limits / results
Billing and throughput are different operating dimensions. A key may have an enforced credit boundary, while its parent account or model supplies a shared request allowance. A funded request can still be too bursty; a quiet request can still fail at an exhausted budget. Keep the actual code and affected scope in the failure state.
Use the cost calculator to establish the intended workload, then configure the provider’s real account controls. A planning estimate does not enforce a budget and should not be presented as the mechanism that stops requests.
Keep secrets in the server-side environment or a suitable secret-management service. The process that sends the request must load the value without copying it into source, logs or a browser bundle. A frontend can call your authorized backend; it should not expose the provider credential to every visitor.
Verify the actual launch path. An interactive terminal can have a variable that an editor, service manager or scheduled worker does not inherit. Check presence without printing the value, then run a safe minimal request from the environment that will operate the job. This isolates configuration failure from provider rejection.
Rotation needs a consumer inventory. Create a replacement where appropriate, deploy it to each consumer and verify the new path before retiring the old value. An immediate reset can invalidate the old key before a worker reloads configuration, so choose the provider-supported action that fits the application’s continuity requirement.
If the key is exposed, revocation matters more than deleting the local copy. Inspect usage and remove the leaked value from the place it appeared, while avoiding another copy in the incident report. Preserve safe timestamps and affected process information so the response can be understood without redistributing the secret.
Provider differences
Gemini key setup now distinguishes current authorization-key behavior from legacy key forms. Follow the official key guide and confirm the project that owns the key.
Alibaba Model Studio key setup ties the credential to workspace access and a matching host. The current key guide describes model/IP controls and one-time secret display.
OpenRouter key setup supports named credentials with credit controls in its authentication documentation. Keep a BYOK upstream credential distinct from the OpenRouter credential used by the application.
These examples demonstrate why a generic environment-variable pattern is only the storage part of setup. Each provider still has its own account hierarchy, credential type and request header or SDK configuration. Follow the provider-specific guide for the actual endpoint.
When migrating a workload, preserve the key owner, selected model and request interface with the new configuration. A compatible client can simplify code changes while the account and billing relationship changes completely. Run the same safe fixture and inspect the new account’s usage evidence before making it unattended.
Common mistakes
Do not paste a key into a model prompt, public issue or correction message. Share a minimal redacted reproduction with endpoint, model, interface and error code. A support investigation rarely needs the secret value itself.
Do not use the secret as the name passed to an environment lookup. The lookup expects a variable name such as the provider-specific name documented in the tutorial. Check the launch configuration rather than printing the environment wholesale.
Do not assume an alert is an enforced spending limit. Inspect the actual setting and define application stop behavior. If the provider’s accounting has delay, retain a bounded worker policy as part of the operating plan.
Do not create additional keys to multiply a shared rate allowance. The documented scope governs capacity, and independent keys can still compete within one parent account.
Do not retire a shared credential without identifying infrequent jobs. A rotation can appear complete until an old scheduled worker runs later and discovers its access has been removed.
Last verified · Source ↗
Frequently asked questions
Is an API key a model identifier?
Why can a valid key still get a rejection?
Does a calculator enforce spending?
Where should a secret be loaded?
What is needed for a safe rotation?
What should a diagnostic message exclude?
Sources
Last verified · Source ↗