The Fleet Python SDK provides programmatic access to Fleet's environment infrastructure.
Install the Fleet SDK using pip:
pip install fleet-pythonTo install the latest alpha or pre-release version:
pip install --pre fleet-pythonTo install a specific alpha version:
pip install fleet-python==0.2.64-alpha1Fleet supports browser login for local CLI use and API keys for scripts, services, and CI.
For local CLI use:
flt loginThe CLI stores browser-login credentials in ~/.fleet/credentials.json and
sends JWT auth headers scoped to the selected team.
For API-key auth, obtain a key from the Fleet Platform and set:
export FLEET_API_KEY="sk_your_key_here"When both are present, FLEET_API_KEY takes precedence.
import fleet
import datetime
# Create environment by key
env = fleet.env.make("fira")
# Reset environment with seed and options
env.reset(
seed=42,
timestamp=int(datetime.datetime.now().timestamp())
)
# Access environment state ('current' is the resource id for a sqlite database)
sql = env.state("sqlite://current")
sql.exec("UPDATE customers SET status = 'active' WHERE id = 123")
# Clean up
env.close()# Create environment instance with explicit version
env = fleet.env.make("fira:v1.2.5")
# Create environment instance with default (latest) version
env = fleet.env.make("fira")# Connect to a running instance
env = fleet.env.get("env_instance_id")
# List all running instances
instances = fleet.env.list_instances()
for instance in instances:
print(f"Instance: {instance.instance_id}")
print(f"Type: {instance.environment_type}")
print(f"Status: {instance.status}")
# Filter instances by status (running, pending, stopped, error)
running_instances = fleet.env.list_instances(status_filter="running")
# List available environment types
available_envs = fleet.env.list_envs()