Python SDK Guide
Python SDK Guide
Learn how to integrate AgentWall with your Python agent frameworks.
Installation
Basic Usage
Simple Chat Completion
Run-Level Tracking
Track multi-step agent tasks with run IDs:
Streaming Responses
Handle streaming responses for real-time output:
LangChain Integration
Use AgentWall with LangChain:
CrewAI Integration
Use AgentWall with CrewAI agents:
Error Handling
Handle AgentWall-specific errors:
Budget Tracking
Monitor costs and budgets:
Best Practices
- Always use run IDs for multi-step tasks - Enables loop detection and cost tracking
- Handle 429 responses - Loop detection blocks requests with 429 status
- Set appropriate timeouts - LLM responses can take time
- Monitor costs - Track spending to stay within budget
- Use streaming for long responses - Better UX and real-time feedback
- Implement retry logic - Handle transient failures gracefully
Troubleshooting
Loop Detection Blocking Requests
If you see 429 Loop detected errors:
- Check if you're sending the same prompt repeatedly
- Use different run IDs for different tasks
- Verify your agent logic isn't stuck in a loop
Authentication Errors
If you see 401 Unauthorized:
- Verify your API key is correct
- Check the key hasn't been revoked
- Ensure the key is passed in the Authorization header
Timeout Issues
If requests timeout:
- Increase the timeout value
- Check your network connection
- Verify the API is responding (check
/healthendpoint)
Next Steps
- Check out LangChain Integration
- Read CrewAI Integration
- Explore API Reference