Skip to main content

Python SDK

The FrootAI Python SDK (frootai) gives you programmatic access to the entire FrootAI knowledge base from any Python application โ€” search modules, browse plays, compare models, and estimate costs.

Installationโ€‹

pip install frootai

Quick Startโ€‹

from frootai import FrootAIClient

client = FrootAIClient()

# Search FROOT knowledge base
results = client.search_knowledge("RAG chunking strategies")
for r in results:
print(f"{r['module']}: {r['title']}")

# Get a specific module
module = client.get_module("R2")
print(module["title"]) # "RAG Architecture"

# List all solution plays
plays = client.list_plays()
print(f"{len(plays)} plays available")

API Referenceโ€‹

Knowledge & Modulesโ€‹

# Search across all 17 FROOT modules
results = client.search_knowledge(query: str, max_results: int = 5)

# Get full content of a specific module
module = client.get_module(module_id: str)
# module_id: F1, F2, F3, R1, R2, R3, O1-O6, T1-T3

# List all modules organized by FROOT layer
modules = client.list_modules()

# Look up an AI/ML term in the glossary
definition = client.lookup_term(term: str)

Solution Playsโ€‹

# List all solution plays
plays = client.list_plays(filter: str = None)

# Get detailed play information
play = client.get_play_detail(play_number: str)

# Semantic search for plays
matches = client.search_plays(query: str, top_k: int = 3)

# Compare plays side-by-side
comparison = client.compare_plays(plays: list[str])

Models & Costโ€‹

# Compare AI models for a use case
comparison = client.compare_models(use_case: str, priority: str = "quality")

# Get model catalog
catalog = client.get_model_catalog(category: str = "all")

# Estimate monthly Azure costs
estimate = client.estimate_cost(play: str, scale: str = "dev")

Build / Review / Tuneโ€‹

# Builder agent โ€” implementation guidelines
guidelines = client.agent_build(task: str)

# Reviewer agent โ€” security + quality checklist
review = client.agent_review(context: str = None)

# Tuner agent โ€” production readiness validation
validation = client.agent_tune(context: str = None)

# Run evaluation against thresholds
result = client.run_evaluation(scores: dict, thresholds: dict = None)

Usage Example: Evaluation Pipelineโ€‹

from frootai import FrootAIClient

client = FrootAIClient()

# Run evaluation
scores = {
"groundedness": 4.5,
"relevance": 3.8,
"coherence": 4.1,
"fluency": 4.6
}

result = client.run_evaluation(
scores=scores,
thresholds={"groundedness": 4.0, "relevance": 3.5}
)

print(f"Overall: {'PASS' if result['overall_pass'] else 'FAIL'}")
for metric in result["results"]:
status = "โœ…" if metric["passed"] else "โŒ"
print(f" {status} {metric['metric']}: {metric['score']}")

MCP Integrationโ€‹

The Python SDK also provides an MCP server wrapper:

pip install frootai-mcp
python -m frootai.mcp

This starts a Python MCP server exposing the same 25 tools as the Node.js MCP server.

Versionโ€‹

Current version: v4.0.0, synced with 100 plays and all primitives.

See Alsoโ€‹

  • npm SDK โ€” Node.js equivalent
  • MCP Server โ€” MCP protocol access
  • CLI โ€” command-line interface