Skip to main content

Using API keys with REST requests

You may limit access to your deployed models using API keys. API keys are created in the Settings area of Modelbit.

Enforcing API keys with deployments

In Settings, under API Keys toggle Deployments Require API Keys to enforce API keys across all deployments. Once enabled, deployments will error unless the request includes a valid API key.

Here's how to use your API key when calling the REST APIs of your deployments:

Use the api_key parameter of modelbit.get_inference:

import modelbit

modelbit.get_inference(..., api_key: "YOUR_API_KEY")

Testing API keys

Before enabling the setting Deployments Require API Keys, you can optionally send API keys along with your REST requests to check that they'd work correctly.

If an API key is present it will be always be validated, regardless of the Deployments Require API Keys setting. If the API key is invalid the request will be rejected with an error.

See also