承接 mmorand/laravel-apertus 相关项目开发

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

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

mmorand/laravel-apertus

最新稳定版本:0.2.0

Composer 安装命令:

composer require mmorand/laravel-apertus

包简介

Laravel package for the Swiss made Apertus LLM

README 文档

README

Apertus Logo

Laravel Client for Apertus LLM

Latest Version on Packagist Total Downloads

The Apertus AI PHP Client enables seamless integration with the Apertus AI API, providing straightforward access to Swiss AI models for chat completions and model management.

More informations about Apertus AI can be found on their website and API Reference.

Features

  • Chat Completions - Full conversation support with streaming
  • Model Management - List available models
  • Laravel Integration - Native Laravel support with Facades
  • Type Safety - Fully typed DTOs using Spatie Laravel Data
  • Modern PHP - Built with PHP 8.3+ and Saloon HTTP client

Installation

You can install the package via Composer:

composer require mmorand/laravel-apertus

You can publish the config file with:

php artisan vendor:publish --tag="apertus-config"

This is the contents of the published config file:

return [
    'api_key' => env('APERTUS_API_KEY'),
    'base_url' => env('APERTUS_BASE_URL', 'https://api.publicai.co'),
    'user_agent' => env('APERTUS_USER_AGENT', 'Apertus-Laravel-Client/1.0.0'),
    'timeout' => env('APERTUS_TIMEOUT', 60),
];

Add your Apertus API key to your .env file:

APERTUS_API_KEY=your_api_key_here
APERTUS_BASE_URL=https://api.publicai.co
APERTUS_USER_AGENT=MyApp/1.0
APERTUS_TIMEOUT=30

Get your API key from the Apertus AI Console.

Usage

Basic Setup

Create an instance of the Apertus client to start interacting with the API:

use Mmorand\Apertus\Apertus;
use Mmorand\Apertus\Enums\Model;

// Instantiate the client
$apertus = new Apertus(
    apiKey: config('apertus.api_key'),
    baseUrl: 'https://api.publicai.co',
    userAgent: 'MyApp/1.0'
);

// Or use the Facade (Laravel)
use Mmorand\Apertus\Facades\Apertus;

Apertus::chat();
Apertus::models();

Chat Completions

Create a chat completion:

use Mmorand\Apertus\Facades\Apertus;
use Mmorand\Apertus\Enums\Model;

$response = Apertus::chat()->create(
    model: Model::apertus8b,
    messages: [
        [
            'role' => 'user',
            'content' => 'Hello! Can you help me understand Swiss AI?',
        ]
    ],
    temperature: 0.7,
    maxTokens: 1000
);

/** @var \Mmorand\Apertus\Dto\Chat\ChatCompletionResponse $dto */
$dto = $response->dto();

Model Management

List available models:

$response = Apertus::models()->list();

/** @var \Mmorand\Apertus\Dto\Models\ModelsResponse $dto */
$dto = $response->dto();

Artisan Commands

List available models using Artisan:

php artisan apertus:models

Available Models

The following models are available in the Apertus API. You can use the Model enum in this package to refer to them.

Enum Case Model Name Documentation Link
Model::apertus8b 'swiss-ai/apertus-8b-instruct' Apertus 8b Docs
Model::apertus70b 'swiss-ai/apertus-70b-instruct' Apertus 70b Docs
use Mmorand\Apertus\Enums\Model;

Model::apertus8b  // swiss-ai/apertus-8b-instruct - Small Apertus model
Model::apertus70b // swiss-ai/apertus-70b-instruct - Complete Apertus model

Testing

Run the tests with:

composer test

Static Analysis

Analyze code with PHPStan:

composer analyse

Code Style

Fix code style with Laravel Pint:

composer format

Inspired by the excellent work of HelgeSverre with his Mistral package.

License

The MIT License (MIT). Please see License File for more information.

Disclaimer

Apertus AI and the Apertus logo are trademarks of their respective owners. This package is not affiliated with, endorsed by, or sponsored by Apertus AI. All trademarks and registered trademarks are the property of their respective owners.

See the Terms and Conditions for more information.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固