Skip to content

Quick Start

Let’s build your first langcrew application! In this tutorial, we’ll create a simple content creation crew with two agents working together.

  • Python 3.10+
  • An LLM API key (OpenAI, Anthropic, DashScope, or Google)

Quick installation with pip:

Terminal window
pip install langcrew
export OPENAI_API_KEY=your_openai_key

A content creation system where:

  1. A Researcher agent gathers information on a topic
  2. A Writer agent creates an article based on the research
from langcrew import Agent, Task, Crew
from langchain_openai import ChatOpenAI
# Configure LLM
llm = ChatOpenAI(model="gpt-4o")
researcher = Agent(
role="Senior Research Analyst",
goal="Gather comprehensive information on the given topic",
backstory="""You are an experienced researcher with a keen eye for
credible sources and relevant information. You excel at finding and
synthesizing data from multiple sources.""",
tools=["web_search", "web_fetch"], # Built-in tools
llm=llm,
verbose=True
)
writer = Agent(
role="Content Writer",
goal="Create engaging and informative content based on research",
backstory="""You are a skilled writer who transforms research into
compelling narratives. You have a talent for making complex topics
accessible to readers.""",
llm=llm,
verbose=True
)
research_task = Task(
description="""Research the topic: 'The Impact of AI on Healthcare'
Your research should include:
- Current applications of AI in healthcare
- Benefits and challenges
- Future possibilities
- Real-world examples and case studies
Provide a comprehensive research summary.""",
agent=researcher,
expected_output="A detailed research report on AI in healthcare"
)
writing_task = Task(
description="""Using the research provided, write an engaging article
about 'The Impact of AI on Healthcare'.
The article should:
- Have a compelling introduction
- Cover key points from the research
- Include specific examples
- Be approximately 500 words
- End with a thought-provoking conclusion""",
agent=writer,
context=[research_task], # This task depends on research_task
expected_output="A well-written article on AI in healthcare"
)
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
verbose=True
)
# Start the crew's work
result = crew.kickoff()
# Display the final result
print("=" * 50)
print("FINAL ARTICLE:")
print("=" * 50)
print(result)
from langcrew import Agent, Task, Crew
from langchain_openai import ChatOpenAI
# Configure LLM
llm = ChatOpenAI(model="gpt-4o")
# Create agents
researcher = Agent(
role="Senior Research Analyst",
goal="Gather comprehensive information on the given topic",
backstory="""You are an experienced researcher with a keen eye for
credible sources and relevant information.""",
tools=["web_search", "web_fetch"],
llm=llm,
verbose=True
)
writer = Agent(
role="Content Writer",
goal="Create engaging and informative content",
backstory="""You are a skilled writer who transforms research into
compelling narratives.""",
llm=llm,
verbose=True
)
# Define tasks
research_task = Task(
description="Research the topic: 'The Impact of AI on Healthcare'",
agent=researcher,
expected_output="A detailed research report"
)
writing_task = Task(
description="Write an engaging article based on the research",
agent=writer,
context=[research_task],
expected_output="A well-written article"
)
# Create and run crew
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
verbose=True
)
result = crew.kickoff()
print(result)
from langcrew_tools.hitl import UserInputTool
agent = Agent(
role="Interactive Agent",
tools=[UserInputTool()],
# ... other parameters
)
from langcrew.tools import tool
@tool
def custom_calculator(expression: str) -> str:
"""Evaluate a mathematical expression."""
try:
result = eval(expression)
return f"The result is: {result}"
except Exception as e:
return f"Error: {str(e)}"
agent = Agent(
tools=[custom_calculator],
# ... other parameters
)
  1. Start Simple: Begin with 2-3 agents and gradually add complexity
  2. Clear Roles: Give each agent a specific, well-defined role
  3. Task Dependencies: Use context to share information between tasks
  4. Iterate: Refine agent prompts and task descriptions based on results
  5. Monitor Output: Use verbose mode during development to understand agent behavior

Ready to build more complex crews? Check out our advanced examples!