Creating Requests
Thewith()
method is the main way to set the parameters of the requests to LLM providers.
It accepts several parameters:
Basic Request Example
Here’s a simple example of creating a request:Request with Multiple Messages
For chat-based interactions, you can pass an array of messages:Using Messages
Class
You can also use the Messages
class to create message sequences more conveniently:
Message Formats
Polyglot supports different message formats depending on the provider:- String: A simple string will be converted to a user message
- Array of messages: Each message should have a
role
andcontent
field - Multimodal content: Some providers support images in messages
Cognesy\Messages\Utils\Image
class for easier conversion of image files to the message format.