JavaScript/TypeScript SDK Guide
JavaScript/TypeScript SDK Guide
Learn how to integrate AgentWall with your JavaScript/TypeScript agent frameworks.
Installation
Basic Usage
Simple Chat Completion
TypeScript Client
Run-Level Tracking
Track multi-step agent tasks:
Streaming with React
LangChain.js Integration
Error Handling
Budget Tracking
Best Practices
- Always use run IDs for multi-step tasks - Enables loop detection and cost tracking
- Handle streaming properly - Use async iterators for better performance
- Implement error boundaries - Catch and handle API errors gracefully
- Monitor costs - Track spending to stay within budget
- Use TypeScript - Better type safety and IDE support
- Implement retry logic - Handle transient failures with exponential backoff
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
Streaming Not Working
If streaming responses aren't working:
- Ensure
stream: trueis set in the payload - Check that your client supports streaming
- Verify the response body is readable
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
Next Steps
- Check out LangChain Integration
- Read API Reference
- Explore Concepts