LlmServiceManager 

The central service for all LLM operations.

class LlmServiceManager
Fully qualified name
\Netresearch\NrLlm\Service\LlmServiceManager

Orchestrates LLM providers and provides unified API access.

chat ( array $messages, ?ChatOptions $options = null) : CompletionResponse

Execute a chat completion request.

param array $messages

Array of message objects with 'role' and 'content' keys

param ChatOptions|null $options

Optional config

Message Format:

Chat message format
$messages = [
    ['role' => 'system', 'content' => '...'],
    ['role' => 'user', 'content' => 'Hello!'],
    ['role' => 'assistant', 'content' => 'Hi!'],
    ['role' => 'user', 'content' => 'How are you?'],
];
Copied!
Returns

CompletionResponse

complete ( string $prompt, ?ChatOptions $options = null) : CompletionResponse

Simple completion from a single prompt.

param string $prompt

The prompt text

param ChatOptions|null $options

Optional config

Returns

CompletionResponse

embed ( string|array $input, ?EmbeddingOptions $options = null) : EmbeddingResponse

Generate embeddings for text.

param string|array $input

Single text or array of texts

param EmbeddingOptions|null $options

Optional configuration

Returns

EmbeddingResponse

vision ( array $content, ?VisionOptions $options = null) : VisionResponse

Analyze an image with vision capabilities.

param array $content

Array of content parts (text and image_url entries)

param VisionOptions|null $options

Optional configuration

Returns

VisionResponse

streamChat ( array $messages, ?ChatOptions $options = null) : Generator

Stream a chat completion response.

param array $messages

Array of message objects

param ChatOptions|null $options

Optional config

Returns

Generator yielding string chunks

chatWithTools ( array $messages, array $tools, ?ToolOptions $options = null) : CompletionResponse

Chat with tool/function calling capability.

param array $messages

Array of message objects

param array $tools

Array of tool definitions

param ToolOptions|null $options

Optional config

Returns

CompletionResponse with tool calls

getProvider ( ?string $identifier = null) : ProviderInterface

Get a specific provider by identifier.

param string|null $identifier

Provider identifier (openai, claude, gemini); null for default

throws

ProviderException

Returns

ProviderInterface

getAvailableProviders ( ) : array

Get all configured and available providers.

Returns

array<string, ProviderInterface>