Ai3 Core 

Extension key

ai3_core

Package name

wegewerk/ai3_core

Version

main

Language

en

Author

Wegewerk GmbH

License

This document is published under the Creative Commons BY 4.0 license.

Rendered

Fri, 24 Jul 2026 15:34:31 +0000


Ai3 Core is the shared foundation of the Ai3 Suite — an AI-assisted content-generation toolkit for TYPO3. It provides:

  • A PSR HTTP client wrapper for the Zak_ai REST API
  • A capability registry that other Ai3 packages extend via a DI tag
  • A persistent generation task queue (Extbase model + repository)
  • A backend module with dashboard, Zak_ai registration wizard, and task overview
  • Two CLI commands for querying Zak_ai credits and processing pending tasks

This package will support TYPO3 13 and 14.

Introduction 

What it does 

Ai3 Core is the shared core package of the Ai3 Suite. It is not a standalone user-facing extension; instead, it provides infrastructure that all other Ai3 packages depend on.

Core responsibilities:

  • Authenticate against the Zak_ai REST API using credentials supplied via environment variables.
  • Manage a Zak_ai registration lifecycle (API key request and confirm). the registration progress is persisted in the TYPO3 system registry.
  • Maintain a generation task queue stored in tx_ai3_domain_model_generation_task. AI-generation requests can be processed asynchronously.
  • Expose a capability registry that other Ai3 extensions use to register their own AI endpoints.
  • Provide a TYPO3 backend module (Ai3) with a dashboard, the Zak_ai setup wizard, and view of the generation task queue.

Features 

  • PSR-compliant HTTP client wrapper for the Zak_ai API
  • Symfony DI compiler pass for tagged capability registration
  • Extbase GenerationTask entity and repository
  • Backend module
  • AJAX endpoints for live Zak_ai credit and account info
  • CLI: ai3_core:process_tasks
  • ES module namespace @wegewerk/ai3core/

Requirements 

Dependency Requirement
TYPO3 CMS ^13.4.0 || ^14.0
PHP >=8.4
PHP extension ext-intl

Installation 

Installation via Composer 

Ai3 Core is installed as a dependency of other Ai3 Suite packages. It is not intended to be required directly in most projects. If you do need it explicitly, run:

Install via Composer
composer require wegewerk/ai3_core
Copied!

Environment variables 

The Zak_ai API client reads its credentials exclusively from environment variables. API_KEY and SECRET are obtained in the Backend Module.

.env or server environment
ZAKAI_API_KEY=<your-api-key>
ZAKAI_SECRET=<your-secret>
Copied!

The complete registration flow — including requesting and confirming the API key — is available through the backend module.

Configuration 

Ai3 Core has no extension configuration form in the TYPO3 backend. All runtime settings are controlled through environment variables and TYPO3 configuration files that ship with the package.

See the sub-pages for details on each configuration area.

Environment variables 

The Zak_ai HTTP client is configured exclusively through environment variables.

ZAKAI_API_KEY

ZAKAI_API_KEY
Type
string
Default
(empty)

The API key issued by Zak_ai after a successful registration. When empty, all authenticated API calls throw a \RuntimeException.

Obtain the key by completing the registration wizard in the backend module.

ZAKAI_SECRET

ZAKAI_SECRET
Type
string
Default
(empty)

The secret associated with your Zak_ai account. Together with ZAKAI_API_KEY it forms the HTTP Basic Auth header sent with every authenticated request.

API base URL 

The Zak_ai API base URL is defined in Configuration/Services.yaml. To override it in a specific environment, rebind the service argument in your project's Services.yaml:

config/services.yaml (project level)
Wegewerk\Ai3Core\Api\ZakAiClient:
    arguments:
        $baseUrl: 'https://staging.zak-ai.com/api/v1/'
Copied!

Or define to use another env-var:

config/services.yaml (project level)
Wegewerk\Ai3Core\Api\ZakAiClient:
    arguments:
        $baseUrl: '%env(ZAK_AI_BASE_URL)%'
Copied!

Default model 

The default inference model is mistral-small3.2:latest, defined as the DEFAULT_MODEL constant in \Wegewerk\Ai3Core\Api\ZakAiClient. It is appended automatically to every POST payload.

It is not detemined yet if this should be user configurable in the future.

Logging 

Logging is done using the PsrLogLoggerInterface.

For Logging Configuration refer to the TYPO3 Documentation

JavaScript modules 

Ai3 Core registers ES modules under the import-map namespace @wegewerk/ai3core/. The mapping is defined in Configuration/JavaScriptModules.php:

Configuration/JavaScriptModules.php
return [
    'dependencies' => ['core', 'backend'],
    'tags' => [
        'backend.form',
        'backend.contextmenu',
    ],
    'imports' => [
        '@wegewerk/ai3core/' =>
            'EXT:ai3_core/Resources/Public/JavaScript/',
    ],
];
Copied!

The following modules are available:

Import path Purpose
@wegewerk/ai3core/ai3api.js Low-level API call helpers
@wegewerk/ai3core/ajax.js Common Error Handling for AJAX Calls
@wegewerk/ai3core/credits.js Credit display widget
@wegewerk/ai3core/response-handling.js Shared response-processing logic
@wegewerk/ai3core/Typo3Icon.js Helper for TYPO3 SVG icons

Other Ai3 extensions import these modules using standard ES import syntax:

Resources/Public/JavaScript/MyModule.js
import { fetchCredits } from
    '@wegewerk/ai3core/credits.js';
Copied!

Usage 

This section describes how to use the features of Ai3 Core from the TYPO3 backend and from the command line.

For information on how to extend Ai3 Core from your own extension (e.g. registering a custom AI capability), see Developer.

Backend module 

The Ai3 backend module is located under Web > Ai3 in the TYPO3 backend main menu. It provides three views accessible via the sub-navigation:

Dashboard 

Zak_ai management 

This Dashboard guides you through the Zak_ai registration process:

  1. Generate a Secret and Provide an e-mail address.
  2. Put this secret in the ``ZAKAI_SECRET'' environment variable.
  1. Request API key — Sends a POST /accounts request to Zak_ai. The registration status changes to Requested. Zak_ai sends an email containing your api key.
  1. Save API key After receiving the confirmation e-mail from Zak_ai, Put the API Key in the ``ZAKAI_API_KEY'' environment variable.
  2. Activate API key Click Activate API key to call PUT /accounts. The status changes to Done.

The dashboard looks like this when the registration is complete.

Generation task overview 

This view lists all GenerationTask records stored in the database. Each row shows the capability, target record (table / field / UID), current status, prompt, and generated result.

This view is intended for developers to see what the queue status looks like

See Generation task for the full field reference.

CLI commands 

Ai3 Core ships two Symfony console commands registered with TYPO3's CLI dispatcher.

ai3_core:credits 

Queries the Zak_ai credits endpoint and dumps the raw response.

Query available credits
vendor/bin/typo3 ai3_core:credits
Copied!

Output: A var_dump() of the decoded JSON response from GET /credits. Useful for verifying that ZAKAI_API_KEY is set correctly and the API is reachable.

ai3_core:process_tasks 

Fetches up to 100 pending GenerationTask records (ordered by UID ascending) and processes each one by calling the registered capability endpoint.

Process all pending generation tasks
vendor/bin/typo3 ai3_core:process_tasks
Copied!

Processing logic per task:

  1. Look up the capability identified by task.capability in the CapabilityRegistry.
  2. Call capability->endpoint->generate(image, prompt, language).
  3. If a result is returned, set task.result, mark the task as Done, and store task.generated_timestamp.
  4. Persist all changes.

Developer 

This section is intended for PHP developers who want to:

  • Register a custom AI capability in a third-party extension.
  • Work with the generation task queue programmatically.

Capability API 

A capability is a named AI endpoint that a third-party Ai3 extension provides. Ai3 Core exposes a tagged DI compiler pass so that capabilities register without code changes in ai3_core.

ZakAiEndpointInterface 

Every capability must implement \Wegewerk\Ai3Core\Api\ZakAiEndpointInterface:

Classes/Api/ZakAiEndpointInterface.php
interface ZakAiEndpointInterface
{
    public function generate(
        string $imagePath,
        string $description,
        string $language,
    ): string;
}
Copied!

The generate() method receives the image path (may be empty), a text prompt, and a language code. It must return the generated text.

Registering a capability 

Tag your endpoint service with ai3.capability in your extension's Configuration/Services.yaml. The compiler pass picks up the $key, $title, and $endpoint constructor arguments automatically:

Configuration/Services.yaml (your extension)
MyVendor\MyAiExt\Endpoint\SummaryEndpoint:
    tags:
        - name: ai3.capability
    arguments:
        $key: 'my_ext_summary'
        $title: 'Automatic summary'
        $endpoint: '@MyVendor\MyAiExt\Endpoint\SummaryEndpoint'
Copied!
Classes/Endpoint/SummaryEndpoint.php
use Wegewerk\Ai3Core\Api\ZakAiEndpointInterface;

final class SummaryEndpoint implements ZakAiEndpointInterface
{
    public function generate(
        string $imagePath,
        string $description,
        string $language,
    ): string {
        // Call Zak_ai provider here.
        return 'Generated summary …';
    }
}
Copied!

CapabilityRegistry 

At runtime, all registered capabilities are available via \Wegewerk\Ai3Core\Service\CapabilityRegistry. It is a SingletonInterface and can be injected via constructor:

Injecting the registry
use Wegewerk\Ai3Core\Service\CapabilityRegistry;

final class MyService
{
    public function __construct(
        private readonly CapabilityRegistry $capabilityRegistry,
    ) {}

    public function run(string $capabilityKey): string
    {
        $capability = $this->capabilityRegistry
            ->getCapability($capabilityKey);
        if ($capability === null) {
            throw new \RuntimeException(
                'Unknown capability: ' . $capabilityKey,
            );
        }
        return $capability->endpoint->generate('', 'Hello', 'en');
    }
}
Copied!

TCA integration 

To expose capability selection in a FormEngine field, use the provided itemsProcFunc:

TCA column configuration
'capability' => [
    'label' => 'AI capability',
    'config' => [
        'type' => 'select',
        'renderType' => 'selectSingle',
        'itemsProcFunc' =>
            \Wegewerk\Ai3Core\FormEngine\CapabilityItemsProcFunc::class
            . '->itemsProcFunc',
    ],
],
Copied!

The items list is populated dynamically from the CapabilityRegistry at render time.

Generation task 

A GenerationTask represents one AI-generation request. Tasks are stored in the database table tx_ai3_domain_model_generation_task and managed through the Extbase GenerationTaskRepository.

Task lifecycle 

Every task moves through a set of states defined by \Wegewerk\Ai3Core\Enums\Status:

Value Meaning
Pending Task created, waiting to be processed.
Processing Reserved for future use (processing flag).
Done AI generation completed; result is populated.
Failed Generation failed; error_message is populated.
Canceled Task was canceled before processing.

Field reference 

status

status
Type
string (enum)
Default
Pending

Current lifecycle state. One of Pending, Processing, Done, Failed, Canceled.

prompt

prompt
Type
string
Default
(empty)

The text prompt sent to the AI endpoint.

image

image
Type
string
Default
(empty)

Optional path to an image passed to the capability endpoint.

capability

capability
Type
string
Default
(empty)

Key of the registered capability (e.g. my_ext_summary). See Capability API.

record_table

record_table
Type
string
Default
(empty)

Name of the TYPO3 database table that owns the record being processed (e.g. tt_content).

record_field

record_field
Type
string
Default
(empty)

Name of the field within record_table that will receive the generated text.

record_uid

record_uid
Type
int

UID of the owning record.

generate_language

generate_language
Type
string
Default
(empty)

ISO language code passed to the capability endpoint.

result

result
Type
string
Default
(empty)

The text returned by the capability endpoint after a successful generation.

result_meta

result_meta
Type
string
Default
(empty)

Optional JSON metadata returned alongside the result.

error_message

error_message
Type
string
Default
(empty)

Human-readable error description when status is Failed.

reviewed

reviewed
Type
bool
Default
false

Set to true by an editor after reviewing the generated result.

generated_timestamp

generated_timestamp
Type
int (Unix timestamp)
Default
0

Unix timestamp set when generation completes successfully.

GenerationTaskService 

\Wegewerk\Ai3Core\Service\GenerationTaskService is the primary API for working with the task queue. Inject it via constructor:

Adding a generation task
use Wegewerk\Ai3Core\Domain\Model\Dto\AddGenerationTask;
use Wegewerk\Ai3Core\Service\GenerationTaskService;

$dto = new AddGenerationTask(
    status: 'Pending',
    prompt: 'Write a short product description.',
    image: '',
    capability: 'my_ext_summary',
    record_table: 'tt_content',
    record_field: 'bodytext',
    record_uid: 42,
    generateLanguage: 'en',
    parameters: '',
    result: '',
    result_meta: '',
    error_message: '',
);

$task = $this->generationTaskService->addTask($dto);
Copied!

Useful query methods:

Method Description
getTask(int $uid) Latest task for record_uid.
isTaskRunning(int $uid) true if status is Pending or Processing.
hasGenerationDone(int $uid) true if the latest task is Done.
getLatestResult(int $uid) Result string of the most recent Done task.
isReviewed(int $uid) true if the latest task has been reviewed.
setReviewed(GenerationTask $task) Marks the task as reviewed and persists.

API client 

The Zak_ai API client layer consists of two classes:

  • \Wegewerk\Ai3Core\Api\ZakAiClient — low-level PSR HTTP wrapper
  • \Wegewerk\Ai3Core\Api\ZakAiAccount — account-level operations

Both classes are registered as services and can be injected via constructor DI.

ZakAiClient 

ZakAiClient handles authentication and the raw HTTP layer. It reads credentials from the environment at construction time (see Environment variables). The base URL defaults to https://www.zak-ai.com/api/v1/.

Public methods:

Method Description
postJson(string $path, array $payload, ...) Sends a JSON POST and returns the decoded response. Appends model to the payload automatically.
putJson(string $path, array $payload, ...) Sends a JSON PUT.
getJson(string $path, ...) Sends a GET request (no body).
hasApikey(): bool Returns true if ZAKAI_API_KEY is non-empty.
hasSecret(): bool Returns true if ZAKAI_SECRET is non-empty.

All request methods accept optional $extraHeaders and a $requireAuth flag. When $requireAuth is true (default) and no API key is set, a \RuntimeException is thrown before the request is sent.

ZakAiAccount 

ZakAiAccount wraps the account-related endpoints:

Method Description
requestApikey(mixed $email, string $secret) POST /accounts — request a new API key.
confirmApikey() PUT /accounts — confirm the pending API key.
queryCredits(): mixed GET /credits — return the current credit balance.
clientHasApikey(): bool Proxy for ZakAiClient::hasApikey().
clientHasSecret(): bool Proxy for ZakAiClient::hasSecret().

Changelog 

0.9 — 2026-06-17 

  • Initial version