22
33Official runnable examples for the BeatAPI async AI video API.
44
5+ [ ![ Verify examples] ( https://github.com/erickkkyt/beatapi-examples/actions/workflows/verify.yml/badge.svg )] ( https://github.com/erickkkyt/beatapi-examples/actions/workflows/verify.yml )
6+
57[ Website] ( https://beatapi.io/ ) ·
68[ API documentation] ( https://docs.beatapi.io/ ) ·
79[ Music Video Playground] ( https://beatapi.io/music-video-api ) ·
@@ -17,6 +19,17 @@ The primary launch route is `POST /v1/music-video/tasks`.
1719Create task -> queued/processing -> succeeded/failed -> hosted output
1820```
1921
22+ ``` mermaid
23+ flowchart LR
24+ A["Create task"] --> B["queued / processing"]
25+ B --> C{"Final state?"}
26+ C -->|No| D["Wait 5-10 seconds"]
27+ D --> E["GET /v1/tasks/{task_id}"]
28+ E --> C
29+ C -->|succeeded| F["Read output.media"]
30+ C -->|failed| G["Inspect error_code and usage"]
31+ ```
32+
2033> This repository contains examples and a small reference client. It is not a
2134> versioned SDK and it does not contain the BeatAPI service implementation.
2235
@@ -41,7 +54,8 @@ curl https://api.beatapi.io/v1/music-video/tasks \
4154 "prompt": "Neon rooftop performance with cinematic light trails.",
4255 "language": "en",
4356 "aspect_ratio": "9:16",
44- "resolution": "720p"
57+ "resolution": "720p",
58+ "compose_mode": "auto"
4559 }'
4660```
4761
@@ -78,7 +92,8 @@ are available in `data.output.media`.
7892
7993### Node.js
8094
81- Requires Node.js 20 or newer. No install step is required.
95+ The dependency-free examples require Node.js 20 or newer. Repository
96+ verification requires Node.js 20.19+ or 22.12+.
8297
8398``` bash
8499node examples/node/music-video.mjs
@@ -157,6 +172,7 @@ credit, or concurrency errors.
157172Webhook requests include:
158173
159174``` text
175+ X-BeatAPI-Event
160176X-BeatAPI-Signature
161177X-BeatAPI-Timestamp
162178```
@@ -165,14 +181,28 @@ Verify the signature against the exact raw request body before parsing JSON,
165181and reject timestamps older than five minutes. The Node.js receiver example
166182implements HMAC-SHA256 verification with a constant-time comparison.
167183
184+ The signed JSON body uses ` event ` , not ` type ` :
185+
186+ ``` json
187+ {
188+ "id" : " evt_example_123" ,
189+ "event" : " task.succeeded" ,
190+ "created_at" : 1784188934 ,
191+ "data" : {
192+ "id" : " task_8K2qA" ,
193+ "status" : " succeeded"
194+ }
195+ }
196+ ```
197+
168198``` bash
169199export BEATAPI_WEBHOOK_SECRET=" whsec_your_secret"
170200node examples/node/webhook-server.mjs
171201```
172202
173203## Integration guides
174204
175- - [ n8n] ( integrations/n8n/README.md )
205+ - [ n8n guide and importable bounded-polling workflow ] ( integrations/n8n/README.md )
176206- [ Postman] ( integrations/postman/README.md )
177207- [ Sanitized response fixtures] ( fixtures/ )
178208- [ Production API reference] ( https://docs.beatapi.io/ )
@@ -202,6 +232,24 @@ npm run test:python
202232npm run verify
203233```
204234
235+ The public OpenAPI file is synchronized byte-for-byte from the private service
236+ repository:
237+
238+ ``` bash
239+ npm run sync:openapi
240+ npm run check:openapi-sync
241+ ```
242+
243+ Run a read-only production smoke test with:
244+
245+ ``` bash
246+ npm run smoke:live
247+ ```
248+
249+ Without ` BEATAPI_API_KEY ` , it checks anonymous workflow discovery. When the
250+ environment variable is present, it additionally verifies authenticated
251+ ` GET /v1/usage ` . The smoke test never creates tasks or consumes credits.
252+
205253## License
206254
207255Original example code in this repository is available under the
0 commit comments