Essentials
Creating Requests
Learn how to create requests to LLM providers using Polyglot.
This section covers how to create requests to LLM providers using the Polyglot library. It includes examples of basic requests, handling multiple messages, and using different message formats.
Creating Requests
The create()
method is the main way to send 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:
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
Example with image (for providers that support it):