chat() method provides the simplest way to generate text responses. It returns just the text string, making it perfect for quick interactions.
Basic Usage
Method Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
prompt | String | The text prompt to respond to |
Returns
AString containing the generated response text.
Throws
SDKErrorif the SDK is not initializedSDKErrorif no LLM model is loadedSDKErrorif generation fails
Examples
Simple Q&A
Conversation Flow
Error Handling
When to Use chat() vs generate()
| Use Case | Method |
|---|---|
| Quick responses | chat() |
| Need performance metrics | generate() |
| Custom generation options | generate() |
| Real-time token display | generateStream() |
| Simple prototyping | chat() |
| Production with analytics | generate() |
SwiftUI Example
generate()
For detailed metrics and custom options, use generate() →