How to beginner · 3 min read

How to use CrewAI for research automation

Quick answer
Use the CrewAI Python SDK or REST API to automate research tasks by sending queries and retrieving structured insights. Authenticate with your API key, then call client.research.query() to get summarized research outputs programmatically.

PREREQUISITES

  • Python 3.8+
  • CrewAI API key (sign up at CrewAI platform)
  • pip install crewai-sdk>=1.0

Setup

Install the official crewai-sdk Python package and set your API key as an environment variable for secure authentication.

bash
pip install crewai-sdk>=1.0

Step by step

This example demonstrates how to initialize the CrewAI client, send a research query, and print the summarized results.

python
import os
from crewai_sdk import CrewAI

# Initialize client with API key from environment
client = CrewAI(api_key=os.environ["CREWAI_API_KEY"])

# Define your research query
query_text = "Latest trends in renewable energy technologies"

# Send query to CrewAI research endpoint
response = client.research.query(query=query_text, max_results=3)

# Print summarized research insights
print("Research Summary:")
for idx, item in enumerate(response.results, 1):
    print(f"{idx}. {item.title}\n{item.summary}\n")
output
Research Summary:
1. Advances in solar panel efficiency
Solar photovoltaic cells have improved efficiency by 15% in the last 2 years...

2. Growth of offshore wind farms
Offshore wind capacity has doubled globally, driven by new turbine technologies...

3. Innovations in energy storage
Battery technologies such as solid-state batteries are enabling longer storage times...

Common variations

You can customize research automation by adjusting parameters like max_results, using asynchronous calls, or integrating CrewAI with other AI models for enhanced analysis.

python
import asyncio
from crewai_sdk import CrewAI

async def async_research():
    client = CrewAI(api_key=os.environ["CREWAI_API_KEY"])
    response = await client.research.query_async(query="AI impact on healthcare", max_results=2)
    for item in response.results:
        print(f"Title: {item.title}\nSummary: {item.summary}\n")

asyncio.run(async_research())
output
Title: AI-driven diagnostics improvements
Summary: AI algorithms have increased diagnostic accuracy in radiology by 20%...

Title: Personalized treatment plans
Summary: Machine learning models enable tailored therapies based on patient data...

Troubleshooting

  • If you get authentication errors, verify your CREWAI_API_KEY environment variable is set correctly.
  • For network timeouts, check your internet connection and retry the request.
  • If results are empty, try broadening your query or increasing max_results.

Key Takeaways

  • Use the official crewai-sdk Python package for seamless research automation.
  • Always secure your API key in environment variables, never hardcode it.
  • Leverage async methods for non-blocking research queries in larger applications.
Verified 2026-04 · crewai-sdk v1.0
Verify ↗