Python SDK for Fleet environments
Project description
Fleet SDK
The Fleet Python SDK provides programmatic access to Fleet's environment infrastructure.
Installation
pip install fleet-python
API Key Setup
Get your API key from the Fleet Dashboard, then set it as an environment variable:
export FLEET_API_KEY="sk_your_key_here"
Tasks
A Task represents a unit of work for an agent to complete within an environment. Each task combines:
- Prompt: Instructions describing what needs to be done
- Environment: The environment configuration (
env_key,data_key,env_variables) - Verifier: Code that validates task completion and returns a score (0.0 to 1.0)
Tasks provide all the configuration needed to spin up an environment and verify an agent's work.
Task Properties
| Property | Description |
|---|---|
key |
Unique task identifier |
prompt |
Instructions for the agent |
env_key |
Environment identifier (e.g., "hubspot:v1.2") |
data_key |
Data configuration identifier |
env_variables |
Environment variables for the task |
metadata |
Additional info (e.g., avg_steps for task difficulty) |
Quick Start
import fleet
async def main():
# Load a task
tasks = await fleet.load_tasks_async(
keys=["task_abcdef"]
)
task = tasks[0]
# Create an environment from the task
env = await fleet.env.make_async(
env_key=task.env_key,
data_key=task.data_key,
env_variables=task.env_variables,
ttl_seconds=7200,
run_id="run-123",
)
# Access the environment URL
print(env.urls.app[0])
# ... interact with the environment ...
# Verify task completion
result = await task.verify_detailed_async(env.instance_id)
print(result)
# Clean up
await env.close()
Loading Tasks
By Task Keys
tasks = await fleet.load_tasks_async(
keys=["task_abcdef"]
)
By Project Key
tasks = await fleet.load_tasks_async(project_key="my-project")
Creating Environments
env = await fleet.env.make_async(
env_key=task.env_key,
data_key=task.data_key,
env_variables=task.env_variables,
ttl_seconds=7200,
run_id="run-123",
)
With Heartbeats (Optional)
Optionally enable heartbeats to keep environments alive during long-running operations:
env = await fleet.env.make_async(
env_key=task.env_key,
data_key=task.data_key,
env_variables=task.env_variables,
ttl_seconds=10800,
heartbeat_interval=30, # seconds
)
Send heartbeats to keep the environment alive:
# Via the environment object
await env.heartbeat()
# Or via instance ID
await fleet.env.heartbeat_async(instance_id)
Heartbeats are optional. If heartbeat_interval is not set, the instance lifetime is controlled solely by ttl_seconds. If heartbeats are enabled and missed 3 consecutive times, the instance will be terminated. Heartbeats take precedence over the TTL.
Instance Management
List Instances
# List all instances for a run
instances = await fleet.env.list_instances_async(run_id="run-123")
# List all instances for your profile
instances = await fleet.env.list_instances_async(profile_id="self")
Close Instances
# Close all instances for a run
await fleet.env.close_all_async(run_id="run-123")
# Close all instances for your profile
await fleet.env.close_all_async(profile_id="self")
# Close a specific instance by ID
await fleet.env.close_async("bc8954c2")
"self" is an alias for the profile associated with your FLEET_API_KEY.
Account Information
View your current account details including team info, instance limits, and profile ID:
account = await fleet.env.account_async()
Returns:
{
"team_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"team_name": "My Team",
"instance_limit": 32000,
"instance_count": 924,
"profile_id": "11111111-2222-3333-4444-555555555555",
"profile_name": "Jane Doe"
}
Run Tracking
Track active and past runs:
# List active runs
runs = await fleet.env.list_runs_async()
# List all runs (active and inactive)
runs = await fleet.env.list_runs_async(status="all")
# Filter by profile
runs = await fleet.env.list_runs_async(profile_id="self")
Returns:
[
{
"run_id": "run-123",
"running_count": 0,
"total_count": 4,
"first_created_at": "2025-10-24T09:48:47.152387",
"last_created_at": "2025-10-24T09:55:19.284294",
"profile_id": "11111111-2222-3333-4444-555555555555"
}
]
Task Verification
Verify task completion and get detailed results:
result = await task.verify_detailed_async(env.instance_id)
print(result)
Returns:
{
"key": "task_abcdef",
"version": 4,
"success": true,
"result": 1.0,
"error": null,
"execution_time_ms": 2291,
"stdout": ""
}
On failure, stdout contains detailed verification errors:
{
"key": "task_abcdef",
"version": 4,
"success": true,
"result": 0,
"error": null,
"execution_time_ms": 2291,
"stdout": "Verification errors: [\"Expected field to be 'value', got None\", \"Form not marked as complete\"]"
}
Complete Example
import fleet
import asyncio
async def main():
# Load tasks from a project
tasks = await fleet.load_tasks_async(project_key="my-project")
for task in tasks:
# Create environment
env = await fleet.env.make_async(
env_key=task.env_key,
data_key=task.data_key,
env_variables=task.env_variables,
ttl_seconds=7200,
run_id="my-evaluation-run",
)
try:
# Access the environment URL
print(env.urls.app[0])
# ... run your agent ...
# Verify task completion
result = await task.verify_detailed_async(env.instance_id)
print(f"Task {task.key}: score={result['result']}")
finally:
await env.close()
# Clean up all instances from this run
await fleet.env.close_all_async(run_id="my-evaluation-run")
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fleet_python-0.2.123.tar.gz.
File metadata
- Download URL: fleet_python-0.2.123.tar.gz
- Upload date:
- Size: 289.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bf308349ef6cd98224e577bc3489b384d39041f6550c038460bcd9045bbf3d6
|
|
| MD5 |
949f82db6210a3f058f7e30477062332
|
|
| BLAKE2b-256 |
bddcc13966734ea89da53c9c81006cfc04a8c3117763cfdae8b123bf7f034ff0
|
Provenance
The following attestation bundles were made for fleet_python-0.2.123.tar.gz:
Publisher:
publish-fleet-sdk.yml on fleet-ai/fleet-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fleet_python-0.2.123.tar.gz -
Subject digest:
5bf308349ef6cd98224e577bc3489b384d39041f6550c038460bcd9045bbf3d6 - Sigstore transparency entry: 1200543045
- Sigstore integration time:
-
Permalink:
fleet-ai/fleet-sdk@cae219a98107977f00ff7ab892a3ec3762f5f3d2 -
Branch / Tag:
refs/tags/fleet-python-v0.2.123 - Owner: https://github.com/fleet-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-fleet-sdk.yml@cae219a98107977f00ff7ab892a3ec3762f5f3d2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fleet_python-0.2.123-py3-none-any.whl.
File metadata
- Download URL: fleet_python-0.2.123-py3-none-any.whl
- Upload date:
- Size: 337.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66c92e75e1bc1adcf6efc0cc98795e3366779c715fb2bdd3ce14fb8addf8ddf5
|
|
| MD5 |
02663be427323a986a82fc84c3445d91
|
|
| BLAKE2b-256 |
33efaeefc2263354e5589a783628840e0cd6debad60a98de4e53997e271ca061
|
Provenance
The following attestation bundles were made for fleet_python-0.2.123-py3-none-any.whl:
Publisher:
publish-fleet-sdk.yml on fleet-ai/fleet-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fleet_python-0.2.123-py3-none-any.whl -
Subject digest:
66c92e75e1bc1adcf6efc0cc98795e3366779c715fb2bdd3ce14fb8addf8ddf5 - Sigstore transparency entry: 1200543087
- Sigstore integration time:
-
Permalink:
fleet-ai/fleet-sdk@cae219a98107977f00ff7ab892a3ec3762f5f3d2 -
Branch / Tag:
refs/tags/fleet-python-v0.2.123 - Owner: https://github.com/fleet-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-fleet-sdk.yml@cae219a98107977f00ff7ab892a3ec3762f5f3d2 -
Trigger Event:
push
-
Statement type: