Initialization
Initialize Early
Initialize the SDK at app launch, not when first needed:Pre-load Models
Load models during onboarding or splash screen:Memory Management
Unload When Not Needed
Free memory by unloading unused models:Monitor Memory
Handle Memory Warnings
Model Selection
Choose Appropriate Model Sizes
| Device | Recommended LLM | Notes |
|---|---|---|
| iPhone 12/13 (4GB) | 1B Q4 | May need to unload others |
| iPhone 14/15 (6GB) | 1-3B Q4 | Good for most use cases |
| iPhone 15 Pro (8GB) | 3B Q4, some 7B | More headroom |
| iPad Pro | 3-7B Q4 | Depends on RAM |
| M1+ Mac | 7B+ Q4 | Ample memory |
Device-Specific Loading
Streaming for Responsiveness
Always Stream for Long Outputs
Batch UI Updates
Threading
Use Appropriate Actors
Don’t Block the Main Thread
Error Recovery
Implement Retries
Graceful Fallbacks
Storage
Check Before Downloads
Clean Up Regularly
Event Handling
Subscribe to Events
Testing
Use Development Environment
Mock for Unit Tests
Quick Reference
| Scenario | Recommendation |
|---|---|
| App launch | Initialize SDK, register modules |
| Before first use | Pre-load models |
| Long text generation | Use streaming |
| Low memory devices | Use smaller models, unload when done |
| Voice features | Use Voice Agent for full pipeline |
| Production | Set log level to .warning |
| Errors | Implement retries and fallbacks |
| Background | Unload models to free memory |