Setup for CLI

TrueFoundry CLI Libraries

TrueFoundry provides two CLI libraries to help you interact with the platform programmatically:

  • servicefoundry - Interacts with the deployments side of TrueFoundry, enabling you to manage workspaces, deployments, applications, and view logs.
  • mlfoundry - Provides experiment tracking capabilities, allowing you to track ML experiments and interact with ML repositories within TrueFoundry.

Setup for CLI


To install the ServiceFoundry CLI, run the following command:

pip install -U "servicefoundry"

To install the MLFoundry CLI, run the following command:

pip install -U "mlfoundry"


Login with manual interaction

You can log in to TrueFoundry using either the ServiceFoundry CLI or the MLFoundry CLI. Once you are logged in to one library, the other library will automatically be logged in as well.

To log in to ServiceFoundry, run the following command:

sfy login --host <your-truefoundry-host> # e.g. host:

To log in to MLFoundry, run the following command:

mlfoundry login --host <your-truefoundry-host> # e.g. host:

Login without manual interaction ( Non-Interactive Mode )

For scenarios where code interacts with Truefoundry APIs or where opening a browser is not feasible, you can log in using the Truefoundry API Key.

To begin, generate an API Key. Once you have the API key, you can authenticate in these ways:

1. Setting environment variables:

Set the TFY_API_KEY and TFY_HOST environment variables.

  • Set TFY_API_KEY to your API key.
  • Set TFY_HOST to your Truefoundry host URL. e.g.

2. Using the CLI:

When using the CLI, you can provide the API key directly within the command:

sfy login --host <your-truefoundry-host> --api-key <your-api-key>

Generate Truefoundry API Key

TrueFoundry API comes in handy when you want to interact with the Platform programmatically. You can generate the API key by following the instructions below:



Your API key is a sensitive piece of information, so handle it with care. Never share it with unauthorized individuals.

How the two libraries work together

The ServiceFoundry CLI and the MLFoundry CLI work together to provide a comprehensive solution for managing your machine learning experiments and deploying machine learning models on TrueFoundry.

For example, you could use the MLFoundry CLI to track your experiments and log the model artifact, and then use the ServiceFoundry CLI to deploy the model artifact to production.