Skip to content

Set Neptune credentials#

Neptune generally needs two things in order to send the metadata to the correct place:

  • 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 in your workflow, 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.

The workspace name is displayed in the top-left corner of the app. You can find and copy the full name of a project from its settings:

  1. In your project view, click the menu in the top-right corner.
  2. Select Edit project details.
  3. Click the copy button () next to Project.

Finding project details

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 a recommended practice 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 (make sure not to publish sensitive data through your source code!):

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