# π― Quick Reference: AgentOps + CrewAI Integration
## β
What Was Fixed
| Issue | Solution |
|-------|----------|
| Trace Not Found on Dashboard | Initialize AgentOps BEFORE crew creation |
| API Key Format Error | Removed quotes from `.env` file |
| 401 Upload Error | Expected on free tier - basic tracking still works |
| Missing Session Data | Added proper `end_trace()` call |
## π Working Configuration
### .env File (NO QUOTES!)
```bash
AGENTOPS_API_KEY=your-api-key-here
GROQ_API_KEY=your-groq-key-here
```
### Initialization Order (CRITICAL!)
```python
# 1οΈβ£ Load environment
load_dotenv(override=True)
# 2οΈβ£ Initialize AgentOps FIRST
agentops.init(
api_key=os.getenv("AGENTOPS_API_KEY"),
default_tags=["crewai", "market-analysis"],
auto_start_session=True
)
# 3οΈβ£ Create crew AFTER
my_crew = YourCrewName().crew()
# 4οΈβ£ Run crew
result = my_crew.kickoff()
# 5οΈβ£ End trace
agentops.end_trace("Success")
```
## π Your Session URLs
- **Latest**: https://app.agentops.ai/sessions?trace_id=d06785f5e765a308689e2b958ddbe386
- **Dashboard**: https://app.agentops.ai/sessions
## π Quick Diagnostics
```bash
# Test AgentOps connection
python test_agentops.py
# Run main script
python crewai_agentops_integradtion.py
```
## β οΈ Known Limitations (Free Tier)
- β
Session creation: **WORKS**
- β
Basic tracking: **WORKS**
- β
Trace URLs: **WORKS**
- β οΈ Detailed metrics upload: **LIMITED** (401 errors are normal)
## π Key Learnings
1. **Order matters**: AgentOps β Crew β Kickoff β End
2. **No quotes in .env**: Quotes break API key parsing
3. **Use `end_trace()`**: `end_session()` is deprecated
4. **401 is OK**: Free tier limitation, not a critical error
5. **Tags help**: Use meaningful tags for filtering
## π Files in This Project
- `crewai_agentops_integradtion.py` - Main script (FIXED β
)
- `test_agentops.py` - Diagnostic tool
- `AGENTOPS_FIX_GUIDE.md` - Detailed documentation
- `FIX_SUMMARY.md` - OpenAI quota fix
- `.env` - Environment variables (FIXED β
)
## π If Dashboard Still Shows "Trace Not Found"
1. **Check project selector** on AgentOps dashboard
2. **Wait 30-60 seconds** for processing
3. **Hard refresh** browser (Ctrl+Shift+R)
4. **Verify API key** matches selected project
5. **Run diagnostic**: `python test_agentops.py`
---
**Status**: β
**WORKING** - Both OpenAI quota and AgentOps issues resolved!