PHP Luminova: Configure AI Agents
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
- Full namespace:
App\Config\AI - This configuration derives from Luminova\Base\AbstractConfig.
- File path:
/app/Config/AI.php - This class is final.
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:
OpenAI- Luminova\AI\Agents\OpenAIOllama- Luminova\AI\Agents\OllamaAnthropic- Luminova\AI\Agents\Anthropic
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-minifor chat) when no model is set. Specify a model for general Anthropic and Ollama requests. Some operations have their own defaults, such asllavafor 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:
- 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).
Used by OpenAI to select an organization. Sent as the
OpenAI-Organizationheader when notnull.
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-Projectheader when notnull.
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-versionheader. 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-betaheader. Leave it atnullto omit the beta header when constructing a new agent.
public ?string $betaFeatures = null;Provider Usage
| Property | OpenAI | Ollama | Anthropic |
|---|---|---|---|
model | Yes | Yes | Yes |
baseUrl | Yes | Yes | Yes |
apiKey | Yes | Optional | Yes |
organization | Yes | No | No |
project | Yes | No | No |
version | Built-in URL | No | Built-in URL |
headerVersion | No | No | Yes |
betaFeatures | No | No | Yes |
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'; // optionalUsing Environment Variables (Recommended)
// 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
.envfile and never commit them to version control.