Download the PHP package imrandevbd/laravel-ai-hub without Composer

On this page you can find all versions of the php package imrandevbd/laravel-ai-hub. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-ai-hub

Laravel AI Hub

Latest Version Total Downloads PHP Imran Dev BD

One unified interface. Thirteen AI providers. Playground, budgets, tools, vision, and cost telemetry.

Swap OpenAI, Gemini, Claude, Grok, DeepSeek, Mistral, Groq, Ollama, OpenRouter, Azure OpenAI, Together, Fireworks, or Perplexity via config or a visual Studio UI — every request is cost-tracked in USD, retried with exponential backoff, JSON-repaired automatically, and logged asynchronously with zero user latency (no queue workers required).

Built by Imran Dev BD · Laravel 10–13 · PHP 8.2+

Packagist: imrandevbd/laravel-ai-hub
GitHub: github.com/imranbru99/laravel-ai-hub


Why Laravel AI Hub?

Advantage Benefit
One Unified API Identical fluent chain across 13 providers including Azure OpenAI, Together, Fireworks & Perplexity
Dynamic Model Routing Auto-detects providers from model IDs (AIHub::model('gemini-3.8-flash')) or scoped chains (AIHub::priority(['gemini', 'openai']))
Testing Assertion Engine Full mocking & assertions with AIHub::fake(), assertSent(), assertNotSent(), assertSentCount()
Conversational Chat Sessions Multi-turn sessions via AIHub::chat() with history, export/load, and cumulative cost tracking
Server-Sent Events (SSE) streamResponse() returns standard SSE stream ready for browsers and frontend apps
Strict JSON Schemas asJsonSchema() & AIHub::structured() enforce structured outputs across OpenAI, Gemini & Claude
Latest 2026 Models Google Gemini 3.8 / 2.5 series, OpenAI GPT-5.6 / GPT-4.5 / o3 / o1-pro, Claude 3.7 Sonnet & Opus 4, Grok 4.6, DeepSeek V3 / R1, Mistral Saba
Hybrid Thinking Engine Fluent ->thinking(), ->withoutThinking(), and ->reasoningEffort() across Gemini, Claude, and OpenAI
Interactive Studio UI /ai-hub (Studio v1.7.1) — Playground with thinking controls, custom model IDs, light/dark theme, budgets, telemetry
Automatic Failover #1 → #2 → #3… chain fallback when rate-limited or unavailable
Tools, vision & cache Function tools, image inputs, named prompt templates, optional response cache
Spend budgets Monthly / provider / job USD caps with block or warn
Zero-Worker Logging after_response logging stores analytics immediately without requiring php artisan queue:work
JSON Auto-Repair Depth-aware parser recovers malformed or truncated JSON from LLM responses automatically
Cost & Health Analytics Real-time USD spend calculation, failure %, latency percentiles (p50/p95/p99) & top jobs
Role & Gate Protection Built-in AIHub::auth() callback, AI_HUB_ROLES check, and Laravel Gate integration

Features at a Glance

Feature Description
Multi-Provider Hub OpenAI · Gemini · Claude · Grok · DeepSeek · Mistral · Groq · Ollama · OpenRouter · Azure · Together · Fireworks · Perplexity
Visual Studio /ai-hub with Playground, thinking budget controls, light/dark mode, per-provider save, budgets & templates
Hybrid Thinking & Reasoning Gemini 3.8 / 3.7 thinkingConfig, Claude 3.7 extended thinking, and OpenAI o1/o3/gpt-5 reasoning_effort
Failover Priority Chain Customize and drag-and-drop provider priority order (#1 tried first)
JSON Recovery Strips markdown code blocks and repairs broken/unclosed braces automatically
Retries & Backoff Exponential backoff with jitter on 429 and 5xx errors
Real-time Cost Tracking Precise USD pricing calculation per 1M tokens from built-in pricing tables
Spend budgets Monthly, per-provider, and per-job USD caps (block or warn)
Zero-Latency Logging Logs saved automatically via after_response lifecycle or background queue
Telemetry Dashboard 30-day spend, failure rate, JSON recovery rate, latency p95, daily cost chart
Filament Widget Optional ready-to-use widget for Filament v3/v4 admin panels
Filament nav (new tab) Admin sidebar AI Hub opens /ai-hub Studio in a new browser tab

Installation

Upgrading

Studio (/ai-hub) reads the package model catalog automatically after an upgrade. Re-publishing config is optional:

--force overwrites a previously published config/ai-hub.php. Skip it if you customized that file — new models still appear in the dropdown.

If Studio still shows the old layout (no Playground tab, no Studio v1.7.1 badge), Laravel is using a published copy at resources/views/vendor/ai-hub/studio.blade.php. That file wins over the package. Either delete it, or refresh it:

Environment Configuration (.env)

Tip: You can leave .env empty and configure all keys and models visually via the /ai-hub Studio UI. Keys are stored encrypted in the database.


Visual Studio (/ai-hub) & Visual Telemetry

Visit /ai-hub in your browser after installing. The Studio provides a real-time visual control room for all 13 providers, credential management, interactive prompting, live streaming, and full financial cost telemetry.


1. Studio Dashboard — Provider Credentials, Models & Instant Save

Manage all 13 providers with masked encryption, instant per-card saving, live connection testing, and single-click default provider assignment.

Key Dashboard Highlights:


2. Interactive Playground — Real-Time Streaming & Hybrid Reasoning Controls

Run live prompts, stream completions token-by-token over SSE, toggle thinking budgets, and inspect exact token usage and financial cost before deploying to production.


3. Conversational Multi-Turn Demo & Live Dialogue Simulation

Simulate persistent conversation sessions with automatic context retention, turn tracking, and cumulative session cost telemetry via AIHub::chat():


4. Costing & Usage Analytics Dashboard

View full 30-day telemetry, live USD spend calculations, budget enforcement, latency percentiles, and per-job cost attribution.


Priority Chain & Automatic Failover

Configure provider priority in /ai-hub (drag-and-drop or click Make #1) or directly in config/ai-hub.php:

CLI Alternative (ai-hub:configure)


Supported Providers & Latest 2026 Models

Provider Key Flagship & Hybrid Reasoning Models
Google Gemini gemini gemini-4-argon (1M context frontier reasoning), gemini-3.8-flash, gemini-3.8-pro, gemini-3.8-flash-lite, gemini-3.7-flash, gemini-3.7-pro, gemini-2.5-pro, gemini-2.5-flash, gemini-2.0-flash
OpenAI openai gpt-6-luna ($0.10/1M ultra-fast), gpt-6-sol, gpt-6-astra, gpt-6, gpt-5.6-luna, gpt-5.6-terra, gpt-5.6-sol, o3, o3-mini, o4-mini, o1, o1-pro, gpt-4.5, gpt-4o
Anthropic Claude claude claude-opus-5.5, claude-sonnet-5.5, claude-haiku-5.5, claude-fable-5.1, claude-opus-4.5, claude-3-7-sonnet-latest (Extended Thinking), claude-sonnet-4-latest, claude-haiku-4-latest
xAI Grok grok grok-4.7 (Flagship reasoning, 500k context), grok-4.6, grok-4.5, grok-4.3 (1M context), grok-4.20, grok-build-0.1, grok-4.1-fast, grok-3, grok-2
DeepSeek deepseek deepseek-v4.1-flash (1M context multimodal), deepseek-v4-pro, deepseek-v4, deepseek-chat (V3), deepseek-reasoner (R1), deepseek-coder
Mistral AI mistral mistral-large-4 (1M context frontier), mistral-medium-3.5, mistral-small-4, mistral-saba-latest, codestral-2501, devstral-latest, ministral-14b-latest, pixtral-large-latest
Groq (LPU Speed) groq llama-3.3-70b-versatile, deepseek-r1-distill-llama-70b, deepseek-r1-distill-qwen-32b, qwen-2.5-coder-32b, llama-3.1-8b-instant
Ollama (Local) ollama llama3.3, llama3.2, deepseek-r1, deepseek-v3, qwen2.5-coder, qwen2.5, mistral-small, phi4, gemma2, llama3.2-vision
OpenRouter openrouter google/gemini-4-argon, openai/gpt-6-luna, anthropic/claude-sonnet-5.5, anthropic/claude-3.7-sonnet, deepseek/deepseek-v4.1-flash, x-ai/grok-4.7
Azure OpenAI azure gpt-6-luna, gpt-6, gpt-5, gpt-4.5-preview, gpt-4o, gpt-4o-mini, o3-mini, o1, o1-pro
Together together meta-llama/Llama-3.3-70B-Instruct-Turbo, Qwen/Qwen2.5-Coder-32B-Instruct, deepseek-ai/DeepSeek-R1, deepseek-ai/DeepSeek-V3
Fireworks fireworks accounts/fireworks/models/llama-v3p3-70b-instruct, accounts/fireworks/models/deepseek-r1, accounts/fireworks/models/deepseek-v3
Perplexity perplexity sonar-deep-research, sonar-reasoning-pro, sonar-reasoning, sonar-pro, sonar

Usage Guide

Dynamic Model Selection & Purpose-Based Routing

A common real-world architecture in modern Laravel AI apps:

Scenario: "My application default is OpenAI (or OpenAI is #1 in priority), but for specific purposes like vision/OCR, 1M long-context documents, high-volume extraction, or low cost, I need to use Google Gemini (or Claude, DeepSeek). How do we handle this cleanly?"

The Frontier Spotlight: OpenAI GPT Luna vs. Google Gemini 4 Argon

Metric / Dimension OpenAI GPT-6 Luna (gpt-6-luna) Google Gemini 4 Argon (gemini-4-argon)
Role & Architecture Ultra-fast, lightweight high-throughput daily driver Flagship frontier reasoning & deep agentic workflow engine
Token Pricing \$0.10 input / \$0.50 output per 1M tokens \$2.00 input / \$10.00 output per 1M tokens
Context Window 128,000 tokens 1,000,000 tokens (1M decode capacity)
Best For High-volume chat, sub-second API classification, tagging, JSON extraction Large repository refactoring, autonomous vulnerability patching, mathematical proofs
Reasoning Control ->reasoningEffort('low'|'medium'|'high') ->thinking(4096) hybrid reasoning budget

1. Direct Provider & Model Shortcut (Most Common)

You can call any provider at any time without altering your .env or global priority chain:

2. Smart Model Auto-Detection

Pass any model ID to AIHub::model(), and AI Hub automatically detects and selects the right driver:

3. Unified using() Helper

Select both the provider and model in a single fluent call:

4. Scoped Priority & Fallback Chains

Override the failover priority order for a specific task. Try Gemini first (e.g. for cost efficiency or speed); if Gemini hits a 429 rate limit or outage, safely fall back to OpenAI:

Safe Model Normalization: When failover triggers across providers, AI Hub automatically normalizes the model to the fallback provider's default model (e.g. gpt-5.6-luna), avoiding 404/400 errors from unrecognized model IDs.

5. Isolate Purpose Without Failover

When a task strictly requires Gemini-specific features (e.g. Google search grounding or 2M context window), disable failover so it never falls back to an incompatible provider:

6. Purpose-Specific Named Prompt Templates

Configure named prompt templates in Studio (/ai-hub) or DB. Each template can have its own dedicated provider and model:

In your PHP code, simply call the template name:

7. Purpose-Tagged Job Budgets & Observability

Tag requests with forJob() to monitor costs and enforce USD spend limits per purpose:

8. Multi-Turn Chat Sessions with Custom Routing

When managing multi-turn chat sessions (AIHub::chat()), target any provider and model:

Hybrid Thinking & Reasoning Engine

Seamlessly configure thinking token budgets on hybrid reasoning models (Google Gemini 3.8/3.7, Claude 3.7 Sonnet) or reasoning effort on OpenAI o-series / GPT-5:

JSON Auto-Recovery (Fixes Malformed LLM JSON)

LLMs often wrap JSON in markdown blocks or cut off closing brackets. recoverJson() automatically repairs the syntax:

Structured Outputs & Strict JSON Schemas

Enforce valid, structured JSON conforming to your custom schema across OpenAI, Azure, Gemini, and Claude:

Server-Sent Events (SSE) & Browser Streaming

Stream AI completions directly into browser frontend apps (Fetch API, EventSource, or Inertia.js):

Multi-turn Conversational Chat Sessions (AIHub::chat())

Manage persistent, multi-turn dialogue sessions with automatic context retention, turn tracking, and accumulated token cost calculation:

Testing Assertion Engine (AIHub::fake())

Mock AI responses and assert outbound requests with Laravel-style testing syntax without hitting real APIs or incurring costs:

Tools, vision, cache, and prompt templates

Vector Embeddings

Tagging Workflows & Background Jobs

Tag your requests to trace spend by feature in Analytics:


Failover Priority Chain

Configure provider priority in /ai-hub or in config/ai-hub.php:


How Logging Works (Zero Queue Worker Required)

The package captures comprehensive telemetry without slowing down your user's web requests:

Mode Worker Needed? User Latency Description
after_response (Default) No ❌ 0ms Executes database logging immediately after HTTP response is returned to browser.
queue Yes ✅ 0ms Pushes TrackAiUsageJob to your background queue (Redis/Database/Horizon).
sync No ❌ ~1-2ms Synchronous direct database insert (ideal for testing/CLI).

Automatic Log Pruning

AiRequestLog uses Laravel's MassPrunable trait. Clean up old logs automatically in your scheduler (routes/console.php):


Security & Access Control for /ai-hub

The package includes built-in AuthorizeStudio middleware to protect /ai-hub Studio from unauthorized access.

1. Dedicated Callback (AIHub::auth) — Recommended

In your app/Providers/AppServiceProvider.php (or AuthServiceProvider.php):

2. Role & Email Protection via .env

3. Laravel Gate (viewAiHub)

4. Custom Middleware Stack via .env


Filament admin

When Filament is installed, the panel sidebar gets an AI Hub item that opens Studio (/ai-hub) in a new tab. Dashboard widget stats do the same.


Analytics API

Access aggregated telemetry programmatically:


License

MIT © Imran Dev BD


Developed by Imran Dev BD

Platform Link
Portfolio imrandev.bd
LinkedIn linkedin.com/in/imranbru99
GitHub github.com/imranbru99
X / Twitter @imrandev_bd
YouTube @ImranDevBD
Facebook ExpertImranDev
WhatsApp +880 1576-918420
Email [email protected]
All Links linktr.ee/ExpertImranDev

Need help or have questions? Contact → imrandev.bd/contact


All versions of laravel-ai-hub with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/queue Version ^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package imrandevbd/laravel-ai-hub contains the following files

Loading the files please wait ...