Getting Responses
There are multiple ways to interact with your agent and get responses.Using for(): Named Sessions
Use for() to specify a chat session identifier. This enables conversation persistence based on your configured history storage:
Using forUser(): User-Specific Sessions
Pass a Laravel Authenticatable object directly to create user-specific sessions:
Using ask(): Quick One-Off
For simple, stateless interactions where you donβt need conversation history:
ask() uses in-memory history thatβs discarded after the response. Perfect for single-turn interactions.Using make(): Instance Without Session
Create an agent instance without a named session:
Chainable Methods
Build complex requests using the fluent API:Setting the Message
Using UserMessage Objects
For more control, create aUserMessage instance with metadata and bypass prompt processing:
Response Types
By default,respond() returns different types based on your configuration:
Getting the Raw Message Object
To get the fullAssistantMessage object instead of just the content:
Multimodal Input
Images
Pass image URLs or base64-encoded images for vision-capable models:Audio
Pass base64-encoded audio for audio-capable models:Runtime Mutators
Override agent configuration for specific requests:withModel() β Change model
withModel() β Change model
temperature() β Adjust creativity
temperature() β Adjust creativity
maxCompletionTokens() β Limit response length
maxCompletionTokens() β Limit response length
withTool() β Add tool at runtime
withTool() β Add tool at runtime
removeTool() β Remove tool for this request
removeTool() β Remove tool for this request
addMessage() β Inject message into history
addMessage() β Inject message into history
clear() β Reset conversation history
clear() β Reset conversation history
Accessors
Inspect agent state and retrieve information:getChatSessionId() β Get session identifier
getChatSessionId() β Get session identifier
chatHistory() β Access chat history
chatHistory() β Access chat history
lastMessage() β Get last message
lastMessage() β Get last message
currentMessage() β Get message being processed
currentMessage() β Get message being processed
getTools() β List registered tools
getTools() β List registered tools
getChatKeys() β Get all session keys
getChatKeys() β Get all session keys
getProviderName() β Get provider name
getProviderName() β Get provider name

