vaultic/sdk
Composer 安装命令:
composer require vaultic/sdk
包简介
Official PHP SDK for the Vaultic API
README 文档
README
Official PHP SDK for the Vaultic API. This SDK provides a simple and intuitive interface for interacting with the Vaultic API to manage prompts, projects, and more.
Installation
Install the package via Composer:
composer require vaultic/sdk
Requirements
- PHP 8.0 or higher
- Composer
- Guzzle HTTP Client (automatically installed via Composer)
Quick Start
<?php require 'vendor/autoload.php'; use Vaultic\VaulticClient; // Initialize the client with your API key $client = new VaulticClient('vt_your_api_key_here'); // Get a prompt with variables $prompt = $client->prompts->get('0sZNC8EC9D', [ 'variables' => [ 'user_name' => 'John', 'issue' => 'Password reset' ] ]); echo $prompt['system_content']; echo $prompt['user_content'];
Configuration
You can customize the client with additional configuration options:
$client = new VaulticClient('vt_your_api_key_here', [ 'baseUrl' => 'https://app.vaultic.io/api/v1', // Custom API URL 'timeout' => 30, // Request timeout in seconds 'enableLogging' => false, // Enable request/response logging 'userAgent' => 'MyApp/1.0.0', // Custom User-Agent ]);
Usage Examples
Prompts
Get a Prompt
// Get a prompt by ID $prompt = $client->prompts->get('prompt_id_here'); // Get a prompt with variables replaced $prompt = $client->prompts->get('prompt_id_here', [ 'variables' => [ 'name' => 'John Doe', 'email' => 'john@example.com' ] ]);
Get a Specific Version
$prompt = $client->prompts->getVersion('prompt_id_here', '1.0.0', [ 'variables' => ['name' => 'John'] ]);
Get Prompts for a Project
$prompts = $client->prompts->getProjectPrompts('project_id_here', [ 'page' => 1, 'per_page' => 20, 'variables' => [ 'name' => 'John', 'email' => 'john@example.com' ] ]);
Projects
Get a Project
$project = $client->projects->get('project_id_here');
List All Projects
$projects = $client->projects->list([ 'page' => 1, 'per_page' => 20 ]);
Helper Classes
The SDK includes helper classes for working with variables in prompts:
VariableReplacer
Replace variables in prompt content:
use Vaultic\Helpers\VariableReplacer; $prompt = [ 'system_content' => 'Hello {{name}}', 'user_content' => 'Email: {{email}}' ]; $result = VariableReplacer::replace($prompt, [ 'name' => 'John', 'email' => 'john@example.com' ]);
VariableExtractor
Extract variable names from prompts:
use Vaultic\Helpers\VariableExtractor; $variables = VariableExtractor::extract($prompt); // Returns: ['name', 'email']
VariableValidator
Validate that all required variables are provided:
use Vaultic\Helpers\VariableValidator; $result = VariableValidator::validate($prompt, [ 'name' => 'John', 'email' => 'john@example.com' ]); if ($result['valid']) { echo "All variables provided"; } else { echo "Missing: " . implode(', ', $result['missing']); }
Error Handling
The SDK throws specific exceptions for different HTTP status codes:
use Vaultic\Exceptions\UnauthorizedException; use Vaultic\Exceptions\NotFoundException; use Vaultic\Exceptions\RateLimitException; use Vaultic\Exceptions\VaulticException; try { $prompt = $client->prompts->get('invalid_id'); } catch (UnauthorizedException $e) { echo "Invalid API key"; } catch (NotFoundException $e) { echo "Prompt not found"; } catch (RateLimitException $e) { echo "Rate limit exceeded. Retry after: " . $e->getRetryAfter() . " seconds"; } catch (VaulticException $e) { echo "Error: " . $e->getMessage(); echo "Status Code: " . $e->getStatusCode(); }
Available Exceptions
VaulticException- Base exception for all Vaultic errorsUnauthorizedException- 401 UnauthorizedForbiddenException- 403 ForbiddenNotFoundException- 404 Not FoundUnprocessableEntityException- 422 Validation ErrorRateLimitException- 429 Rate Limit ExceededServerException- 500+ Server Errors
Testing
Run the test suite:
composer test
Or with PHPUnit directly:
./vendor/bin/phpunit
Development
Running Static Analysis
composer analyse
Code Style
This package follows PSR-12 coding standards.
License
This SDK is licensed under the MIT License. See the LICENSE file for details.
Support
For API documentation and support, visit https://vaultic.io/documentation
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
vaultic/sdk 适用场景与选型建议
vaultic/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 209 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「sdk」 「prompts」 「vaultic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vaultic/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vaultic/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vaultic/sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An AI bot made for the command line that can read and understand any codebase from your Laravel app.
Deck is a Laravel and PHP package for versioned, file-based AI prompt management with variable interpolation, performance tracking, A/B testing, and optional Laravel AI SDK integration.
Deck is a Laravel and PHP package for versioned, file-based AI prompt management with variable interpolation, performance tracking, A/B testing, and optional Laravel AI SDK integration.
A PSR-7 compatible library for making CRUD API endpoints
Templating library for ai prompts.
Production-ready AI workflows for Laravel — resilient calls with retries, fallback models, and prompt management.
统计信息
- 总下载量: 209
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-20