PHP Luminova: Default Application AI Client Configuration
Set up and manage AI models used in your application — choose models, define behavior, and customize how your app interacts with AI services.
The App\Config\AI class is the central place to configure your default AI provider and credentials for the Luminova framework. AI clients like: OpenAI, Ollama, and Anthropic, read their defaults from this file when instantiated through the AI manager.
See AI Client Implementation to get started.
Class Definition
- Class namespace:
\App\Config\AI - Parent class:
Luminova\Base\Configuration - File path:
/app/Config/AI.php - This class is marked as final and can't be subclassed
Properties
handler
The AI client handler to use.
Determines which AI provider implementation will handle requests.
Must match one of the registered client names (case-insensitive).
public string $handler = 'OpenAI';Available handlers include:
OpenAI- Luminova\AI\Client\OpenAIOllama- Luminova\AI\Client\OllamaAnthropic- Luminova\AI\Client\Anthropic
baseUrl
Base API endpoint for the selected AI provider.
public string $baseUrl = 'http://example.com/api/';Examples:
- Ollama (local):
http://localhost:11434/api/ - OpenAI:
https://api.openai.com/v1/ - Anthropic:
https://api.anthropic.com/v1/
apiKey
API key used to authenticate requests to the provider.
Not required for local Ollama instances unless using a proxy or hosted Ollama service.
public string $apiKey = '';See Also:
Where to obtain your key:
- OpenAI: https://platform.openai.com/
- Anthropic: https://docs.anthropic.com/
- Ollama: https://ollama.com (Only needed if your deployment uses a Bearer token.)
organization
OpenAI organization identifier (e.g, org-xxxx).
Required only if the API key belongs to an organization account.
public ?string $organization = null;See Also:
project
OpenAI project identifier.
Used to group API usage and billing under a specific project.
public ?string $project = null;version
API version identifier sent as a header when required.
Not used by Ollama.
public string $version = 'v1';Examples:
- OpenAI:
v1 - Anthropic:
2023-06-01
betaFeatures
Optional Anthropic beta feature flags (e.g, interleaved-thinking-2025-05-14).
These are sent using the anthropic-beta header when interacting with the Anthropic API.
public ?string $betaFeatures = null;A comma-separated string of beta feature flags sent via the
anthropic-betaheader. Set tonullto disable beta features entirely.
Examples
Setting Up OpenAI as Default Handler
// app/Config/AI.php
namespace App\Config;
use Luminova\Base\Configuration;
final class AI extends Configuration
{
public string $handler = 'OpenAI';
public string $apiKey = 'sk-...your-key...';
public ?string $organization = 'org-abc123';
public ?string $project = null;
public string $version = 'v1';
}Setting Up Anthropic as Default Handler
// app/Config/AI.php
namespace App\Config;
use Luminova\Base\Configuration;
final class AI extends Configuration
{
public string $handler = 'Anthropic';
public string $apiKey = 'sk-ant-...your-key...';
public string $version = '2023-06-01';
public ?string $betaFeatures = 'interleaved-thinking-2025-05-14';
}Setting Up a Remote Ollama Deployment
// app/Config/AI.php
namespace App\Config;
use Luminova\Base\Configuration;
final class AI extends Configuration
{
public string $handler = 'Ollama';
public string $baseUrl = 'https://ollama.example.com/api/';
public string $apiKey = 'your-bearer-token'; // optional
}Using Environment Variables (Recommended)
// app/Config/AI.php
namespace App\Config;
use Luminova\Base\Configuration;
final class AI extends Configuration
{
public string $handler = 'OpenAI';
public string $apiKey = ''; // loaded from .env below
public ?string $organization = null;
protected function onCreate(): void
{
$this->apiKey = env('OPENAI_KEY', '');
$this->organization = env('OPENAI_ORG', null);
}
}Tip: Always store API keys in your
.envfile and never commit them to version control.