API keys and keyless calls
The keys that protect your endpoints, and how to let a browser call your model without one.
A project's endpoint can be called in two ways: with an API key, from your own server, or without one, from a browser on a site you allow. This page covers both.
The keys
| Key | Used with | Where you see it |
|---|---|---|
| Project API key | The stable endpoint, /api/p/<project-id>/infer, and the OpenAI-compatible endpoint | Once, at the project's first deployment |
| Deployment key | One versioned endpoint, /api/deployments/<deployment-id>/infer | On the Overview under API key, for the live deployment |
Send either one in an X-Api-Key header, or as Authorization: Bearer <key>, which is how the OpenAI SDKs send it. See Call your model.
The project API key
The project's first deployment creates its API key and shows it once: on the wizard's Deploy step (Save this key now. It won't be shown again!) or on Training jobs (Save your project API key). After that, Studio shows only its last four characters, so you can tell which key you stored.
Studio can't show the project API key again, and has no button to replace it. Store it in your secrets manager when you first see it. If you lose it, contact us.
Deployment keys
Each deployment has its own key for its versioned endpoint. On the Overview, Regenerate next to API key replaces the live deployment's key and shows the new one. The old key stops working immediately, so update your code first or be ready to.
Regenerate doesn't change the project API key.
Keyless calls
The intent bar runs in your users' browsers, and code in a browser can't keep a secret. So the intent bar calls the stable endpoint without a key, and the project limits who may call it instead.
To turn keyless calls on, open the project's Overview, go to Add the intent bar, and choose Allow keyless calls. The same control is on the wizard's Deploy step under Keyless access.
Studio has no control to turn keyless calls off again. If you need to, contact us. Requests that carry the project API key keep working either way.
Allowed sites
Once keyless calls are on, Sites allowed to call this endpoint lists the sites whose pages may call it. Enter one address per line, such as https://app.example.com, and choose Save allowed sites.
- The
www.and bare forms of an address both match, overhttpandhttps. - Add
http://localhost:3000, or wherever you run your app, while you develop. - Left empty, the list allows the address Studio names beside it, the site the project was created from. When Studio names none, as for a project created from API docs or a file, an empty list allows any site.
A call from a browser on a site that isn't listed gets a 403, and the browser doesn't let the page read the answer.
What the allowed sites don't do
The list is enforced by browsers. A script outside a browser can send any Origin header it likes, or none, and a request with no Origin isn't checked against the list. Two other controls apply to every keyless request:
- A rate limit. Each caller can make 20 requests a minute to a project. Past that, the endpoint answers
429. - Your daily limit. Keyless requests count toward your plan's daily inference requests, like any other.
Requests that carry the project API key skip both the allowed-sites check and the per-caller rate limit.
What to use where
| Calling from | Use |
|---|---|
| Your server | The project API key, kept in your server's configuration |
| Your web app, through the intent bar | Keyless calls, with your app's address in the allowed sites |
| A mobile or desktop app | Your own server in between, holding the project API key |
| A test against one model version | That deployment's versioned endpoint and key |
Revised