# API Keys - Documentation

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown is available with `Accept: text/markdown` and `.md` URL variants.

Source: /docs/guides/llm-api-keys

# API Keys

Copy pageCopy page

Copy pageCopy page

An API key authenticates your requests to Novita AI. This page covers how keys work, how to create and store one, and how to keep it working across your environments.
Use this page to:

- Authenticate requests to Novita AI with a Bearer API key.

- Create an API key from the console and store it safely.

- Configure your key as an environment variable on Linux, macOS, and Windows.

- Understand how long a key stays valid and what the OpenAPI does and does not cover.

##

[​](#authentication)

Authentication

Novita AI authenticates API access using Bearer authentication. Send your API key in the `Authorization` request header:

```
Authorization: Bearer
```

An example request:

```
curl "https://api.novita.ai/openai/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $NOVITA_API_KEY" \
-d '{
"model": "deepseek/deepseek-r1",
"messages": [{"role": "user", "content": "Hello"}]
}'
```

##

[​](#create-an-api-key)

Create an API key

1

Open Key Management

Go to [Key Management](https://novita.ai/settings/key-management?utm_source=getstarted) in the console.

2

Create a new key

Select Create API Key, then give the key a name that reflects its purpose, such as `production` or `local-testing`.

3

Copy and store the key

The full key is shown only once, at creation. Copy it immediately and store it somewhere safe, such as a secrets manager or an environment variable. If you lose it, you cannot recover it — create a new key instead.

Optionally, you can limit which models a key is allowed to call. See [Model Access for API Keys](/docs/guides/llm-model-access).

##

[​](#key-format-and-validity)

Key format and validity

- Every key begins with the `sk_` prefix.

- A key is shown in full only once, at creation. Afterward, the console displays a masked form.

- A key stays valid indefinitely once created. It keeps working until you delete it in the console.

- Each account can create up to 10 API keys.

##

[​](#what-the-openapi-covers)

What the OpenAPI covers

You create and delete API keys in the console only. The Novita OpenAPI does not include endpoints to create or delete keys.
The key-related OpenAPI endpoints cover listing keys and managing a key’s model access policy:

- [List API Keys](/docs/api-reference/key-list-with-model-access) — list the keys on your team, with an optional model access summary.

- [Get API Key Model Access Policy](/docs/api-reference/key-get-model-access-policy) — read a single key’s model access policy.

- [Set API Key Model Access Policy](/docs/api-reference/key-put-model-access-policy) — set or update a key’s model access policy.

- [Reset API Key Model Access Policy](/docs/api-reference/key-delete-model-access-policy) — reset a key’s model access policy to the default. This resets the policy only; it does not delete the key itself.

##

[​](#store-your-key-as-an-environment-variable)

Store your key as an environment variable

Hardcoding a key in source code risks leaking it, for example when you commit the file. Reading the key from an environment variable such as `NOVITA_API_KEY` keeps it out of your code.

###

[​](#temporary-vs-permanent)

Temporary vs. permanent

A key set with `export` (Linux/macOS) or `set` (Windows) lasts only for the current terminal session and is gone when you close it. That is fine for a quick test. To keep the key across sessions, set it permanently as shown below, then open a new terminal so the change takes effect.

Linux

macOS

Windows

```
# Temporary: current session only
export NOVITA_API_KEY=""

# Permanent: append to your shell profile, then reload
echo 'export NOVITA_API_KEY=""' >> ~/.bashrc
source ~/.bashrc
```

```
# Temporary: current session only
export NOVITA_API_KEY=""

# Permanent: append to your shell profile, then reload
# Newer macOS uses zsh (~/.zshrc); older setups use bash (~/.bash_profile)
echo 'export NOVITA_API_KEY=""' >> ~/.zshrc
source ~/.zshrc
```

```
# Temporary: current PowerShell session only
$env:NOVITA_API_KEY = ""

# Permanent: persist for the current user, then open a new terminal
setx NOVITA_API_KEY ""
```

Read the key back in your code from the environment:

Python

Node.js

```
import os
from openai import OpenAI

client = OpenAI(
base_url="https://api.novita.ai/openai",
api_key=os.environ.get("NOVITA_API_KEY"),
)
```

```
import OpenAI from "openai";

const client = new OpenAI({
baseURL: "https://api.novita.ai/openai",
apiKey: process.env.NOVITA_API_KEY,
});
```

###

[​](#the-variable-is-set-but-the-code-still-can’t-find-it)

The variable is set but the code still can’t find it

You set it temporarily and opened a new terminal

A key set with `export` or `$env:` lives only in the terminal session where you ran it. A new terminal, or a new tab, does not inherit it. Set the key permanently (`>> ~/.zshrc`, `setx`), or re-run the `export`/`$env:` line in the session you are using.

You set it permanently but didn't restart

A permanent change (shell profile, `setx`) applies to terminals started after the change. Open a new terminal, and restart your IDE or editor so it picks up the new environment. On Windows, `setx` does not affect terminals that are already open.

A service manager doesn't inherit your shell environment

Processes launched by `systemd`, `supervisor`, Docker, or a CI runner do not read your interactive shell profile. Set the variable in the service’s own configuration (for example, a `systemd` unit’s `Environment=`, a `docker run -e` flag, or the CI project’s secrets), not in `~/.bashrc`.

You ran the command under sudo

`sudo` does not pass your environment through by default, so the variable you exported as your user is not visible to the elevated process. Use `sudo -E` to preserve the environment, or set the variable within the elevated context.

##

[​](#related)

Related

- [Model Access for API Keys](/docs/guides/llm-model-access) — restrict which models a key can call.

- [Common Error Codes](/docs/guides/error) — resolve `401` and `403` responses related to keys.

- [Rate limits](/docs/guides/llm-rate-limits) — request and token limits that apply to your account.

Last modified on August 4, 2026
