页面 · Laravilt
Providers
Configure the AI providers that power chat, agents and search.
Every provider implements Laravilt\AI\Contracts\AIProvider and extends Laravilt\AI\Providers\BaseProvider.
| Provider | Class | Default model | Page |
|---|---|---|---|
| OpenAI | OpenAIProvider | gpt-4o-mini | OpenAI |
| Anthropic | AnthropicProvider | claude-sonnet-4-20250514 | Anthropic |
| Google Gemini | GeminiProvider | gemini-2.0-flash-exp | Gemini |
| DeepSeek | DeepSeekProvider | deepseek-chat | DeepSeek |
| Perplexity | PerplexityProvider | sonar | Perplexity |
Config file
config/laravilt-ai.php (published by php artisan laravilt:ai:install):
Each provider reads api_key, model, base_url, temperature and max_tokens from its entry.
Using the AI manager
Laravilt\AI\AIManager builds a provider for every configured entry that has an API key.
AIManagerbuilds providers from config only foropenai,anthropic,geminianddeepseek. To use Perplexity, register it on the panel withAIProviderBuilderor add it with$ai->addProvider(new PerplexityProvider).
Panel providers
A panel lists its providers with aiProviders(). The configure callback receives the provider instance:
Shortcuts: openai(), anthropic(), gemini(), deepseek(), perplexity().
Provider methods
| Method | Description |
|---|---|
apiKey(string) | Set the API key |
model(string|BackedEnum) | Set the model (string or model enum) |
baseUrl(string) | Override the API base URL |
temperature(float) | Sampling temperature |
maxTokens(int) | Maximum output tokens |
enabled() / disabled() | Toggle the provider |
chat($messages, $options) | Returns ['content' => ..., 'usage' => [...]] |
chatWithTools($messages, $tools, $options) | Adds tool_calls to the result |
streamChat($messages, $options) | Generator of text chunks |
streamChatRealtime($messages, $callback, $options) | Calls $callback for each chunk as it arrives |
Per-call $options accept model, temperature and max_tokens (OpenAI and DeepSeek also accept tool_choice in chatWithTools()).
Model enums live in Laravilt\AI\Enums: OpenAIModel, AnthropicModel, GeminiModel, DeepSeekModel, PerplexityModel.