AI Core

Layers and the bridge

How AI Core sits between scripts - integration layers, stand-ins and the ESX / QB / Qbox bridge.

Integration layers

A script never calls another script's exports for a shared job. It calls the lib, the lib calls AI Core, and AI Core forwards to the script the server runs for that job. Each layer picks its adapter at start (the admin panel can override it) and again when a candidate starts or stops.

LayerLibAdapters
Inventoryinventoryai-inventory, ox_inventory, qb-inventory, tgiann-inventory and more
Vehicle keysvehicleKeysai-vehiclekeys, qbx_vehiclekeys and others
Dispatchdispatch.alertai-policealert and alert scripts
Phonephonetgiann-phone, lb-phone
Weather and timeworldthe qb-weathersync API (ai-weathersync, qb-weathersync, Renewed), cd_easytime; pauses counted per reason
Prisonprisonai-prison, qb-prison
Appearanceappearanceai-appearance, tgiann-clothing
Medicalmedicalai-death, qbx_medical, qb-ambulancejob, esx_ambulancejob, ars_ambulancejob
Radial menuradialai-radialmenu, qb-radialmenu, ox_lib
Gesturesgesturesai-smallresources, tgiann-emotes
HUDhud, keyHintsai-hud, tgiann-lumihud
Prime timeisPrimeTimetgiann-policealert, else the panel's hours

Adding a script to a layer is one adapter file and one registry line.

The bridge

ai-core provides es_extended, qb-core and qbx_core and answers their APIs from Lua files in bridge/:

  • core objects (exports['qb-core']:GetCoreObject(), ESX = exports.es_extended:getSharedObject(), the legacy events), Qbox exports;
  • player objects (xPlayer, QB Player) mirrored from AI Core's change events, never by asking AI Core per read;
  • client PlayerData built from AI Core's own player data channel;
  • framework events with the same arguments and timing (QBCore:Client:OnPlayerLoaded, esx:setJob...);
  • callbacks, usable items, commands (listed in the panel), notifications, menus, text prompts and progress bars drawn with AI Core's UI;
  • file includes (@qb-core/shared/locale.lua, @es_extended/imports.lua, @qbx_core/modules/playerdata.lua).

The bridge runs on a copy of ai-lib's Lua side, so framework helpers (streaming, zones, keybinds, progress, rate limits) share the lib's code.

On this page