---
title: "Consumer integration examples"
manual: "LLM Foundation"
version: "main"
permalink: "https://docs.typo3.org/permalink/netresearch/nr-llm:consumer-integration-examples@main"
source: "Developer/FeatureServices/Integrations.rst"
rendered: "2026-11-12T15:41:35+00:00"
---

# Consumer integration examples {#consumer-integration-examples}

## Configuration {#feature-services-configuration}

### Custom prompts {#feature-services-custom-prompts}

Pass a custom analysis prompt to the vision service:

**Custom image analysis prompt**

```php
$analysis = $visionService->analyzeImage(
    $imageUrl,
    'Describe the visible objects for this product catalog.',
);
```

For configuration-owned prompts, use the backend's LLM configurations and
prompt snippets. The API documentation describes those records and their
composition; they do not replace the feature service's built-in prompt constants.

### Service options {#feature-services-service-options}

Services accept the options object for their operation:

**Service options example**

```php
use Netresearch\NrLlm\Service\Option\ChatOptions;

$result = $completionService->complete(
    prompt: 'Generate text',
    options: new ChatOptions(
        temperature: 0.7,
        maxTokens: 1000,
        topP: 0.9,
        frequencyPenalty: 0.0,
        presencePenalty: 0.0,
        responseFormat: 'json',
        systemPrompt: 'Custom instructions',
        stopSequences: ["\n\n", 'END'],
    ),
);
```

## Extension integration examples {#feature-services-extension-integration}

### rte-ckeditor-image {#feature-services-integration-ckeditor}

**Example: CKEditor image integration**

```php
use Netresearch\NrLlm\Service\Feature\VisionService;

class ImageAiService
{
    public function __construct(
        private readonly VisionService $visionService
    ) {}

    public function enhanceImage(string $absoluteImageUrl): array
    {
        return [
            'alt' => $this->visionService->generateAltText($absoluteImageUrl),
            'title' => $this->visionService->generateTitle($absoluteImageUrl),
        ];
    }
}
```

Resolve a FAL file's public URL to an absolute HTTPS URL before calling this
service, or read the file and supply a base64 data URL.

### textdb {#feature-services-integration-textdb}

**Example: textdb translation integration**

```php
use Netresearch\NrLlm\Service\Feature\TranslationService;
use Netresearch\NrLlm\Service\Feature\EmbeddingService;

class AiTranslationService
{
    public function __construct(
        private readonly TranslationService $translationService,
        private readonly EmbeddingService $embeddingService
    ) {}

    public function suggestTranslation(
        string $text,
        string $lang,
        array $candidateVectors,
    ): array
    {
        $vector = $this->embeddingService->embed($text);
        return [
            'translation' => $this->translationService->translate($text, $lang),
            'similar' => $this->embeddingService->findMostSimilar(
                $vector,
                $candidateVectors,
            ),
        ];
    }
}
```

### contexts {#feature-services-integration-contexts}

**Example: Contexts rule generation**

```php
use Netresearch\NrLlm\Service\Feature\CompletionService;
use Netresearch\NrLlm\Service\Option\ChatOptions;

class RuleGeneratorService
{
    public function __construct(
        private readonly CompletionService $completionService
    ) {}

    public function generateRule(string $description): ?array
    {
        return $this->completionService->completeJson(
            "Generate TYPO3 context rule: $description",
            new ChatOptions(temperature: 0.2),
        );
    }
}
```

## File structure {#feature-services-file-structure}

**Feature services file structure**

```text
nr-llm/
├── Classes/
│   ├── Domain/
│   │   └── Model/
│   │       ├── CompletionResponse.php
│   │       ├── VisionResponse.php
│   │       ├── TranslationResult.php
│   │       ├── EmbeddingResponse.php
│   │       ├── UsageStatistics.php
│   │       └── RenderedPrompt.php
│   ├── Service/
│   │   └── Feature/
│   │       ├── CompletionService.php
│   │       ├── VisionService.php
│   │       ├── EmbeddingService.php
│   │       └── TranslationService.php
│   └── Exception/
│       └── InvalidArgumentException.php
├── Configuration/
│   └── Services.yaml
├── Resources/
│   └── Private/
│       └── Data/
│           └── DefaultPrompts.php
└── Tests/
    └── Unit/
        └── Service/
            └── Feature/
                ├── CompletionServiceTest.php
                ├── VisionServiceTest.php
                └── EmbeddingServiceTest.php
```
