CLI API Reference¶
Complete API reference for the RapidAI CLI tool.
Commands¶
rapidai¶
Main CLI entry point.
Options:
--version- Show the version and exit--help- Show help message and exit
Commands:
new- Create a new RapidAI projectdev- Run development serverdeploy- Deploy to cloud platformstest- Run testsdocs- Generate and serve documentation
new¶
Create a new RapidAI project from a template.
Arguments:
| Argument | Type | Required | Description |
|---|---|---|---|
PROJECT_NAME |
string | Yes | Name of the project to create |
Options:
| Option | Short | Type | Default | Description |
|---|---|---|---|---|
--template |
-t |
choice | chatbot |
Template to use (chatbot|rag|agent|api) |
--directory |
-d |
path | . |
Directory to create project in |
Return Codes:
0- Success1- Error (invalid name, directory exists, etc.)
Examples:
# Create chatbot project
rapidai new my-bot
# Create RAG project in specific directory
rapidai new doc-qa -t rag -d ~/projects
# Create API project
rapidai new my-api --template api
Template Details:
chatbot¶
Creates a chatbot application with conversation memory.
Generated Files:
app.py- Main application with chat endpoints.env- Environment variable templaterequirements.txt- Dependencies (rapidai, anthropic/openai)README.md- Project documentationtests/- Empty test directory
Endpoints:
POST /chat- Chat with memoryPOST /clear- Clear conversation history
rag¶
Creates a RAG application with document upload and Q&A.
Generated Files:
app.py- Main application with RAG endpoints.env- Environment variable templaterequirements.txt- Dependencies (rapidai[rag], anthropic/openai)README.md- Project documentationtests/- Empty test directorydocs/- Document storage directory
Endpoints:
POST /upload- Upload documentsPOST /ask- Ask questionsPOST /search- Search documents
agent¶
Creates an AI agent with analysis and generation capabilities.
Generated Files:
app.py- Main application with agent endpoints.env- Environment variable templaterequirements.txt- Dependencies (rapidai, anthropic/openai)README.md- Project documentationtests/- Empty test directory
Endpoints:
POST /analyze- Analyze textPOST /generate- Generate contentPOST /chat- Agent chat
api¶
Creates a REST API with authentication and CORS.
Generated Files:
app.py- Main application with API endpoints.env- Environment variable templaterequirements.txt- Dependencies (rapidai, anthropic/openai)README.md- Project documentationtests/- Empty test directory
Endpoints:
GET /- API informationPOST /complete- Complete promptsPOST /chat- Chat endpointGET /health- Health check
dev¶
Run the development server with hot reload.
Options:
| Option | Short | Type | Default | Description |
|---|---|---|---|---|
--port |
-p |
integer | 8000 |
Port to run server on |
--host |
-h |
string | 127.0.0.1 |
Host to bind server to |
--reload |
- | flag | True |
Enable auto-reload on file changes |
--no-reload |
- | flag | False |
Disable auto-reload |
--app |
-a |
string | app:app |
Application module path |
Return Codes:
0- Server stopped normally (Ctrl+C)1- Error (app file not found, uvicorn not installed, etc.)
Examples:
# Run with defaults
rapidai dev
# Custom port
rapidai dev -p 3000
# Custom host (allow external connections)
rapidai dev -h 0.0.0.0
# Disable auto-reload
rapidai dev --no-reload
# Custom app module
rapidai dev --app myapp:application
Behavior:
- Checks if app file exists
- Displays startup banner with URL and settings
- Starts Uvicorn server with specified options
- Watches files for changes if
--reloadis enabled - Stops on Ctrl+C
File Watching:
When --reload is enabled, watches:
*.pyfiles- Excludes:
*.pyc,__pycache__,.git
deploy¶
Deploy application to a cloud platform.
Arguments:
| Argument | Type | Required | Description |
|---|---|---|---|
PLATFORM |
choice | Yes | Cloud platform (fly|heroku|vercel|aws) |
Options:
| Option | Short | Type | Default | Description |
|---|---|---|---|---|
--app-name |
-n |
string | - | Application name for deployment |
--region |
-r |
string | - | Region to deploy to |
Return Codes:
0- Success1- Error (CLI not installed, deployment failed, etc.)
Examples:
# Deploy to Fly.io
rapidai deploy fly
# Deploy to Heroku with app name
rapidai deploy heroku -n my-app
# Deploy to Vercel in specific region
rapidai deploy vercel -r us-east-1
# AWS deployment instructions
rapidai deploy aws
Platform Details:
fly¶
Deploy to Fly.io.
Requirements:
flyctlCLI installed- Fly.io account
Behavior:
- Checks for
flyctlinstallation - Prompts for app name if not provided
- Generates
fly.tomlif not present - Runs
flyctl deploy - Displays deployment URL
Generated Files:
fly.toml- Fly.io configuration
Configuration:
app = "app-name"
primary_region = "iad" # if --region specified
[build]
builder = "paketobuildpacks/builder:base"
[env]
PORT = "8080"
[[services]]
internal_port = 8080
protocol = "tcp"
heroku¶
Deploy to Heroku.
Requirements:
herokuCLI installed- Heroku account
- Git repository
Behavior:
- Checks for
herokuCLI installation - Prompts for app name if not provided
- Generates
Procfileif not present - Creates Heroku app
- Sets Python buildpack
- Displays git push instructions
Generated Files:
Procfile- Heroku process configuration
Configuration:
vercel¶
Deploy to Vercel.
Requirements:
vercelCLI installed (npm)- Vercel account
Behavior:
- Checks for
vercelCLI installation - Generates
vercel.jsonif not present - Runs
vercel --prod - Displays deployment URL
Generated Files:
vercel.json- Vercel configuration
Configuration:
{
"builds": [{"src": "app.py", "use": "@vercel/python"}],
"routes": [{"src": "/(.*)", "dest": "app.py"}]
}
aws¶
AWS deployment instructions.
Behavior:
Displays manual deployment guide for:
- AWS Lambda + API Gateway (serverless)
- AWS ECS/Fargate (containers)
- AWS Elastic Beanstalk (platform)
No automatic deployment.
test¶
Run tests for the application.
Options:
| Option | Short | Type | Default | Description |
|---|---|---|---|---|
--coverage |
- | flag | True |
Run with coverage reporting |
--no-coverage |
- | flag | False |
Disable coverage reporting |
--verbose |
-v |
flag | False |
Verbose output |
Return Codes:
0- All tests passed1- Tests failed or pytest not found
Examples:
# Run with coverage
rapidai test
# Run without coverage
rapidai test --no-coverage
# Verbose output
rapidai test -v
# Combine options
rapidai test --no-coverage --verbose
Behavior:
- Checks for
pytestinstallation - Builds pytest command with options
- Runs tests
- Returns pytest exit code
Command Generated:
# With coverage (default)
pytest --cov=. --cov-report=term-missing
# Without coverage
pytest
# Verbose
pytest -v
docs¶
Generate and serve project documentation.
Options:
| Option | Short | Type | Default | Description |
|---|---|---|---|---|
--serve |
- | flag | True |
Serve documentation locally |
--build |
- | flag | False |
Build for production |
--port |
-p |
integer | 8001 |
Port to serve docs on |
Return Codes:
0- Success1- Error (mkdocs not installed, build failed, etc.)
Examples:
# Serve locally
rapidai docs
# Build for production
rapidai docs --build
# Custom port
rapidai docs -p 3000
Behavior:
- Checks for
mkdocsinstallation - Creates basic docs structure if missing
- Either serves or builds documentation
- Displays URL or build location
Serve Mode:
- Runs
mkdocs serve - Hot reloads on changes
- Accessible at
http://localhost:{port}
Build Mode:
- Runs
mkdocs build - Generates static site in
site/ - Ready for deployment
Configuration¶
Environment Variables¶
The CLI respects these environment variables:
| Variable | Description | Default |
|---|---|---|
DEBUG |
Enable debug mode | false |
RAPIDAI_* |
Any RapidAI configuration | - |
Config Files¶
Generated config files:
fly.toml- Fly.io configurationProcfile- Heroku configurationvercel.json- Vercel configuration
Error Handling¶
Common Errors¶
"Application file not found"
"pytest not found"
"mkdocs not found"
"Directory already exists"
# Solution: Choose a different name or directory
rapidai new my-project-v2
# or
rm -rf my-project # if you want to overwrite
Exit Codes¶
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error |
| 2 | Invalid usage |
See Also¶
- CLI Guide - Complete usage guide with examples
- Configuration - Environment variable configuration
- Deployment - Deployment best practices