<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged async-api</title>
<link>https://coderlegion.com/tag/async-api</link>
<description>Powered by Question2Answer</description>
<item>
<title>Four ways to reach the same video model, and what each one asks of you first</title>
<link>https://coderlegion.com/27019/four-ways-to-reach-the-same-video-model-and-what-each-one-asks-of-you-first</link>
<description>&lt;p&gt;Most &quot;how do I use model X&quot; questions are not really about prompting. They are&lt;br&gt;
about &lt;em&gt;where you type the prompt&lt;/em&gt;, and for Alibaba's Wan 3.0 that is genuinely&lt;br&gt;
confusing, because the model shipped as an API months before it shipped as&lt;br&gt;
anything a person could open.&lt;/p&gt;
&lt;p&gt;There are four routes in. The model at the far end is the same in all four. What&lt;br&gt;
differs is the paperwork.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Route &lt;/th&gt;&lt;th&gt;What you need before you can start &lt;/th&gt;&lt;th&gt;Who it suits&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Alibaba Cloud Model Studio &lt;/td&gt;&lt;td&gt;Cloud account, a region choice, an API key that matches that region &lt;/td&gt;&lt;td&gt;Teams already on Alibaba Cloud&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Qwen Cloud &lt;/td&gt;&lt;td&gt;An account; international access still rolling out &lt;/td&gt;&lt;td&gt;Developers outside China&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Alibaba's own consumer surfaces &lt;/td&gt;&lt;td&gt;An account, plus access being rolled out to members &lt;/td&gt;&lt;td&gt;People who want the first-party product&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;A hosted front end &lt;/td&gt;&lt;td&gt;Usually nothing, sometimes an email &lt;/td&gt;&lt;td&gt;One clip today&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;That table is the whole answer for most people. The rest of this post is the&lt;br&gt;
part that actually costs money if you skip it.&lt;/p&gt;
&lt;h3 id=&quot;the-region-key-pairing-is-a-real-constraint-not-boilerplate&quot;&gt;The region/key pairing is a real constraint, not boilerplate&lt;/h3&gt;
&lt;p&gt;On the official route, the API key is scoped to the region you picked. A key&lt;br&gt;
issued in one region will not authenticate against another region's endpoint,&lt;br&gt;
and the failure surfaces as an authentication error rather than &quot;wrong region&quot;,&lt;br&gt;
which sends people to rotate a perfectly good key.&lt;/p&gt;
&lt;p&gt;Worth knowing before you build routing: four of the five regions are priced&lt;br&gt;
identically and the fifth is about 25% more. If your traffic is not&lt;br&gt;
latency-sensitive, region choice is a billing decision that looks like an&lt;br&gt;
infrastructure decision.&lt;/p&gt;
&lt;h3 id=&quot;the-api-is-asynchronous-and-there-are-two-separate-24-hour-clocks&quot;&gt;The API is asynchronous, and there are two separate 24-hour clocks&lt;/h3&gt;
&lt;p&gt;You submit a job and poll. There is no callback in the published reference, and&lt;br&gt;
there is no documented cancel call — &lt;code&gt;CANCELED&lt;/code&gt; exists in the state enum, but&lt;br&gt;
nothing in the API puts a task into it. Once a thirty-second job is submitted,&lt;br&gt;
it is submitted.&lt;/p&gt;
&lt;p&gt;Then two clocks start, and they are not the same clock:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The &lt;code&gt;task_id&lt;/code&gt; is valid for 24 hours.&lt;/strong&gt; Query it later and you get &lt;code&gt;UNKNOWN&lt;/code&gt;,&lt;br&gt;
which is not a failure state. It means the system no longer remembers the job.&lt;br&gt;
A front end that maps &lt;code&gt;UNKNOWN&lt;/code&gt; onto &lt;code&gt;PENDING&lt;/code&gt; will spin forever — if you have&lt;br&gt;
ever watched a progress bar run past an hour, that is usually what you were&lt;br&gt;
watching.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The &lt;code&gt;video_url&lt;/code&gt; also expires 24 hours after success.&lt;/strong&gt; The file was&lt;br&gt;
generated, the money was spent, and if nobody fetched it, there is nothing to&lt;br&gt;
show. Copying the output into your own storage the moment a job succeeds is&lt;br&gt;
the single most important line in the integration, and it is the line people&lt;br&gt;
leave for later.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Six states exist in total: &lt;code&gt;PENDING&lt;/code&gt;, &lt;code&gt;RUNNING&lt;/code&gt;, &lt;code&gt;SUCCEEDED&lt;/code&gt;, &lt;code&gt;FAILED&lt;/code&gt;,&lt;br&gt;
&lt;code&gt;CANCELED&lt;/code&gt;, &lt;code&gt;UNKNOWN&lt;/code&gt;. Collapsing the last one into &quot;failed&quot; is the mistake that&lt;br&gt;
generates support tickets, because &quot;expired&quot; and &quot;failed&quot; have different causes&lt;br&gt;
and different remedies.&lt;/p&gt;
&lt;h3 id=&quot;concurrency-is-small-enough-to-design-around&quot;&gt;Concurrency is small enough to design around&lt;/h3&gt;
&lt;p&gt;Two concurrent tasks. A fifty-task queue. Thirty submissions a minute. A single&lt;br&gt;
generation usually runs one to five minutes, longer for longer clips.&lt;/p&gt;
&lt;p&gt;Batch four variants and you are running two and waiting on two. Nothing failed;&lt;br&gt;
two are queued. The useful consequence is that your rate limiter is probably&lt;br&gt;
guarding the wrong number — the submission ceiling is rarely what you hit first,&lt;br&gt;
concurrency is.&lt;/p&gt;
&lt;h3 id=&quot;the-default-that-quietly-quadruples-the-bill&quot;&gt;The default that quietly quadruples the bill&lt;/h3&gt;
&lt;p&gt;If you do not set &lt;code&gt;resolution&lt;/code&gt;, Wan 3.0 generates at 1080P. At Alibaba's&lt;br&gt;
published rates that is four times the per-second cost of 480P: a thirty-second&lt;br&gt;
clip is $6.00 instead of $1.50. Nothing errors and nothing warns you. One&lt;br&gt;
parameter.&lt;/p&gt;
&lt;p&gt;Related, and equally undocumented in most write-ups: prompt expansion is on by&lt;br&gt;
default. It helps a short prompt and interferes with a long one you already&lt;br&gt;
tuned. The response hands your original text back under &lt;code&gt;orig_prompt&lt;/code&gt;, so you&lt;br&gt;
can always diff what you sent against what ran.&lt;/p&gt;
&lt;h3 id=&quot;two-input-families-that-cannot-share-a-request&quot;&gt;Two input families that cannot share a request&lt;/h3&gt;
&lt;p&gt;Wan 3.0 takes a reference family (&lt;code&gt;reference_image&lt;/code&gt;, &lt;code&gt;reference_video&lt;/code&gt;,&lt;br&gt;
&lt;code&gt;reference_audio&lt;/code&gt;, &lt;code&gt;file&lt;/code&gt;, &lt;code&gt;link&lt;/code&gt;) and a keyframe family (&lt;code&gt;first_frame&lt;/code&gt;,&lt;br&gt;
&lt;code&gt;last_frame&lt;/code&gt;), and it refuses both in the same call:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;code&quot;: &quot;InvalidParameter&quot;,
  &quot;message&quot;: &quot;The two modes are mutually exclusive. Do not pass reference_xx and first_frame/last_frame at the same time.&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This reads like an arbitrary validation rule and it is not. Keyframes say &lt;em&gt;start&lt;br&gt;
here, end there, invent the middle&lt;/em&gt;. References say &lt;em&gt;here is a cast and a mood,&lt;br&gt;
work the shot out yourself&lt;/em&gt;. One pass cannot be pinned at both ends and freely&lt;br&gt;
composed at the same time. So the fix is a decision rather than a workaround.&lt;/p&gt;
&lt;p&gt;The same shape appears twice more, smaller: &lt;code&gt;file&lt;/code&gt; and &lt;code&gt;link&lt;/code&gt; are mutually&lt;br&gt;
exclusive, and there is exactly one of each per job.&lt;/p&gt;
&lt;h3 id=&quot;if-you-just-want-one-clip-today&quot;&gt;If you just want one clip today&lt;/h3&gt;
&lt;p&gt;Route four exists because the other three are a day of setup for a thing you&lt;br&gt;
wanted to try for ten minutes. &lt;a rel=&quot;nofollow&quot; href=&quot;https://wan-3.run/&quot;&gt;wan-3.run&lt;/a&gt; is a browser tab&lt;br&gt;
that runs the same &lt;code&gt;wan3.0-video&lt;/code&gt; model, prints the model ID and upstream task&lt;br&gt;
ID under every result, and gives the first clip away so you can check the output&lt;br&gt;
before you decide whether any of the paperwork above is worth it.&lt;/p&gt;
&lt;p&gt;If you are writing the integration rather than using one, the numbers above are&lt;br&gt;
the ones to hard-code tests around, and there is&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://wan-3.run/wan-3-0-specs&quot;&gt;a spec table with each row dated and linked to its source&lt;/a&gt;&lt;br&gt;
that is easier to diff against than the docs when Alibaba changes something.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Disclosure: I work on that second link.&lt;/em&gt;&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/27019/four-ways-to-reach-the-same-video-model-and-what-each-one-asks-of-you-first</guid>
<pubDate>Sun, 13 Sep 2026 03:33:37 +0000</pubDate>
</item>
</channel>
</rss>