承接 omer-hanaraey/laravel-ai-gateway 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

omer-hanaraey/laravel-ai-gateway

最新稳定版本:v0.3.0

Composer 安装命令:

composer require omer-hanaraey/laravel-ai-gateway

包简介

A unified interface for multiple AI providers in Laravel

README 文档

README

A unified interface for multiple AI providers in Laravel applications.

Features

  • Support for multiple AI providers (OpenAI, Gemini, Claude, DeepSeek, Mistral, and Cohere)
  • Unified API interface
  • Easy driver switching
  • Standardized response format
  • Facade access

Installation

  1. Install via Composer:
composer require omer-hanaraey/laravel-ai-gateway
  1. Publish the configuration file:
php artisan vendor:publish --tag=ai-bridge-config

Configuration

Add your API keys to your .env file:

AI_DEFAULT_DRIVER=openai

OPENAI_API_KEY=your_openai_key
OPENAI_MODEL=gpt-3.5-turbo

GEMINI_API_KEY=your_gemini_key
GEMINI_MODEL=gemini-pro

CLAUDE_API_KEY=your_claude_key
CLAUDE_MODEL=claude-2

DEEPSEEK_API_KEY=your_deepseek_key
DEEPSEEK_MODEL=deepseek-chat

MISTRAL_API_KEY=your_mistral_key
MISTRAL_MODEL=mistral-large-latest

COHERE_API_KEY=your_cohere_key
COHERE_MODEL=command-a-03-2025
COHERE_CLIENT_NAME=your_cohere_client

Usage

Usage Examples 🧑‍💻

use LaravelAiGateway\Ai\Facades\Ai;

$response = Ai::chat([
    ['role' => 'system', 'content' => 'You are a helpful assistant'],
    ['role' => 'user', 'content' => 'Tell me a joke about Laravel']
]);

echo $response->getContent();

Using Specific Drivers

$response = Ai::driver('claude')
    ->withModel('claude-3-haiku-20240307')
    ->chat([...]);

Available Methods

  • chat(array $messages): Send chat completion
  • driver(string $name): Switch between providers

Response Format 📦

All responses implement AiResponseInterface with these methods:

  • getContent(): string - Get the response content
  • getUsage(): array - Get usage statistics
  • isSuccessful(): bool - Check if request succeeded

Testing 🧪

Run the tests with:

composer test tests

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License 📄

MIT License - Free for commercial and personal use.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-09