Skip to main content

Security Architecture

Why Token Provider?

Your organization’s API key never touches the browser for security reasons:
  • API Key Protection: Your Animus API key stays secure on your backend
  • User Authentication: You control who can access your AI services
  • Token Expiration: JWT tokens automatically expire for enhanced security
  • Audit Trail: Track usage through your own authentication system

Authentication Flow

Backend Implementation

Basic Token Provider Endpoint

Here’s how to implement a secure token provider endpoint in different backend frameworks:

Frontend Integration

Basic SDK Configuration

Once your backend is set up, configure the SDK to use your token provider:

User Authentication Integration

The SDK doesn’t have built-in user authentication features. Instead, you handle user authentication in your backend token provider endpoint. Here’s the recommended pattern:

Managing User Sessions

Since the SDK doesn’t handle user authentication directly, you’ll need to manage user sessions at the application level:

Advanced Authentication

Custom Token Storage

Control where Animus tokens are stored in the browser:

Token Refresh Handling

Token refresh happens automatically, but you can handle authentication errors:

Manual Token Management

Clear the stored Animus token when needed:
Note: The SDK doesn’t provide methods to check if a token exists or inspect token details. Token management is handled automatically, and you only need to clear tokens when necessary (e.g., on user logout).

CORS Configuration

Configure CORS properly for production:

Troubleshooting

Common Issues

Token Provider URL Not Found (404)
CORS Errors
Authentication Loops

Debug Mode

Enable debug logging to troubleshoot authentication issues:

Next Steps

Chat Completions

Start building chat features with secure authentication

Media & Vision

Add vision capabilities to your authenticated app

Tool Calling

Implement function calling with proper authentication

Event System

Handle authentication events in your application