Account and authentication
This guide explains how to set up your distil labs account and authenticate against the platform.
Registration
Section titled “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:
distil register
Using the web app:
Visit app.distillabs.ai/sign-up and follow the sign-up process.
CLI authentication
Section titled “CLI authentication”Once you have an account, log in using the CLI:
distil login
You can verify your identity with:
distil whoami
To log out:
distil logout
API authentication
Section titled “API authentication”If you need to interact with the distil labs API directly, you can obtain an API token using your username and password:
import os
import json
import requests
DISTIL_USERNAME = os.environ.get("DISTIL_USERNAME", "")
DISTIL_PASSWORD = os.environ.get("DISTIL_PASSWORD", "")
if not DISTIL_USERNAME or not DISTIL_PASSWORD:
raise ValueError("DISTIL_USERNAME and DISTIL_PASSWORD must be set")
def distil_bearer_token() -> str:
"""
Get an authentication token from the distil labs API
Returns:
str: Authentication token for API requests
"""
response = requests.post(
"https://cognito-idp.eu-central-1.amazonaws.com",
headers={
"X-Amz-Target": "AWSCognitoIdentityProviderService.InitiateAuth",
"Content-Type": "application/x-amz-json-1.1",
},
data=json.dumps({
"AuthParameters": {"USERNAME": DISTIL_USERNAME, "PASSWORD": DISTIL_PASSWORD},
"AuthFlow": "USER_PASSWORD_AUTH",
"ClientId": "4569nvlkn8dm0iedo54nbta6fd",
})
)
response.raise_for_status()
return response.json()["AuthenticationResult"]["AccessToken"]
Use the token in the Authorization header for all API requests:
response = requests.get(
"https://api.distillabs.ai/models",
headers={"Authorization": f"Bearer {distil_bearer_token()}"}
)
print(response.json())
API tokens are valid for 1 hour. Your code should handle re-authentication when needed.
Troubleshooting
Section titled “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.