快速图像模型即时返回;视频通过webhook或轮询异步执行——同一个客户端,同一个方法。
HMAC-SHA256校验,附带防重放时间戳。一行代码,开箱即安全。
每个响应都会把X-RateLimit-*响应头解析成对象返回,成功时如此,出错时同样如此。在撞上429之前就能调好节奏。
JS SDK使用原生fetch与Web Crypto,PHP SDK使用curl与ext-hash。放进任何环境都能跑。
挑一个最贴近你技术栈的语言——所有SDK暴露的接口一致,上手经验可以直接迁移。
安装
npm install @flixly/sdk快速上手
import { Flixly } from "@flixly/sdk";
const flixly = new Flixly({ apiKey: process.env.FLIXLY_API_KEY! });
const result = await flixly.generateAndWait({
model: "flux-dev",
prompt: "A cat wearing a top hat, oil painting style",
type: "TEXT_TO_IMAGE",
input: { aspect_ratio: "1:1", resolution: "1K" },
});
console.log(result.data.output_url);
// → https://cdn.flixly.ai/outputs/...校验webhook
// Verify incoming webhooks in your handler
import { Flixly } from "@flixly/sdk";
const valid = await Flixly.verifyWebhookSignature({
secret: process.env.FLIXLY_WEBHOOK_SECRET!,
timestamp: req.headers["x-flixly-timestamp"]!,
signature: req.headers["x-flixly-signature"]!,
body: rawBody, // raw, NOT JSON.parse + re-stringify
});
if (!valid) return res.status(401).end();安装
composer require flixly/sdk快速上手
use Flixly\Flixly;
use Flixly\FlixlyError;
$flixly = new Flixly(['api_key' => getenv('FLIXLY_API_KEY')]);
try {
$gen = $flixly->generateAndWait([
'model' => 'flux-dev',
'prompt' => 'A cat wearing a top hat, oil painting style',
'type' => 'TEXT_TO_IMAGE',
'input' => ['aspect_ratio' => '1:1', 'resolution' => '1K'],
]);
echo $gen['data']['output_url'];
// → https://cdn.flixly.ai/outputs/...
} catch (FlixlyError $e) {
error_log("Flixly: {$e->getErrorCode()} {$e->getMessage()}");
}校验webhook
// Verify incoming webhooks in your handler
$body = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_FLIXLY_SIGNATURE'] ?? '';
$timestamp = $_SERVER['HTTP_X_FLIXLY_TIMESTAMP'] ?? '';
$valid = Flixly::verifyWebhookSignature(
getenv('FLIXLY_WEBHOOK_SECRET'),
$timestamp,
$signature,
$body // raw body — do NOT json_decode + re-encode
);
if (!$valid) {
http_response_code(401);
exit;
}你用的语言我们还没有提供SDK?直接调用REST API——完整的机器可读规范见下方。