TrueFoundry SDK

0.2.0 · active · verified Sun Apr 12

The TrueFoundry Python SDK provides convenient access to the TrueFoundry API, enabling users to programmatically interact with the platform. It supports managing applications, deployments, workspaces, and offers capabilities for ML experiment tracking and interacting with ML repositories. The SDK is currently at version 0.2.0 and has an active release cadence, with frequent updates. It is designed to work with the TrueFoundry MLOps platform, which includes an AI Gateway, deployment tools, and observability features.

Warnings

Install

Imports

Quickstart

Initializes the TrueFoundry client using an API key and base URL. It then demonstrates how to list applications within a specified workspace. Remember to replace placeholder values with your actual TrueFoundry API key and workspace FQN, preferably by using environment variables.

import os
from truefoundry_sdk import TrueFoundry

# It's recommended to store API keys securely, e.g., via environment variables.
API_KEY = os.environ.get('TRUEFOUNDRY_API_KEY', 'YOUR_TRUEFOUNDRY_API_KEY')
# The base_url should point to your TrueFoundry instance or Gateway.
BASE_URL = os.environ.get('TRUEFOUNDRY_BASE_URL', 'https://api.truefoundry.com')

if API_KEY == 'YOUR_TRUEFOUNDRY_API_KEY':
    print("Warning: Please replace 'YOUR_TRUEFOUNDRY_API_KEY' with your actual API key or set the TRUEFOUNDRY_API_KEY environment variable.")
if BASE_URL == 'https://api.truefoundry.com':
    print("Note: Using default TrueFoundry API base URL. Adjust TRUEFOUNDRY_BASE_URL if needed.")

client = TrueFoundry(
    api_key=API_KEY,
    base_url=BASE_URL,
)

try:
    # Example: List applications in a workspace
    # Replace 'your-workspace-fqn' with an actual workspace FQN from your TrueFoundry setup
    applications_page = client.applications.list(workspace_fqn='your-workspace-fqn', limit=1)
    print(f"Found {len(applications_page.items)} application(s) in workspace 'your-workspace-fqn'.")
    if applications_page.items:
        print(f"First application name: {applications_page.items[0].name}")
except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure 'your-workspace-fqn' is a valid workspace and your API key and base URL are correct.")

view raw JSON →