Guide · Open source
How to use trae-agent: install, configure and run tasks
Updated · written with AI from the project's own documentation and checked against our catalogue data
Trae Agent is a command-line tool from ByteDance that takes plain-language instructions, such as fixing a bug or adding tests, and works through them using an LLM and tools for editing files and running bash commands. This guide shows you how to install it from source, configure a model provider, and run tasks on a local project. It is aimed at developers comfortable with the terminal and researchers who want to study or modify agent architectures.
Quick start
- 1Check prerequisites. Confirm Python 3.12 or newer and UV are installed, and that you have an API key or a local Ollama setup.
- 2Clone the repository. Run git clone on the bytedance/trae-agent repository and move into the trae-agent folder.
- 3Install dependencies. Run uv sync --all-extras to install the project and its extras with UV.
- 4Activate the environment. Run source .venv/bin/activate so the trae-cli command is available in your shell.
- 5Create your config. Copy trae_config.yaml.example to trae_config.yaml and add your provider API key and model settings.
- 6Run a task. Run trae-cli run with a plain-language instruction and optionally --working-dir to target your project.
What you need before installing Trae Agent
Trae Agent requires Python 3.12 or newer and UV, the Python package manager, which is linked from the project README at docs.astral.sh/uv. You also need an API key for your chosen model provider, or a local Ollama setup. Docker is only needed if you plan to use Docker mode.
- Python 3.12+
- UV (https://docs.astral.sh/uv/)
- An API key for your chosen model provider, or a local Ollama setup
- Docker (only for Docker mode)
Install Trae Agent from source
The README installs Trae Agent by cloning the repository and syncing dependencies with UV. Run these commands in order from your terminal, then activate the virtual environment so the trae-cli command is available.
git clone https://github.com/bytedance/trae-agent.git
cd trae-agent
uv sync --all-extras
source .venv/bin/activateConfigure a model provider with trae_config.yaml
The README recommends YAML configuration. Copy the example file to trae_config.yaml, then edit it with your credentials and preferences. The config file is ignored by git so your API keys stay out of version control. Under model_providers you define each provider and its api_key, and under models you choose which provider and model name the agent uses.
If your provider needs a custom endpoint, add a base_url field after provider. The README notes that only spaces are allowed for indentation in this file, and tabs are not permitted.
Configuration priority is: command-line arguments, then the configuration file, then environment variables, then defaults.
- Copy trae_config.yaml.example to trae_config.yaml
- Set api_key and provider under model_providers
- Set model_provider, model and token settings under models
- Keep trae_config.yaml out of git because it holds your keys
cp trae_config.yaml.example trae_config.yamlUse environment variables instead of a YAML file
If you prefer not to store keys in a file, the README shows environment variables for each supported provider, including OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_API_KEY, OPENROUTER_API_KEY and DOUBAO_API_KEY. Each has a matching _BASE_URL variable. The README mentions storing these in a .env file as an option.
export OPENAI_API_KEY="your-openai-api-key"
export ANTHROPIC_API_KEY="your-anthropic-api-key"Run your first task and check the configuration
Use trae-cli run with a plain-language task in quotes. Before running real work, you can confirm your setup with show-config. To start a conversational session instead, use interactive mode. Pass --working-dir to point the agent at a specific project folder, and --trajectory-file to save a log of its actions for review.
- trae-cli show-config checks the configuration
- trae-cli run "task" runs a single task
- trae-cli interactive opens a session where you type tasks and use status, help, clear and exit or quit
- --working-dir sets the project folder
- --trajectory-file saves the execution record
trae-cli show-config
trae-cli run "Create a hello world Python script"
trae-cli run "Add tests for utils module" --working-dir /path/to/project
trae-cli interactiveSwitch providers, including local Ollama models
You can override the provider and model per run with --provider and --model. The README lists examples for OpenAI, Anthropic, Google Gemini, OpenRouter, Doubao and Ollama. For Ollama, the model is a local model name such as qwen3, so you need a working local Ollama setup first.
Trae Agent also supports optional MCP services. The README shows a Playwright example under an mcp_servers section in the YAML file.
- OpenAI: --provider openai --model gpt-4o
- Anthropic: --provider anthropic --model claude-sonnet-4-20250514
- Google Gemini: --provider google --model gemini-2.5-flash
- Ollama: --provider ollama --model qwen3
trae-cli run "Comment this code" --provider ollama --model qwen3Run tasks in Docker mode
Docker mode runs tasks in a container. The README says you must make sure Docker is configured in your environment first. You can name a base image, attach to an existing container by ID, or build from a Dockerfile. Note that --working-dir cannot be combined with --docker-container-id.
By default the container is kept after the task; set --docker-keep false to remove it.
- --docker-image runs in a new container from an image
- --dockerfile-path builds an environment from a Dockerfile
- --docker-container-id attaches to an existing container
- --docker-image-file loads a local tar archive image
trae-cli run "Add tests for utils module" --docker-image python:3.11 --docker-keep falseWhat people use it for
- Asking the agent to fix a bug in a named file, such as main.py, with a chosen provider.
- Adding unit tests to a module in a local project folder using --working-dir.
- Running a task inside a Docker container to keep the environment isolated.
- Comparing how different model providers handle the same coding task by switching --provider and --model.
- Studying agent behaviour by reading trajectory files saved with --trajectory-file.
Frequently asked questions
Is trae-agent free to use?
The project is published under the MIT licence, as stated on its GitHub page. You still need an API key for your chosen model provider, or a local Ollama setup, and those providers may charge for usage. This guide does not cover provider pricing.
What do I need to install trae-agent?
You need Python 3.12 or newer, UV from docs.astral.sh/uv, and an API key or local Ollama setup. Docker is only required for Docker mode. Install from source by cloning the repository and running uv sync --all-extras.
Can I use trae-agent with Ollama and local models?
Yes. The README includes an example using --provider ollama with a local model such as qwen3. You must have Ollama set up on your machine before running it.
Is trae-agent an IDE or a command-line tool?
It is a command-line tool. The README describes a CLI and an interactive terminal mode, and does not describe a graphical IDE experience.
How does trae-agent compare to Aider, OpenHands, Cline or SWE-agent?
Trae Agent describes itself as a transparent, modular architecture aimed at researchers and developers who want to study or extend agent designs. The README does not compare it directly with the other tools, so check each project's own documentation to decide which fits your workflow.
Why does my trae-agent config fail to load?
The README says configuration fields must be indented with spaces only, because tabs are not allowed. Also check that your API key and provider names match the trae_config.yaml structure in the example file.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Trae Agent suits developers who want a scriptable terminal agent working on a local project, and researchers who want a modular base for studying agent architectures. Its README says the project is still under active development with no release listed, and it needs an API key or local Ollama setup to run. If you want a polished IDE experience or a stable release, pick a different tool.
Install options & downloads