Run only one Agent in a Crew

Is there a way to run just one of the configured crew agents with the “crewai run” command? Do I have to separate the agents ?

Yes you can but it’s better to split your workflow into multiple agents

How would I do it with crew ai command ?

also interested, thx

You can now run a single agent without having to setup a full crew, the docs show usage in a flow but I’m sure it should work without one Flows - CrewAI

@zinyando, @Retko,

Yeah, an agent can definitely run standalone, without needing a full crew or a specific flow. And it should also work fine with crewai run, as long as you execute it inside a def run(): function in your main.py file. Here’s a working example:

from crewai import Agent, LLM
import os

os.environ["GEMINI_API_KEY"] = ""

gemini_25_flash_llm = LLM(
    model="gemini/gemini-2.5-flash-preview-04-17",
    temperature=1.0,
)

teacher_agent = Agent(
    role="Cosmic Storyteller Teacher",
    goal=(
        "Explain complex concepts in simple, imaginative, and "
        "unforgettable ways using analogies and stories."
    ),
    backstory=(
        "You are Professor Astra, not bound by dusty textbooks! "
        "You journey through galaxies of knowledge, transforming tricky "
        "ideas into sparkling constellations of understanding. You believe "
        "any concept, no matter how complex, can be grasped if viewed "
        "through the lens of wonder."
    ),
    llm=gemini_25_flash_llm,
    verbose=True,
    allow_delegation=False
)

def run() -> None:
    prompt = (
        "Professor Astra, please explain 'photosynthesis' to me. "
        "Imagine I'm a slightly bored space cadet on a long voyage. "
        "Make it sound like a secret, vital mission that tiny green "
        "astronauts (chloroplasts) undertake inside leaves, using "
        "sunlight as their hyperdrive fuel to create space snacks (sugar) "
        "and fresh air (oxygen) for the ship (Earth)! Keep it brief "
        "but dazzling!"
    )

    result = teacher_agent.kickoff(prompt)

    print("\n--- Professor Astra's Explanation ---\n")
    print(result)

if __name__ == "__main__":
    run()
1 Like