Account and authentication

This guide explains how to set up your distil labs account and authenticate against the platform.

Registration

You can create a new distil labs account using either the CLI or the web app. Both methods will set up your account with a username and password that you can use to authenticate.

Using the CLI:

1distil register

Using the web app:

Visit app.distillabs.ai/sign-up and follow the sign-up process.

CLI authentication

Once you have an account, log in using the CLI:

1distil login

You can verify your identity with:

1distil whoami

To log out:

1distil logout

API authentication

If you need to interact with the distil labs API directly, you can obtain an API token using your username and password:

1import os
2import json
3import requests
4
5DISTIL_USERNAME = os.environ.get("DISTIL_USERNAME", "")
6DISTIL_PASSWORD = os.environ.get("DISTIL_PASSWORD", "")
7
8if not DISTIL_USERNAME or not DISTIL_PASSWORD:
9 raise ValueError("DISTIL_USERNAME and DISTIL_PASSWORD must be set")
10
11
12def distil_bearer_token() -> str:
13 """
14 Get an authentication token from the distil labs API
15
16 Returns:
17 str: Authentication token for API requests
18 """
19 response = requests.post(
20 "https://cognito-idp.eu-central-1.amazonaws.com",
21 headers={
22 "X-Amz-Target": "AWSCognitoIdentityProviderService.InitiateAuth",
23 "Content-Type": "application/x-amz-json-1.1",
24 },
25 data=json.dumps({
26 "AuthParameters": {"USERNAME": DISTIL_USERNAME, "PASSWORD": DISTIL_PASSWORD},
27 "AuthFlow": "USER_PASSWORD_AUTH",
28 "ClientId": "4569nvlkn8dm0iedo54nbta6fd",
29 })
30 )
31 response.raise_for_status()
32 return response.json()["AuthenticationResult"]["AccessToken"]

Use the token in the Authorization header for all API requests:

1response = requests.get(
2 "https://api.distillabs.ai/models",
3 headers={"Authorization": f"Bearer {distil_bearer_token()}"}
4)
5print(response.json())

API tokens are valid for 1 hour. Your code should handle re-authentication when needed.

Troubleshooting

  • 401 Unauthorized Error: Check that your username and password are correct.
  • 403 Forbidden Error: This typically means your token has expired. Generate a new token.
  • Connection Errors: Ensure you have proper network connectivity to the API endpoints.

For any account or authentication issues, please contact contact@distillabs.ai.