Crews and kickoff

CrewAI · Essentials · 10 min

kickoff is the entry point for every crew run, and its output object holds everything you need afterwards.

A Crew groups agents and tasks and runs them:

crew = Crew(agents=[researcher, writer], tasks=[research, write])
result = crew.kickoff(inputs={"topic": "solar batteries"})

kickoff starts the run. The inputs dictionary fills every {placeholder} in agent and task text. If a placeholder has no matching input, the run fails, so keep names consistent.

By default the crew uses the sequential process: tasks run in the order of the list, one after another (the next lesson looks closer).

kickoff returns a CrewOutput:

  • result.raw: the final task's answer as text. str(result) gives the same.
  • result.tasks_output: a list with one TaskOutput per task, useful for debugging what each step produced.
  • result.token_usage: how many tokens were used, which tells you the cost of the run.
  • result.pydantic and result.json_dict: structured versions, when you ask for structured output (a later lesson).

Useful crew settings:

  • verbose=True prints progress for the whole crew.
  • max_rpm caps model requests per minute across all agents.
  • output_log_file="crew.log" saves logs to a file.

To run the same crew over many inputs, kickoff_for_each(inputs=[...]) runs it once per dictionary and returns a list of results. Async versions exist too for programs that handle many requests at once.

Example

from crewai import Agent, Crew, Task

writer = Agent(role="Copywriter", goal="Write punchy product copy",
               backstory="You write short, concrete marketing text.")
tagline = Task(description="Write one tagline for {product}.",
               expected_output="A single tagline under 10 words.", agent=writer)

crew = Crew(agents=[writer], tasks=[tagline], verbose=False)

result = crew.kickoff(inputs={"product": "a solar phone charger"})
print(result.raw)                      # Power from the sun, wherever you roam.
print(len(result.tasks_output))        # 1
print(result.token_usage.total_tokens) # e.g. 412

many = crew.kickoff_for_each(inputs=[{"product": "a tent"}, {"product": "a kayak"}])
print([r.raw for r in many])           # two taglines

Remember

  • Crew(agents, tasks).kickoff(inputs={...}) runs the crew
  • inputs fill {placeholders} in agents and tasks
  • CrewOutput has raw, tasks_output and token_usage

Watch out for

  • Forgetting an input for a placeholder used in a task, which makes kickoff fail before any agent runs.

Check yourself

  1. Where do you find what the second of three tasks produced after kickoff?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: docs.crewai.com/en/concepts/crews