定制 token27/nexus-ai 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

token27/nexus-ai

最新稳定版本:v1.0.0

Composer 安装命令:

composer require token27/nexus-ai

包简介

Framework-agnostic AI communication engine with middleware pipeline architecture

README 文档

README

CI Latest Version PHP 8.2+ PHPStan Level 6 License: MIT

A framework-agnostic PHP 8.2+ library for communicating with AI providers. Supports text generation, image generation, embeddings, speech synthesis, transcription, streaming, tool calling, and structured output — through a unified, PSR-18 compliant interface.

Supported Providers

OpenAI · Anthropic · Google Gemini · Ollama · DeepSeek · Groq · Mistral · xAI · Perplexity

Features

  • Text generation with full conversation history support
  • Image generation (DALL-E 3, Imagen)
  • Text embeddings with batch support
  • Text-to-Speech and Speech-to-Text (Whisper)
  • Streaming via Server-Sent Events with typed chunks
  • Structured output — maps LLM responses directly to PHP DTOs
  • Tool calling with multi-step execution loops
  • Chat history — in-memory and file-based persistence
  • Middleware pipeline — Retry, Cache, Cost tracking, Rate limiting, Circuit breaker, Logging
  • Observability — EventBus with pluggable observers and metrics
  • FakeDriver for unit testing without API calls

Installation

composer require token27/nexus-ai

Requires a PSR-18 HTTP client:

composer require guzzlehttp/guzzle

Quick Start

use Token27\NexusAI\NexusAI;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;

$factory = new HttpFactory();

NexusAI::setHttpClient(new Client());
NexusAI::setFactories($factory, $factory);
NexusAI::configure([
    'openai' => ['api_key' => $_ENV['OPENAI_API_KEY']],
]);

$response = NexusAI::using('openai', 'gpt-4o')
    ->withSystemPrompt('You are a helpful assistant.')
    ->withPrompt('What is PHP?')
    ->asText();

echo $response->text;

Documentation

Full documentation is available in the docs/ directory:

Requirements

  • PHP 8.2 or higher
  • A PSR-18 HTTP client
  • PSR-17 HTTP factories

Contributing

Please see docs/contributing.md for details.

License

MIT. Please see LICENSE for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固