About this project

Laravel LLM Relay provides a single, consistent interface in Laravel applications to interact with multiple large language model providers — specifically Claude, GPT (OpenAI), and Gemini. It automatically handles provider failures by retrying or falling back to the next available provider in a configurable chain, ensuring your AI features remain available even if one service is down. Each response includes metadata such as the successful provider, total tokens used, and latency in milliseconds, enabling cost monitoring and performance analysis. The package supports simple prompts, multi-turn conversations with system instructions, and dependency injection. It integrates seamlessly with Laravel’s HTTP client for testing via Http::fake(). Configuration is managed through environment variables and optional published config files. Providers are skipped if their API keys are not set, and you can force a specific provider without fallback. Logging of every request (provider, tokens, latency) is supported via Laravel’s logging channels. Designed for production use, it addresses common pain points: provider instability, evolving model preferences, and cost transparency. MIT licensed.