User Tracking
The OpenRouter API supports User Tracking through the optional user parameter, allowing you to track your own user IDs and improve your application’s reporting capabilities.
What is User Tracking?
User tracking enables you to specify an arbitrary string identifier for your end-users in API requests. This optional metadata helps OpenRouter understand your sub-users.
How It Works
Simply include a user parameter in your API requests with any string identifier that represents your end-user. This could be a user ID, email hash, session identifier, or any other stable identifier you use in your application.
Implementation Example
Best Practices
Choose Stable Identifiers
Use consistent, stable identifiers for the same user across requests:
- Good:
user_12345,customer_abc123,account_xyz789 - Avoid: Random strings that change between requests
Consider Privacy
When using user identifiers, consider privacy implications:
- Use internal user IDs rather than exposing personal information
- Avoid including personally identifiable information in user identifiers
- Consider using anonymized identifiers for better privacy protection
Be Consistent
Use the same user identifier format throughout your application: