Implementation:CrewAIInc CrewAI CrewOutput Model
| Knowledge Sources | |
|---|---|
| Domains | Data_Processing, Multi_Agent_Systems |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
Concrete data model for accessing crew execution results in multiple formats provided by the CrewAI framework.
Description
The CrewOutput class is a Pydantic model containing the final results of a crew execution. It provides access to the raw text output, optional Pydantic model, optional JSON dict, per-task outputs as a list of TaskOutput, and token usage metrics. It supports dictionary-style access via __getitem__ and string conversion.
Usage
Access CrewOutput fields after calling crew.kickoff(). Use .raw for text, .pydantic for typed model access, .json_dict for JSON, .tasks_output for per-task results, and .token_usage for cost tracking.
Code Reference
Source Location
- Repository: crewAI
- File: lib/crewai/src/crewai/crews/crew_output.py
- Lines: L13-61
Signature
class CrewOutput(BaseModel):
"""Class that represents the result of a crew."""
raw: str = Field(description="Raw output of crew", default="")
pydantic: BaseModel | None = Field(default=None)
json_dict: dict[str, Any] | None = Field(default=None)
tasks_output: list[TaskOutput] = Field(default=[])
token_usage: UsageMetrics = Field(default_factory=UsageMetrics)
@property
def json(self) -> str | None: ...
def to_dict(self) -> dict[str, Any]: ...
def __getitem__(self, key): ...
def __str__(self): ...
Import
from crewai.crews.crew_output import CrewOutput
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| raw | str | Yes | Raw text output from the crew (default: "") |
| pydantic | None | No | Pydantic model output if final task has output_pydantic |
| json_dict | None | No | JSON dict output if final task has output_json |
| tasks_output | list[TaskOutput] | No | Per-task output list |
| token_usage | UsageMetrics | No | Token consumption metrics |
Outputs
| Name | Type | Description |
|---|---|---|
| .raw | str | Raw text output |
| .pydantic | None | Typed Pydantic model |
| .json_dict | None | JSON dictionary |
| .json | None | Serialized JSON string |
| .tasks_output | list[TaskOutput] | Per-task outputs |
| .token_usage | UsageMetrics | Token usage (total_tokens, prompt_tokens, etc.) |
Usage Examples
Accessing Results
result = crew.kickoff(inputs={"topic": "AI"})
# Raw text
print(result.raw)
# Structured output (if output_pydantic was set on final task)
if result.pydantic:
report = result.pydantic
print(report.title)
# JSON output (if output_json was set on final task)
if result.json_dict:
print(result.json_dict["findings"])
# Per-task outputs
for task_output in result.tasks_output:
print(f"Task: {task_output.description}")
print(f"Result: {task_output.raw}")
# Token usage
print(f"Total tokens: {result.token_usage.total_tokens}")