adachsoft/ai-model-list-provider-xai
最新稳定版本:v0.2.0
Composer 安装命令:
composer require adachsoft/ai-model-list-provider-xai
包简介
XAI (Grok) SPI provider for AdachSoft AI Model List.
README 文档
README
Provider implementation for adachsoft/ai-model-list using the XAI (Grok) API.
- Provider ID:
xai - HTTP endpoint:
GET https://api.x.ai/v1/modelswith headerAuthorization: Bearer <apiKey> - Default timeout: 10.0s (internal, via factory)
Installation (local path)
{
"repositories": [
{ "type": "path", "url": "../ai-model-list-provider-xai", "options": { "symlink": true } }
],
"require": {
"adachsoft/ai-model-list-provider-xai": "*"
}
}
Library composer.json should contain:
{
"name": "adachsoft/ai-model-list-provider-xai",
"autoload": { "psr-4": { "AdachSoft\\AIModelListProviderXai\\": "src/" } }
}
Then run in the consumer project:
composer update adachsoft/ai-model-list-provider-xai
Quick Start (Factory)
use AdachSoft\AIModelList\PublicApi\Builder\AiModelCatalogFacadeBuilder;
use AdachSoft\AIModelListProviderXai\Factory\XaiSpiProviderFactory;
$provider = XaiSpiProviderFactory::create($apiKey);
$facade = (new AiModelCatalogFacadeBuilder())
->withSpiProvider($provider)
->build();
$models = $facade->listModels('xai'); // returns PublicApi\Collection\ModelDefinitionCollection
foreach ($models as $model) {
echo $model->modelId, "\n"; // modelId is a string in Public API DTO
}
CLI example
- Create a
.envfile in the project root:
XAI_API_KEY=your_real_api_key
- Run:
php bin/xai-list-models
The script reads .env, builds the provider via the factory, and prints model IDs using adachsoft/console-io output.
Notes
- Endpoint is fixed to
https://api.x.ai(no configurable base URL). - Capabilities mapping (heuristic): CHAT for all; IMAGE when model id contains
vision; AUDIO/EMBEDDING not supported. - Configuration DTO validates primitives in the constructor; base URL is not exposed.
- Exception classes are not covered by unit tests per project guidelines.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-19