Version-independent adapter run through the authenticated Val Town MCP. No public HTTP handler. Code is public because the account is on the free tier; API secrets and actual job prompts must never be placed in these files.
W tym val otwórz Environment Variables w lewym panelu i dodaj:
- ARK_API_KEY: sekretny klucz BytePlus. Nie Resource ID apikey-…
- ARK_MODEL: dokładne model ID albo ep-… z konsoli BytePlus. Nie nazwa marketingowa.
Nie przesyłaj klucza w czacie. Potem poproś asystenta o uruchomienie check_connection.ts. Ten test czyta listę zadań; nie generuje płatnego filmu i nie potwierdza uprawnienia do każdego modelu.
Opcjonalnie MAX_VIDEO_SECONDS (domyślnie 30) i MAX_DAILY_JOBS (domyślnie 10, ruchome 24h). Limity konektora nie są limitami dostawcy ani gwarancją ceny. Zmiana sekretów/konfiguracji nie wymaga zmiany kodu.
- main.ts: refresh official public announcements, show registry and configuration, no generation.
- check_connection.ts: live task-list authentication test, no generation.
- submit.ts: submit exactly one explicitly authorized draft; paid action.
- status.ts: poll up to ten known submitted tasks; return video links when ready.
- recent.ts: list ten recent provider tasks after an ambiguous submission.
- tests.ts: local validation in Val Town, no paid API requests.
Run through Val Town MCP run_file with val=rafalwiktorowicz/seedance. This is a collection of scripts invoked through the EXISTING Val Town MCP, not a second standalone MCP server and not five newly registered tools.
No Seedance version is hard-coded as the selected model. Any valid model ID / endpoint ID can be supplied, subject to provider compatibility. For the default, set ARK_MODEL. For multiple enabled models, store exact IDs in the val-scoped models table, with source and timestamp. Never infer an API ID from a marketing name.
Each main.ts invocation fetches official BytePlus pages and extracts visible Seedance version announcements. It stores first_seen and last_seen, and reports newly_seen. A parser/network failure is explicit. This is best-effort public-source discovery, NOT an exhaustive authenticated catalog, a push notification, or proof of account access. No unverified GET /models endpoint is used. Discovery does not switch models or spend credits. Future 4.0 is only a hypothetical example; tests use a synthetic fixture.
No confirmed account model-list API has been integrated. New private endpoints created in the BytePlus console must be registered explicitly (ARK_MODEL or models table). A model using the same video task API requires no version-specific code change; a new protocol, region/base URL, content type or authentication scheme requires adapter review. The fixed API host protects the API key from arbitrary forwarding.
Use ONLY this val's project-scoped SQLite, never legacy global database. Run main.ts once to initialize tables. Store a unique stable request_id, full provider JSON body in payload, and authorized=1 ONLY after user authorization of that generation. Do not put prompts/reference URLs into public source files. The primary key prevents duplicate queue insertion. Do not reset an existing job to draft or change its payload to retry.
Example parameterized INSERT (values supplied via SQL args, not string interpolation):
INSERT INTO jobs(request_id,payload,authorized) VALUES(?,?,1)
Payload requires model, content and explicit duration. Other JSON provider parameters are passed through; verify support against selected model. HTTPS reference images/videos/audio supported. No local uploads, callback URLs or credentials in payload. API key only in Environment Variables.
Model registry INSERT (if not using ARK_MODEL):
INSERT INTO models(id,label,enabled,source,updated_at) VALUES(?,?,1,?,?)
An atomic claim transitions one authorized draft to submitting before the API request, with a rolling daily job-count limit. Parallel runners cannot claim the same draft. No automatic paid POST retry. A crash can leave submitting, or a timeout uncertain. Inspect recent.ts and BytePlus console before any NEW request. Rejected requests also count toward the submission limit. This is duplicate suppression, not a provider-guaranteed exactly-once transaction.
Results and job IDs persist in SQLite; get video download links from status.ts. Download generated assets promptly; this adapter doesn't automatically archive MP4 or perform editing. Current model account access and billing remain untested until credentials are provided; creation must be tested separately.
Generation REST host, create/get/list routes and payload structure checked against official byteplus-python-sdk-v2 3.0.60 (resources/content_generation/tasks.py, _constants.py, content types). https://github.com/byteplus-sdk/byteplus-python-sdk-v2 https://docs.byteplus.com/en/docs/ModelArk/1520757 https://docs.byteplus.com/en/docs/ModelArk/1330310 https://docs.byteplus.com/en/docs/ModelArk/2607688 https://docs.val.town/reference/std/sqlite/usage https://docs.val.town/reference/environment-variables
BytePlus documentation content sometimes returns only a navigation shell. Such a response is not treated as a verified model catalog or account entitlement.