Skip to content

Set Neptune credentials#

To send the metadata to the correct place, Neptune generally needs two things:

  • An API token. This is a long, unique string that works as authentication to the application. It can belong to a user account or a service account.
  • A project name. The account associated with the API token must have access to the workspace and project in question.

Saving your credentials as environment variables#

As a best practice, set your Neptune API token and full project name to the NEPTUNE_API_TOKEN and NEPTUNE_PROJECT environment variables, respectively.

export NEPTUNE_API_TOKEN="h0dHBzOi8aHR0cHM4kl0jvYh3Kb8...6Lc"
export NEPTUNE_PROJECT="ml-team/classification"
setx NEPTUNE_API_TOKEN "h0dHBzOi8aHR0cHM4kl0jvYh3Kb8...6Lc"
setx NEPTUNE_PROJECT "ml-team/classification"

Finding your credentials#

API token#

In the bottom-left corner of the Neptune app, expand the user menu and select Get your API token.

How to find your Neptune API token

Project name#

Your full project name has the form workspace-name/project-name.

To find and copy the full name of a project:

  1. Open the project settings ( ).
  2. Select Details & privacy.
  3. Click the copy button () next to Project.

Finding project details

Tip

You can also find a pre-filled project string in Experiments Create a new run.

Setting credentials in Colab#

If you're working in Google Colaboratory, you can set your credentials with the os and getpass libraries:

import os
from getpass import getpass
os.environ["NEPTUNE_API_TOKEN"] = getpass("Enter your Neptune API token: ")
os.environ["NEPTUNE_PROJECT"] = "workspace-name/project-name"

Note that these won't persist when the notebook kernel is terminated. You'll need to declare the variables again if you restart the notebook.

Passing credentials without environment variables#

While it's not recommended, especially for the API token, you can also pass your Neptune credentials in the code when initializing Neptune:

run = neptune.init_run(
    project="ml-team/classification",  # your full project name here
    api_token="h0dHBzOi8aHR0cHM6Lkc78ghs74kl0jvYh...3Kb8",  # your API token here
)

run["namespace/field"] = some_metadata

Logging anonymously#

If you haven't registered, you can also log anonymously to a public project:

run = neptune.init_run(
    api_token=neptune.ANONYMOUS_API_TOKEN,
    project="common/quickstarts",
)

Make sure not to publish sensitive data through your source code!