---
title: "LlmServiceManager"
manual: "TYPO3 LLM Extension"
version: "0.35"
permalink: "https://docs.typo3.org/permalink/netresearch/nr-llm:api-llm-service-manager@0.35"
source: "Api/LlmServiceManager.rst"
modified: "2026-09-16T22:09:16+00:00"
---

# 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**

        ```php
        $messages = [
            ['role' => 'system', 'content' => '...'],
            ['role' => 'user', 'content' => 'Hello!'],
            ['role' => 'assistant', 'content' => 'Hi!'],
            ['role' => 'user', 'content' => 'How are you?'],
        ];
        ```

        *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

    -   **embedForConfiguration(string|array $input, LlmConfiguration $configuration, ?EmbeddingOptions $options = null) : EmbeddingResponse**

        Generate embeddings against a specific LLM configuration.

        Resolves the adapter from the configuration's model (vault key +
        model + pricing) and runs through the middleware pipeline, so
        per-configuration budgets and cost attribution apply. Per-call
        options take precedence over the configuration's stored defaults:
        an options `model` overrides the configuration's model id.
        Throws `UnsupportedFeatureException` when the configuration's
        provider does not support embeddings.

        -   *param string|array $input:*

            Single text or array
            of texts

        -   *param LlmConfiguration $configuration:*

            The
            configuration record to resolve provider/model from

        -   *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. An explicit identifier is
        required; passing `null` throws `ProviderException` (code
        4867297358). To select a provider without naming one, pin it per
        call via the options object's `provider` field, or configure an
        active default Configuration in the backend module (see ADR-034).

        -   *param string|null $identifier:*

            Provider identifier
            (openai, claude, gemini); `null` is rejected

        -   *throws:* ProviderException

        *Returns:* ProviderInterface

    -   **getAvailableProviders() : array**

        Get all configured and available providers.

        *Returns:* array\<string, ProviderInterface>
