The TFrameX CLI provides a comprehensive command-line interface for building, running, and managing AI agent applications. After installing TFrameX, the tframex command becomes available globally.
pip install tframexAfter installation, verify the CLI is working:
tframex --helpThe TFrameX CLI provides three main commands:
tframex basic- Start an interactive AI sessiontframex setup <project>- Create a new TFrameX projecttframex serve- Launch a web interface
Starts an interactive session with a basic AI assistant using TFrameX's built-in chat system.
tframex basicFeatures:
- Interactive chat loop with agent switching
- Basic time tool included
- Automatic environment variable detection
- Graceful demo mode if no API keys are configured
- Built-in commands: 'exit', 'quit', 'switch'
Environment Variables: The command will look for LLM configuration in this order:
# OpenAI Configuration
OPENAI_API_KEY=your_openai_key
OPENAI_API_BASE=https://api.openai.com/v1 # Optional
OPENAI_MODEL_NAME=gpt-3.5-turbo # Optional
# Alternative: Llama/Other OpenAI-compatible APIs
LLAMA_API_KEY=your_llama_key
LLAMA_BASE_URL=https://api.llama.com/compat/v1/
LLAMA_MODEL=Llama-4-Maverick-17B-128E-Instruct-FP8Demo Mode: If no API keys are found, the command runs in demo mode with helpful guidance on configuration.
Creates a complete TFrameX project with proper structure and templates.
tframex setup myprojectOptions:
--template basic- Use basic project template (default)
Generated Project Structure:
myproject/
├── main.py # Main application entry point
├── config/
│ ├── __init__.py # Package initialization
│ ├── agents.py # Agent configurations
│ └── tools.py # Tool configurations
├── data/ # Data files and storage
├── docs/ # Documentation
├── requirements.txt # Python dependencies
├── .env.example # Environment template
├── .gitignore # Git ignore rules
└── README.md # Project documentation
Key Files Generated:
main.py:
- Complete application entry point
- Async main function with interactive chat
- Modular configuration loading
- Ready to run out of the box
config/agents.py:
- LLM configuration from environment variables
- Sample agent with proper system prompt
- Extensible agent registration pattern
- Support for multiple LLM providers
config/tools.py:
- Dynamic tool creation examples
- Time tool implementation
- Comments showing how to add custom tools
- Proper tool registration patterns
.env.example:
- Complete environment variable template
- Multiple LLM provider configurations
- Project-specific settings
- Security and deployment notes
requirements.txt:
- TFrameX dependency
- Common additional packages
- Comments for easy extension
README.md:
- Complete setup instructions
- Usage examples
- Project structure explanation
- Development guidance
Launches a web-based chat interface for TFrameX applications.
tframex serve [--host HOST] [--port PORT]Options:
--host- Host to bind to (default: localhost)--port- Port to bind to (default: 8000)
Examples:
# Default (localhost:8000)
tframex serve
# Custom port
tframex serve --port 3000
# Custom host and port
tframex serve --host 0.0.0.0 --port 8080Web Interface Features:
- Real-time chat interface
- Agent interaction through HTTP
- Session management
- Responsive design
- Error handling and status indicators
Requirements: The serve command requires Flask. Install with:
pip install tframex[web]API Endpoints:
GET /- Main chat interfacePOST /chat- Chat API endpoint
OpenAI:
export OPENAI_API_KEY="sk-..."
export OPENAI_MODEL_NAME="gpt-3.5-turbo" # OptionalLlama API:
export LLAMA_API_KEY="LLM|..."
export LLAMA_BASE_URL="https://api.llama.com/compat/v1/"
export LLAMA_MODEL="Llama-4-Maverick-17B-128E-Instruct-FP8"Other OpenAI-Compatible APIs:
export OPENAI_API_KEY="your_key"
export OPENAI_API_BASE="https://your-api-endpoint.com/v1"
export OPENAI_MODEL_NAME="your-model-name"For projects created with tframex setup:
-
Copy the template:
cd myproject cp .env.example .env -
Edit configuration:
nano .env # or your preferred editor -
Add to .gitignore (already included):
.env .env.local
# 1. Create new project
tframex setup my-ai-app
cd my-ai-app
# 2. Setup environment
cp .env.example .env
# Edit .env with your API keys
# 3. Install dependencies
pip install -r requirements.txt
# 4. Run interactive session
python main.py# Quick interactive session for testing
tframex basic
# Test web interface
tframex serve --port 3000# Create production project
tframex setup production-app
cd production-app
# Setup production environment
cp .env.example .env.production
# Configure production API keys and settings
# Install with web dependencies
pip install -r requirements.txt
pip install tframex[web]
# Run web server
tframex serve --host 0.0.0.0 --port 8080In your project's config/tools.py:
from tframex.util.tools import Tool, ToolParameters, ToolParameterProperty
def create_weather_tool():
def get_weather(city: str) -> str:
# Your weather API logic here
return f"Weather in {city}: Sunny, 25°C"
return Tool(
name="get_weather",
func=get_weather,
description="Get current weather for a city",
parameters_schema=ToolParameters(
properties={
"city": ToolParameterProperty(
type="string",
description="The city to get weather for"
)
},
required=["city"]
)
)
def setup_tools(app):
app.register_tool(create_weather_tool())In your project's config/agents.py:
def setup_agents(app):
# Configure LLM
llm = OpenAIChatLLM(...)
# Create specialized agents
research_agent = LLMAgent(
name="Researcher",
description="Research specialist",
llm=llm,
system_prompt="You are a research specialist..."
)
writer_agent = LLMAgent(
name="Writer",
description="Content writer",
llm=llm,
system_prompt="You are a professional writer..."
)
# Register agents
app.register_agent(research_agent)
app.register_agent(writer_agent)Add MCP servers to your project:
# In main.py
from tframex.mcp import MCPManager
async def create_app():
app = TFrameXApp()
# Setup MCP servers
mcp_config = {
"aws-docs": {
"command": "uvx",
"args": ["awslabs.aws-documentation-mcp-server@latest"]
}
}
mcp_manager = MCPManager(mcp_config)
app.set_mcp_manager(mcp_manager)
# Continue with agent/tool setup
return app1. Command not found: tframex
# Reinstall TFrameX
pip uninstall tframex
pip install tframex
# Check installation
which tframex2. Import errors in basic mode
# Check TFrameX installation
python -c "import tframex; print(tframex.__version__)"
# Reinstall if needed
pip install --upgrade tframex3. API key not recognized
# Check environment variables
echo $OPENAI_API_KEY
echo $LLAMA_API_KEY
# Set for current session
export OPENAI_API_KEY="your_key_here"4. Web server won't start
# Install web dependencies
pip install flask
# OR
pip install tframex[web]
# Check port availability
netstat -an | grep :80005. Project generation fails
# Check permissions
ls -la .
mkdir test && rmdir test
# Check available space
df -h .Enable debug logging for troubleshooting:
# Set log level
export TFRAMEX_LOG_LEVEL=DEBUG
# Run with debug output
tframex basicCLI Help:
tframex --help
tframex basic --help
tframex setup --help
tframex serve --helpDocumentation:
- Use the setup command - Always start with
tframex setupfor consistent structure - Environment files - Keep API keys in
.env, not in code - Modular configuration - Use separate files for agents and tools
- Documentation - Update README.md with project-specific instructions
- Start with basic - Use
tframex basicfor quick testing - Iterate on tools - Develop tools in
config/tools.pyfirst - Agent specialization - Create focused agents for specific tasks
- Web testing - Use
tframex servefor user interface testing
- Environment management - Use separate
.envfiles for different environments - Dependency locking - Pin specific versions in
requirements.txt - Error handling - Implement proper error handling in custom tools
- Monitoring - Add logging and metrics for production use
- API key management - Never commit
.envfiles - Input validation - Validate all tool parameters
- Rate limiting - Implement rate limiting for web interfaces
- Access control - Consider authentication for production web interfaces
After mastering the CLI basics:
- Explore Examples - Check out integration examples
- Advanced Patterns - Learn about execution patterns
- Enterprise Features - Explore enterprise capabilities
- MCP Integration - Add external tools via MCP servers
- Custom Development - Build specialized agents for your use case