承接 adachsoft/ai-integration-xai 相关项目开发

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

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

adachsoft/ai-integration-xai

最新稳定版本:v0.1.1

Composer 安装命令:

composer require adachsoft/ai-integration-xai

包简介

xAI SPI provider for adachsoft/ai-integration: tool-calling chat integration with Grok models (OpenAI-compatible endpoint).

README 文档

README

adachsoft/ai-integration-xai is a small integration library that plugs the x.ai chat completions API into the adachsoft/ai-integration package using a tool-calling capable SPI.

It provides a tiny, focused adapter that exposes x.ai as an OpenAI-compatible tool-calling chat provider.

Features

  • Minimal integration layer for x.ai chat completions
  • OpenAI-compatible tool-calling SPI using OpenAiCompatibleToolCallingChatSpi
  • Simple configuration via the XaiConfig value object
  • Factory XaiToolCallingChatSpiFactory that wires configuration into the SPI implementation
  • Sensible defaults for base URI and model ID

Requirements

  • PHP 8.3 or higher
  • adachsoft/ai-integration package (for SPI interfaces and OpenAI-compatible implementation)
  • An active x.ai API key

Installation

Install via Composer:

composer require adachsoft/ai-integration-xai

Make sure you also have adachsoft/ai-integration installed; Composer will usually handle this automatically via dependencies.

Configuration

The library exposes a single configuration value object: AdachSoft\AiIntegrationXai\Config\XaiConfig.

use AdachSoft\AiIntegrationXai\Config\XaiConfig;

$xaiConfig = new XaiConfig(
    apiKey: 'your-xai-api-key',
    defaultModelId: 'grok-4', // optional, default is 'grok-4'
    baseUri: 'https://api.x.ai/v1/chat/completions', // optional, default x.ai chat endpoint
    providerId: 'xai', // optional, identifier used by ai-integration
);

You can keep this configuration in your dependency injection container or any other configuration layer used in your application.

Usage

The main entry point of this library is the factory AdachSoft\AiIntegrationXai\XaiToolCallingChatSpiFactory, which produces a ToolCallingChatSpiInterface compatible instance backed by x.ai.

use AdachSoft\AiIntegrationXai\Config\XaiConfig;
use AdachSoft\AiIntegrationXai\XaiToolCallingChatSpiFactory;
use AdachSoft\AiIntegration\Spi\ToolCalling\ToolCallingChatSpiInterface;

$xaiConfig = new XaiConfig(apiKey: 'your-xai-api-key');

$factory = new XaiToolCallingChatSpiFactory($xaiConfig);

/** @var ToolCallingChatSpiInterface $chatSpi */
$chatSpi = $factory->create();

// You can now pass $chatSpi to the ai-integration tooling that expects a ToolCallingChatSpiInterface

From this point on, you should use the standard APIs exposed by adachsoft/ai-integration for building prompts, registering tools, and executing tool-calling chat interactions. This library is intentionally thin and only concerns itself with wiring x.ai into that SPI.

Default Model

The XaiConfig exposes a defaultModelId property (default grok-4). Depending on your usage of adachsoft/ai-integration, you may:

  • Use this value as the default model when constructing higher-level services
  • Override it per-request when your domain logic requires a different model

Versioning and Changelog

This library follows semantic versioning. All notable changes are documented in CHANGELOG.md.

The first tagged version is 0.1.0, which provides the initial x.ai tool-calling integration.

Testing

This project includes unit tests and a dedicated production test for the actual x.ai integration. To run the test suite, use:

vendor/bin/phpunit

Production tests that hit the real x.ai API are grouped separately (for example under a production group); consult the tests under tests/Production before running them against live services.

License

This library is open-sourced under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固