Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ The API supports multiple AI characters:

### Authentication

> Note: WebSocket calls may reject anonymous Firebase users. Prefer tokens from a logged-in web session.
> The client now also auto-runs `PUT /api/external/user` after auth (same as web app bootstrap).

```python
from sesame_ai import SesameAI, TokenManager

Expand All @@ -60,7 +63,7 @@ print(f"User ID: {lookup_response.local_id}")

# For easier token management, use TokenManager
token_manager = TokenManager(client, token_file="token.json")
id_token = token_manager.get_valid_token()
id_token = token_manager.get_valid_token(allow_anonymous=False)
```

### Voice Chat Example
Expand All @@ -75,7 +78,7 @@ import numpy as np
# Get authentication token using TokenManager
api_client = SesameAI()
token_manager = TokenManager(api_client, token_file="token.json")
id_token = token_manager.get_valid_token()
id_token = token_manager.get_valid_token(allow_anonymous=False)

# Connect to WebSocket (choose character: "Miles" or "Maya")
ws = SesameWebSocket(id_token=id_token, character="Maya")
Expand Down Expand Up @@ -178,6 +181,10 @@ Command-line options:
- `--output-device`: Output device index
- `--list-devices`: List audio devices and exit
- `--token-file`: Path to token storage file
- `--id-token`: Firebase ID token (or `SESAME_ID_TOKEN`)
- `--refresh-token`: Firebase refresh token (or `SESAME_REFRESH_TOKEN`)
- `--firebase-auth-json`: Firebase web auth JSON path/raw JSON (or `SESAME_FIREBASE_AUTH_JSON`)
- `--no-anonymous`: Disable anonymous fallback and require explicit token/auth JSON
- `--debug`: Enable debug logging

## API Reference
Expand All @@ -196,7 +203,9 @@ The main API client for authentication.
Manages authentication tokens with automatic refresh and persistence.

- `TokenManager(api_client=None, token_file=None)` - Create a token manager
- `get_valid_token(force_new=False)` - Get a valid token, refreshing if needed
- `get_valid_token(force_new=False, allow_anonymous=True)` - Get a valid token, refreshing if needed
- `set_tokens(id_token, refresh_token=None, ...)` - Inject tokens directly
- `load_firebase_auth_user(firebase_auth_user)` - Load tokens from Firebase web auth JSON
- `clear_tokens()` - Clear stored tokens

### SesameWebSocket
Expand Down Expand Up @@ -263,7 +272,8 @@ If you have trouble connecting:

1. Check your internet connection
2. Verify your authentication token is valid
3. Ensure the SesameAI service is available
3. If you see `Anonymous users not allowed`, pass `--id-token` (and optionally `--refresh-token`) or `--firebase-auth-json`
4. Ensure the SesameAI service is available

## Legal Disclaimer

Expand All @@ -279,4 +289,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file

If you find this project helpful, consider buying me a coffee!

<a href="https://buymeacoffee.com/ijub" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
<a href="https://buymeacoffee.com/ijub" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
Loading