Registry / llm-agents / truefoundry-sdk

truefoundry-sdk

JSON →
library0.4.0pypypi✓ verified 25d ago

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.

pip install truefoundry-sdk
INSTALL
IMPORT
SIG · TRUEFOUNDRY-SDK
T
truefoundry-sdk
llm-agentspythonv0.4.0
Install
4.7s avg
Import
3509ms
Disk
44MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 3.684s · 45.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 4.7s · import 3.334s · 45MB
44MB installed
● package 44MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TrueFoundry
✓ from truefoundry_sdk import TrueFoundry
Main client for interacting with TrueFoundry platform services like applications, users, etc.
get_client
✓ from truefoundry.ml import get_client
Used for ML-specific functionalities like experiment tracking and ML repositories.

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.")
Debug
Known issues
breakingThe `include_virtual_accounts` parameter has been removed from `client.users.list()`. Calling this method with the removed parameter will result in a `TypeError`.
fix
Remove the `include_virtual_accounts` argument from calls to `client.users.list()`.
affects: >=0.2.0
breakingSome type fields have been removed in version 0.2.0. Specific details on which fields are affected are not provided in the release notes snippet, but this indicates potential changes in data structures returned by the API.
fix
Review your code for usage of TrueFoundry SDK type fields and update according to the latest SDK documentation or by inspecting the new data structures if your code relies on them.
affects: >=0.2.0
gotchaThe TrueFoundry Python SDK is programmatically generated. Direct contributions or modifications to the library's source code will likely be overwritten in subsequent releases.
fix
For contributions, it is recommended to open an issue first to discuss changes. Contributions to the README are generally welcome and do not face this issue.
affects: All versions
gotchaThere are two main ways to interact: the `truefoundry_sdk.TrueFoundry` client for general platform interactions (applications, users) and `truefoundry.ml.get_client()` for ML-specific functionalities (experiment tracking, ML repositories). Using the wrong client for a specific task can lead to errors.
fix
Be mindful of which client (`TrueFoundry` from `truefoundry_sdk` or `get_client()` from `truefoundry.ml`) is appropriate for your desired interaction (e.g., platform management vs. ML experiment tracking).
affects: All versions
gotchaProper configuration of `api_key` and `base_url` is crucial. The `base_url` might vary depending on whether you are interacting with your TrueFoundry instance directly or through the TrueFoundry AI Gateway, especially when integrating with other SDKs like OpenAI or Anthropic.
fix
Always ensure your `api_key` is valid and your `base_url` correctly points to the intended TrueFoundry endpoint or Gateway. Use environment variables for sensitive credentials.
affects: All versions
Errors
Common errors & fixes
RuntimeError: TrueFoundry SDK is not configured. Please call tf.configure(...) first.
The TrueFoundry SDK client (`tf`) has not been initialized with the necessary configuration (host and token) before attempting to use other SDK functionalities.
fix
Call `tf.configure(host="YOUR_TRUEFOUNDRY_HOST", token="YOUR_AUTH_TOKEN")` at the beginning of your script, providing your TrueFoundry host URL and API token.
truefoundry.api.exceptions.TruefoundryAuthError: Authentication Failed. Please check your token or host.
The provided API token is incorrect, expired, or the host URL is wrong, preventing successful authentication with the TrueFoundry platform.
fix
Verify that the `token` and `host` provided to `tf.configure()` are correct and that the token is still valid. You might need to generate a new API token from your TrueFoundry account.
AttributeError: 'ML' object has no attribute 'log_metrics'
The method for logging metrics in the `tf.ml` object is `log_metric` (singular), not `log_metrics` (plural).
fix
Use the correct method name: `tf.ml.log_metric(...)`.
TypeError: 'int' object is not iterable (when passing ports to tf.service.create)
The `ports` argument in `tf.service.create()` expects a dictionary mapping port names (string) to port numbers (integer), but an integer was provided directly.
fix
Provide the `ports` argument as a dictionary, for example: `ports={"http": 8080}`.
Upgrade
Version history
0.4.0latest on PyPI · released Jul 3, 2026
Audit
Dependencies
pythonrequiredRequired Python version.
httpxrequiredUsed internally for HTTP requests and advanced client customization.
Agent activity
48 hits · last 30 days
node
40
OpenAI (training)
1
Resources