Skip to content

PHP classes and functions

The plugin exposes an API object, OG_OGAI_API, in the global $ogaie. Use it after plugins_loaded.

global $ogaie;

// Plain text answer
$answer = $ogaie->simpleTextQuery( 'Summarise our returns policy in two sentences.' );

// Faster, cheaper model
$short = $ogaie->simpleFastTextQuery( 'Give me a title for this paragraph: ...' );

Methods

Method Purpose
simpleTextQuery( $message, $params = [] ) Text in, text out.
simpleFastTextQuery( $message, $params = [] ) Same, using the Fast default model.
simpleChatbotQuery( $botId, $message, $params = [], $onlyReply = true ) Ask one of your chatbots, with its settings.
simpleVisionQuery( $message, $url, $path = null, $params = [] ) Ask about an image by URL or path.
simpleImageQuery( $message, $params = [] ) Generate an image.
simpleImageEditQuery( $message, $mediaId, $params = [] ) Edit an image from the Media Library.
simpleJsonQuery( $message, $url = null, $path = null, $params = [] ) Get structured JSON back.
simpleTranscribeAudio( $url = null, $path = null, $params = [] ) Audio to text.
simpleFileUpload( $file = null, $base64 = null, $filename = null, ... ) Store a file for use in a query.
moderationCheck( $text ) Check text against the moderation endpoint.
getDiscussion( $botId, $chatId ) Read one saved discussion.
getStatus(), hasAI(), hasMCP() Check whether an AI environment with a key exists and whether MCP is on.

$params can select the environment and model. Wrap calls in try/catch: provider errors throw exceptions.

The same methods are available over REST when the Public API module is on. See Public REST API.

Notes

  • Calls run with your server's PHP time limit. Use background tasks for long jobs.
  • Calls cost money. Cache results you reuse.
  • Check the method exists with method_exists() before you call a newer method.
  • OG_OGAI_Modules::is_pro() is true with a valid Pro licence. OG_OGAI_Modules::is_loaded( 'leads' ) tells you whether a built-in module is running (ids: woo, coremail, faq, contact_form, workflow, rss, copytrack, agents, public_mcp, leads).
  • Pro classes (OGPro_OGAI_*) only exist while the Pro pack is loaded. Check with class_exists().

Data and options

OG AI Core keeps its data in your WordPress database. Table names below are shown without the WordPress table prefix.

Tables

Table Holds
ogaie_chats Discussions.
ogaie_files, ogaie_filemeta Uploaded and generated files.
ogaie_logs, ogaie_logmeta Usage records for Insights.
ogaie_vectors Knowledge entries (Pro).
ogaie_local_vectors The internal vector store (Pro).
ogaie_tasks, ogaie_tasklogs Background tasks and their logs (Developer > Tasks).
ogaie_mcp_oauth_clients, ogaie_mcp_oauth_tokens Connected MCP apps and their tokens.
ogmail_logs CoreMail email log.
ogflow_flows, ogflow_runs Workflow flows and runs (Pro).
ogaie_leads, ogaie_lead_state Captured leads, and the status and notes of every lead (Leads, Pro).

Options

Option Holds
ogaie_options The main settings, including the module_* switches of System > Modules.
ogaie_chatbots Your chatbots.
ogaie_themes Chatbot themes.
ogaie_templates Saved templates for the content tools.
ogaie_module_<id> Settings of the built-in modules that OG AI Core builds itself: ogaie_module_faq, ogaie_module_rss, ogaie_module_public_mcp and ogaie_module_leads.
ogaie_license The Pro licence record. See Pro pack.
ogag_agents, ogag_runs_<id> Agents and their last runs.
ogaie_faq_sets FAQ sets for the [og_faq] shortcode.
ogaie_addon_state Which add-ons in wp-content/og-ai-addons are on, and their last error.

The other built-in modules keep their own option names, for example ogaiwoo_options (Woo Basics). Each add-on keeps its own options too, for example ogda_settings (Dynamic API) and ogwa_settings (WooAi). Removing an add-on's files never deletes them.