Runnable examples in four languages
Download safe Python, TypeScript, cURL, and C# workflows with quote-only preparation, persistent idempotency, resumable polling, and actual asset downloads.
On this page
Choose a workflow
Each example discovers the current model, quotes before creation, saves private state, polls the same task, and saves real output bytes. They are learning examples, not production SDKs. Download and inspect code before running it.
| Language | Download | Requirements | Validation |
|---|---|---|---|
| Python | animation-workflow.py | Python 3.10+, standard library | Offline workflow tests |
| TypeScript | typescript.ts | Node.js 22.14+ | Strict types and offline workflow tests |
| cURL | curl.sh | Bash, curl 7.55+, jq, SHA-256 utility; PNG input | Shell syntax and local HTTP Mock |
| C# | csharp.cs + project file | .NET 8 SDK | Syntax parsing only; no .NET SDK on the validation host |
Read the complete sample README and API quickstart first. The generated API reference is the authoritative parameter reference.
Prepare without starting paid work
Keep ANIMGEN_API_KEY private. Set IMAGE_PATH to your image and ANIMGEN_MODEL to an ID from GET /v1/models. Leave ANIMGEN_APPROVE_CREDITS unset for the first TypeScript, cURL, or C# run. A verified AnimGen account is required; generation also needs sufficient credits.
Choose exactly one command for your language:
# TypeScript
node --experimental-strip-types typescript.ts
# cURL
bash curl.sh
# C#: keep both downloads in the same isolated directory
dotnet build AnimGenPublicApiExample.csproj
dotnet run --project AnimGenPublicApiExample.csproj
For Python, use the separate prepare and run commands in the quickstart. The other examples stop after showing a quote until you set ANIMGEN_APPROVE_CREDITS to an explicitly accepted amount and rerun the same command with the same saved state.
Keep state private and recover the same operation
TypeScript and C# use ANIMGEN_STATE (default animgen-state.json); cURL uses ANIMGEN_STATE_DIR (default animgen-curl-state); Python uses --state. Formats differ: never switch implementations to retry an operation. Run only one process per state.
State includes the input image and prompt. Keep it outside version control, in a private directory. It stores account and API key IDs but not the secret key. Restrict Windows directory ACLs yourself. Optional ANIMGEN_OUTPUT chooses the download directory for TypeScript/C#/cURL; Python uses --output.
After an uncertain create, preserve the exact state, account, original API key identity, request body, and idempotency key. Switching keys changes the server's idempotency scope. The examples stop automatic recovery of an unresolved create after 24 hours. A local timeout is not remote cancellation.
After a task ID is saved, a rerun polls that task rather than creating again. Failed or cancelled tasks may still return assets: the examples save them, then exit nonzero to report an incomplete result. Signed downloads do not carry your API Authorization header, and expired links are refreshed through asset metadata.
What was tested
Python, TypeScript, and cURL cover quote-only preparation, guarded creation, stable state, polling, and partial downloads with mocks. Python/TypeScript additionally simulate a lost create response and retry with the original key. No paid provider calls are part of documentation validation. C# has syntax validation only; build and review it with .NET 8 before any real use.
See errors and retries and polling and downloads when adapting these examples.
Was this page helpful?
No search queries, code, or free text are collected. This switch controls documentation interactions only; general site analytics follow the privacy policy. Privacy policy