Skip to content

Setting 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 be the token of 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"
set NEPTUNE_API_TOKEN="h0dHBzOi8aHR0cHM4kl0jvYh3Kb8...6Lc"
set NEPTUNE_PROJECT="ml-team/classification"

Finding your credentials#

API token#

In the top-right corner of the Neptune app, click your avatar and select Get your API token.

Project name#

Your full project name has the form workspace-name/project-name. To copy the name, navigate to your projectSettingsProperties.

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["namspace/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",
)