Luminova Framework

PHP Luminova: Configure AI Agents

Last updated: 2026-11-28 20:57:12

Configure the default AI agent, model, endpoint, and credentials for a Luminova application.

The App\Config\AI class is the central place to configure your default AI provider and credentials for your Luminova application. The Agent proxy uses this configuration when constructing a registered provider. It reuses an agent after the first lookup. When you register an existing agent instance, configure its endpoint, credentials, and model on that instance before registering it.

See Base AI Agents or AI Agent Proxy to get started.


Class Definition


Properties

handler

The AI agent to use by default.

Determines which AI provider implementation will handle requests. The value is matched against the agent registry (case-insensitive). If it is empty, openai is used.

Custom agents added with Agent::register() can also be used here by their registered name.

public string $handler = 'Ollama';

Available handlers include:


model

The default model applied to the agent when it is created.

When the registry constructs an agent, it calls setModel() for a nonempty value. Set this property to null to leave model selection to the agent or to a request’s model option.

public ?string $model = 'qwen3:8b';

Examples:

  • Ollama: qwen3:8b
  • OpenAI: gpt-4.1-mini
  • Anthropic: claude-haiku-4-5-20251001

Note:

OpenAI falls back to its own default model per endpoint (for example gpt-4.1-mini for chat) when no model is set. Specify a model for general Anthropic and Ollama requests. Some operations have their own defaults, such as llava for Ollama vision.


baseUrl

Base API endpoint for the selected AI provider.

The registry passes this value to each built-in provider it constructs from this configuration. Update it along with $handler and $model when switching providers.

public string $baseUrl = 'http://localhost:11434/api/';

Examples:

  • Ollama (local): http://192.168.100.13:11434/api/
  • OpenAI: https://api.openai.com/v1/
  • Anthropic: https://api.anthropic.com/v1/

apiKey

API key used to authenticate requests to the provider.

For a local Ollama instance without authentication, leave the key empty. Set it for deployments that require a Bearer token.

public string $apiKey = '';

When the key is not empty, it is sent as a Bearer token in the Authorization header. Anthropic also receives it in the x-api-key header.

See Also:

Where to obtain your key:


organization

OpenAI organization identifier (e.g, org-xxxx).

Used by OpenAI to select an organization. Sent as the OpenAI-Organization header when not null.

public ?string $organization = null;

See Also:


project

OpenAI project identifier.

Used by OpenAI only. Groups API usage and billing under a specific project. Sent as the OpenAI-Project header when not null.

public ?string $project = null;

version

Version segment for the built-in OpenAI and Anthropic base URLs.

Used by OpenAI and Anthropic. Ollama ignores this value.

public string $version = 'v1';

This setting applies when OpenAI or Anthropic constructs its built-in URL. When the registry passes $baseUrl, the URL already contains its version segment. The default URL is then https://api.openai.com/{version}/ or https://api.anthropic.com/{version}/. An empty value falls back to v1.

Examples:

  • OpenAI: v1
  • Anthropic: v1

headerVersion

API version identifier sent in the request header when required.

Used by Anthropic only, as the anthropic-version header. OpenAI and Ollama ignore this value.

public string $headerVersion = '2023-06-01';

Examples:

  • Anthropic: 2023-06-01

betaFeatures

Optional Anthropic beta feature flags (e.g, interleaved-thinking-2025-05-14).

Used by Anthropic only. A comma-separated string sent via the anthropic-beta header. Leave it at null to omit the beta header when constructing a new agent.

public ?string $betaFeatures = null;

Provider Usage

PropertyOpenAIOllamaAnthropic
modelYesYesYes
baseUrlYesYesYes
apiKeyYesOptionalYes
organizationYesNoNo
projectYesNoNo
versionBuilt-in URLNoBuilt-in URL
headerVersionNoNoYes
betaFeaturesNoNoYes

Examples

Apply each example’s settings inside the existing App\Config\AI class. Keep its other properties so the provider constructors can resolve their defaults.

Setting Up OpenAI as Default Handler

// Inside App\Config\AI
public string $handler  = 'OpenAI';
public ?string $model   = 'gpt-4.1-mini';
public string $baseUrl  = 'https://api.openai.com/v1/';
public string $apiKey   = 'sk-...your-key...';
public ?string $organization = 'org-abc123';
public ?string $project      = null;

Setting Up Anthropic as Default Handler

// Inside App\Config\AI
public string $handler       = 'Anthropic';
public ?string $model        = 'claude-haiku-4-5-20251001';
public string $baseUrl       = 'https://api.anthropic.com/v1/';
public string $apiKey        = 'sk-ant-...your-key...';
public string $version       = 'v1';
public string $headerVersion = '2023-06-01';
public ?string $betaFeatures = 'interleaved-thinking-2025-05-14';

Setting Up a Remote Ollama Deployment

// Inside App\Config\AI
public string $handler  = 'Ollama';
public ?string $model   = 'qwen3:8b';
public string $baseUrl  = 'https://ollama.example.com/api/';
public string $apiKey   = 'your-bearer-token'; // optional

// Inside App\Config\AI
public string $handler = 'OpenAI';
public ?string $model  = 'gpt-4.1-mini';
public string $baseUrl = 'https://api.openai.com/v1/';
public string $apiKey  = ''; // loaded from .env below
public ?string $organization = null;

protected function onCreate(): void
{
  $this->apiKey = (string) env('OPENAI_KEY', '');
  $this->organization = env('OPENAI_ORG', null);
}

Tip: Always store API keys in your .env file and never commit them to version control.