Skip to main content
LLM Drivers provide a standardized interface for interacting with different language model providers. Switch between providers without changing your application code.

Available Drivers

OpenAI

Default driver for OpenAI API. Works with GPT-4, GPT-4o, and other OpenAI models.

Anthropic (Claude)

Native support for Claude models via the Anthropic API.

Google Gemini

Native Gemini driver for Google’s AI models.

Groq

Ultra-fast inference with Groq’s LPU platform.

Ollama

Run local LLMs with Ollama integration.

OpenRouter

Access multiple providers through OpenRouter’s unified API.
All drivers are pre-configured in config/laragent.php. Add your API key and you’re ready to go.

Quick Setup

OpenAI (Default)

.env
App/AiAgents/MyAgent.php

Anthropic (Claude)

.env
App/AiAgents/MyAgent.php
Claude supports structured output (response schemas) for type-safe JSON responses from v1.1.0

Google Gemini

.env
App/AiAgents/MyAgent.php

Groq

.env
App/AiAgents/MyAgent.php

Ollama (Local)

App/AiAgents/MyAgent.php

OpenRouter

.env
App/AiAgents/MyAgent.php

Configuration

Global Configuration

Configure providers in config/laragent.php:
config/laragent.php

Per-Agent Configuration

Override the driver directly in your agent:
Agent-level driver configuration overrides the global provider settings.

Multi-Provider Fallback

Automatically switch between AI providers when one fails, ensuring your agents stay operational even when a provider is down or rate-limited.

Per-Agent Configuration

Set multiple providers directly in your agent using an array:
App/AiAgents/MyAgent.php

With Per-Provider Overrides

Override specific settings for each provider in the fallback chain:
App/AiAgents/MyAgent.php

Global Configuration

Set default fallback providers for all agents in config/laragent.php:
config/laragent.php
Agent-level $provider array takes precedence over default_providers config.

Debugging Fallback

Use these methods to inspect the provider sequence and active provider:
The fallback_provider config option is deprecated. Use default_providers or array-based $provider instead.

Driver Reference

The OpenAiCompatible driver works with any API that follows the OpenAI format, making it easy to integrate with custom or self-hosted solutions.

Best Practices

Store API keys in environment variables — never hardcode them.
Configure multi-provider fallback for production reliability.
Not all providers support the same features. Check provider documentation for streaming, tool calling, and structured output support.

Next Steps

Create & Configure

Configure agents with different providers.

Streaming

Enable real-time streaming responses.

Structured Output

Get typed, validated responses from your agents.

Context Overview

Manage conversation history and agent state.