> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/reference/authentication/authentication/find-your-roboflow-api-key.md).

# Find Your Roboflow API Key

Find your API Key to authenticate with the Roboflow API and Roboflow Inference

Your API key is at [app.roboflow.com/settings/api](https://app.roboflow.com/settings/api), under Settings, "API Keys".

There are two kinds of key:

* Private API key: the credential for the [REST API](/reference/platform/rest-api.md), [Python SDK](/reference/platform/python-sdk.md), [CLI](/reference/platform/cli.md) and [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted). Treat it like a password. It grants access to your workspace's data and models.
* Publishable key: a non-secret key of the form `rf_<workspaceId>` for browser and edge code such as `inference.js`. It can run inference and download models, nothing else. See [The Publishable Key](/reference/authentication/authentication/manage-api-keys.md#the-publishable-key).

Keys belong to a Workspace. To reach a workspace's private projects, use a key from that workspace.

<figure><img src="https://2143050199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmbAGf4KNeNPXGuUuKYv%2Fuploads%2Fgit-blob-ee9c711746c549f84e164db9d4d68158b4a01050%2Fimage-a4b3fa.png?alt=media" alt=""><figcaption></figcaption></figure>

Click "Generate New Key" to create a key, or copy one you already have. To name, roll, protect or revoke keys, see [Manage API Keys in the Dashboard](/reference/authentication/authentication/manage-api-keys-in-the-dashboard.md). If a key was exposed, see [Rotate API Keys](/reference/authentication/authentication/rotate-api-keys.md).

## Use Your Key with Roboflow Inference

Your API key grants access to the models you have trained on Roboflow, public models on Roboflow Universe, and the hosted inference APIs. There are several ways to supply it when using [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted).

### Environment variable

The recommended way is to set `ROBOFLOW_API_KEY` in your environment. In most terminals:

```bash
export ROBOFLOW_API_KEY=YOUR_API_KEY
```

Any command run in that terminal session then has access to the key. See [Environment Variables](/reference/environment-variables.md) for the other variables the CLI and SDK read.

### Python

When using Inference from Python, the key can be passed as a keyword argument:

```python
from inference import get_model

model = get_model(model_id="...", api_key="YOUR_API_KEY")
```

{% hint style="success" %}
If the key is set in your environment, you do not have to pass it as an argument: `model = get_model(model_id="...")`.
{% endhint %}

### HTTP requests

When calling the server directly, send the key as an `Authorization: Bearer` header. The header keeps the key out of URLs, access logs, and browser history, and works the same on every route:

```python
import requests

my_api_key = "YOUR_API_KEY"
headers = {"Authorization": f"Bearer {my_api_key}"}

url = "http://localhost:9001/soccer-players-5fuqs/1"
response = requests.post(url, headers=headers)

url = "http://localhost:9001/infer/object_detection"
payload = {"model_id": "soccer-players-5fuqs/1"}
response = requests.post(url, json=payload, headers=headers)
```

Self-hosted servers read the header from Inference release 1.5.0 onward. The hosted APIs accept it as well.

Passing the key as a URL parameter (`?api_key=...`) or as an `api_key` field in the request payload is the legacy channel. It still works on every server version, but is not recommended for new code:

```python
url = f"http://localhost:9001/soccer-players-5fuqs/1?api_key={my_api_key}"
response = requests.post(url)
```

When several channels carry a key, the query parameter wins over the header, and the header wins over the body field.

When using the Python SDK, set the transport once on the client instead of building headers yourself: see [API key transport](/reference/inference/inference-sdk/configuration.md#api-key-transport).

### Docker

If you run the Inference Server locally in a Docker container, provide the key in the `docker run` command:

```bash
docker run -it --rm --network=host -e ROBOFLOW_API_KEY=YOUR_API_KEY roboflow/roboflow-inference-server-cpu:latest
```

Requests sent to that server can then omit `api_key` from the request payload.

{% hint style="warning" %}
A self-hosted server does not require an API key by default. Setting one in the container does not restrict who may call the server: see [Securing a Self-Hosted Server](https://docs.roboflow.com/deployment/self-hosted/inference-server/configuration/security) to enforce authentication.
{% endhint %}
