CLI
Overview
Section titled “Overview”The CrewAI CLI provides a set of commands to interact with CrewAI, allowing you to create, train, run, and manage crews & flows.
Installation
Section titled “Installation”To use the CrewAI CLI, make sure you have CrewAI installed:
pip install crewaiBasic Usage
Section titled “Basic Usage”The basic structure of a CrewAI CLI command is:
crewai [COMMAND] [OPTIONS] [ARGUMENTS]Available Commands
Section titled “Available Commands”1. Create
Section titled “1. Create”Create a new crew or flow.
crewai create [OPTIONS] TYPE NAMETYPE: Choose between “crew” or “flow”NAME: Name of the crew or flow
Example:
crewai create crew my_new_crewcrewai create flow my_new_flowBy default, crewai create crew creates a JSON-first crew project with crew.jsonc and agents/*.jsonc. Use crewai create crew my_new_crew --classic only when you want the older Python/YAML scaffold with crew.py, config/agents.yaml, and config/tasks.yaml.
2. Version
Section titled “2. Version”Show the installed version of CrewAI.
crewai version [OPTIONS]--tools: (Optional) Show the installed version of CrewAI tools
Example:
crewai versioncrewai version --tools3. Train
Section titled “3. Train”Train the crew for a specified number of iterations.
crewai train [OPTIONS]-n, --n_iterations INTEGER: Number of iterations to train the crew (default: 5)-f, --filename TEXT: Path to a custom file for training (default: “trained_agents_data.pkl”)
Example:
crewai train -n 10 -f my_training_data.pkl4. Replay
Section titled “4. Replay”Replay the crew execution from a specific task.
crewai replay [OPTIONS]-t, --task_id TEXT: Replay the crew from this task ID, including all subsequent tasks
Example:
crewai replay -t task_1234565. Log-tasks-outputs
Section titled “5. Log-tasks-outputs”Retrieve your latest crew.kickoff() task outputs.
crewai log-tasks-outputs6. Reset-memories
Section titled “6. Reset-memories”Reset the crew memories (long, short, entity, latest_crew_kickoff_outputs).
crewai reset-memories [OPTIONS]-l, --long: Reset LONG TERM memory-s, --short: Reset SHORT TERM memory-e, --entities: Reset ENTITIES memory-k, --kickoff-outputs: Reset LATEST KICKOFF TASK OUTPUTS-kn, --knowledge: Reset KNOWLEDGE storage-akn, --agent-knowledge: Reset AGENT KNOWLEDGE storage-a, --all: Reset ALL memories
Example:
crewai reset-memories --long --shortcrewai reset-memories --all7. Test
Section titled “7. Test”Test the crew and evaluate the results.
crewai test [OPTIONS]-n, --n_iterations INTEGER: Number of iterations to test the crew (default: 3)-m, --model TEXT: LLM Model to run the tests on the Crew (default: “gpt-4o-mini”)
Example:
crewai test -n 5 -m gpt-3.5-turbo8. Run
Section titled “8. Run”Run the crew or flow.
crewai run9. Chat
Section titled “9. Chat”Starting in version 0.98.0, when you run the crewai chat command, you start an interactive session with your crew. The AI assistant will guide you by asking for necessary inputs to execute the crew. Once all inputs are provided, the crew will execute its tasks.
After receiving the results, you can continue interacting with the assistant for further instructions or questions.
crewai chat10. Deploy
Section titled “10. Deploy”Deploy the crew or flow to CrewAI AMP.
-
Authentication: You need to be authenticated to deploy to CrewAI AMP. You can login or create an account with:
Terminal window crewai login -
Create a deployment: Once you are authenticated, you can create a deployment for your crew or flow from the root of your localproject.
Terminal window crewai deploy create- Reads your local project configuration.
- Prompts you to confirm the environment variables (like
OPENAI_API_KEY,SERPER_API_KEY) found locally. These will be securely stored with the deployment on the Enterprise platform. Ensure your sensitive keys are correctly configured locally (e.g., in a.envfile) before running this.
11. Organization Management
Section titled “11. Organization Management”Manage your CrewAI AMP organizations.
crewai org [COMMAND] [OPTIONS]Commands:
Section titled “Commands:”list: List all organizations you belong to
crewai org listcurrent: Display your currently active organization
crewai org currentswitch: Switch to a specific organization
crewai org switch <organization_id>-
Create a deployment (continued):
- Links the deployment to the corresponding remote GitHub repository (it usually detects this automatically).
-
Deploy the Crew: Once you are authenticated, you can deploy your crew or flow to CrewAI AMP.
Terminal window crewai deploy push- Initiates the deployment process on the CrewAI AMP platform.
- Upon successful initiation, it will output the Deployment created successfully! message along with the Deployment Name and a unique Deployment ID (UUID).
-
Deployment Status: You can check the status of your deployment with:
Terminal window crewai deploy statusThis fetches the latest deployment status of your most recent deployment attempt (e.g.,
Building Images for Crew,Deploy Enqueued,Online). -
Deployment Logs: You can check the logs of your deployment with:
Terminal window crewai deploy logsThis streams the deployment logs to your terminal.
-
List deployments: You can list all your deployments with:
Terminal window crewai deploy listThis lists all your deployments.
-
Delete a deployment: You can delete a deployment with:
Terminal window crewai deploy removeThis deletes the deployment from the CrewAI AMP platform.
-
Help Command: You can get help with the CLI with:
Terminal window crewai deploy --helpThis shows the help message for the CrewAI Deploy CLI.
Watch this video tutorial for a step-by-step demonstration of deploying your crew to CrewAI AMP using the CLI.
11. Login
Section titled “11. Login”Authenticate with CrewAI AMP using a secure device code flow (no email entry required).
crewai loginWhat happens:
- A verification URL and short code are displayed in your terminal
- Your browser opens to the verification URL
- Enter/confirm the code to complete authentication
Notes:
- The OAuth2 provider and domain are configured via
crewai config(defaults uselogin.crewai.com) - After successful login, the CLI also attempts to authenticate to the Tool Repository automatically
- If you reset your configuration, run
crewai loginagain to re-authenticate
12. API Keys
Section titled “12. API Keys”When running the crewai create crew command, the CLI shows a list of available LLM providers, followed by model selection for your chosen provider. The selected model is saved in the generated .env file and each generated agent JSONC file can set its own llm.
Once you’ve selected an LLM provider and model, you will be prompted for API keys.
Available LLM Providers
Section titled “Available LLM Providers”Here’s a list of the most popular LLM providers suggested by the CLI:
- OpenAI
- Groq
- Anthropic
- Google Gemini
- SambaNova
When you select a provider, the CLI will then show you available models for that provider and prompt you to enter your API key.
Other Options
Section titled “Other Options”If you select “other”, you will be able to select from a list of LiteLLM supported providers.
When you select a provider, the CLI will prompt you to enter the Key name and the API key.
See the following link for each provider’s key name:
13. Configuration Management
Section titled “13. Configuration Management”Manage CLI configuration settings for CrewAI.
crewai config [COMMAND] [OPTIONS]Commands:
Section titled “Commands:”list: Display all CLI configuration parameters
crewai config listset: Set a CLI configuration parameter
crewai config set <key> <value>reset: Reset all CLI configuration parameters to default values
crewai config resetAvailable Configuration Parameters
Section titled “Available Configuration Parameters”enterprise_base_url: Base URL of the CrewAI AMP instanceoauth2_provider: OAuth2 provider used for authentication (e.g., workos, okta, auth0)oauth2_audience: OAuth2 audience value, typically used to identify the target API or resourceoauth2_client_id: OAuth2 client ID issued by the provider, used during authentication requestsoauth2_domain: OAuth2 provider’s domain (e.g., your-org.auth0.com) used for issuing tokens
Examples
Section titled “Examples”Display current configuration:
crewai config listExample output:
| Setting | Value | Description |
|---|---|---|
| enterprise_base_url | https://app.crewai.com | Base URL of the CrewAI AMP instance |
| org_name | Not set | Name of the currently active organization |
| org_uuid | Not set | UUID of the currently active organization |
| oauth2_provider | workos | OAuth2 provider (e.g., workos, okta, auth0) |
| oauth2_audience | client_01YYY | Audience identifying the target API/resource |
| oauth2_client_id | client_01XXX | OAuth2 client ID issued by the provider |
| oauth2_domain | login.crewai.com | Provider domain (e.g., your-org.auth0.com) |
Set the enterprise base URL:
crewai config set enterprise_base_url https://my-enterprise.crewai.comSet OAuth2 provider:
crewai config set oauth2_provider auth0Set OAuth2 domain:
crewai config set oauth2_domain my-company.auth0.comReset all configuration to defaults:
crewai config reset14. Trace Management
Section titled “14. Trace Management”Manage trace collection preferences for your Crew and Flow executions.
crewai traces [COMMAND]Commands:
Section titled “Commands:”enable: Enable trace collection for crew/flow executions
crewai traces enabledisable: Disable trace collection for crew/flow executions
crewai traces disablestatus: Show current trace collection status
crewai traces statusHow Tracing Works
Section titled “How Tracing Works”Trace collection is controlled by checking three settings in priority order:
-
Explicit flag in code (highest priority - can enable OR disable):
crew = Crew(agents=[...], tasks=[...], tracing=True) # Always enablecrew = Crew(agents=[...], tasks=[...], tracing=False) # Always disablecrew = Crew(agents=[...], tasks=[...]) # Check lower priorities (default)tracing=Truewill always enable tracing (overrides everything)tracing=Falsewill always disable tracing (overrides everything)tracing=Noneor omitted will check lower priority settings
-
Environment variable (second priority):
CREWAI_TRACING_ENABLED=true- Checked only if
tracingis not explicitly set toTrueorFalsein code - Set to
trueor1to enable tracing
- Checked only if
-
User preference (lowest priority):
Terminal window crewai traces enable- Checked only if
tracingis not set in code andCREWAI_TRACING_ENABLEDis not set totrue - Running
crewai traces enableis sufficient to enable tracing by itself
- Checked only if