Files
magpie/docs
yetone 389169f761 gateway: a Qwen Token Plan's TTS, ASR and video models are served on OpenAI's routes
gaubeebangeel on X (tweet 2122991088017477954) asked for every kind of
model Alibaba's Token Plan sells, each on its own DashScope endpoint.
Before this, magpie served the plan's text (Anthropic and chat
completions), its realtime voice (/v1/realtime, realtime.go) and its
Qwen-Image drawing (draw_dashscope.go). The plan's text list lacked
deepseek-v4.1-flash-1017, and nothing served its TTS, ASR or video
models.

- presets: alibabaPlanModels as the four plans' overviews list them on
  11-18 (qwen4-max, qwen4-max-preview, deepseek-v4.1-flash-1017 added).
  PresetDef gains Drawers, Videos, Speakers and Transcribers, Region
  gains Speakers and Transcribers, and the four Token Plans
  (qwen-token-plan, bailian-token-plan, alibaba-token-plan,
  qwencloud-token-plan) name qwen-image-3.0-pro and wan2.7-image(-pro),
  wan3.0-video and happyhorse-1.1-t2v/-i2v/-r2v, qwen-audio-3.0-tts-plus
  and qwen-audio-3.0-asr-flash. PlanSpeakers and PlanTranscribers feed
  PlanRetrieval, so the router knows which provider speaks and
  transcribes.
- /v1/audio/speech (speech_dashscope.go): a plan key's qwen-audio TTS
  model is asked on <root>/api/v1/services/audio/tts/SpeechSynthesizer,
  every field under input as the docs have them. An OpenAI voice name
  becomes the model's own first voice (longanlingxin for -plus,
  longanhuan_v3.6 for -flash), speed goes as rate (0.5 to 2), and
  instructions as instruction. mp3, wav, pcm and opus are served; aac,
  flac and stream_format sse are 400s before DashScope is asked. The
  answer's output.audio.url is fetched (or data decoded) and served with
  the format's type.
- /v1/audio/transcriptions: a plan key's qwen-audio ASR model goes to
  multimodal-generation with the file as an input_audio data URI, its
  format from the file's name or type, and language as language_hints.
  The answer is given back as OpenAI's json, text or verbose_json; srt,
  vtt and translations are 400s. The form's file is read only on this
  path (audioForm.file), so a form passed on as sent is never copied.
- /v1/videos (video_dashscope.go): Wan 3.0 and HappyHorse start at
  video-synthesis with X-DashScope-Async: enable and are polled at
  /api/v1/tasks/<id>. The id carries the model and the key's mark, as
  MiniMax's does. vendorAsk.answer now takes the request's context, so
  the TTS answer's audio URL is fetched under it.

Hosts, paths, fields and voices were checked against Alibaba's docs
(help.aliyun.com model-studio qwen-audio-tts/asr HTTP API and Wan 3.0
video reference, docs.qwencloud.com Token Plan multimodal pages,
platform.qianwenai.com token-plan), not against the tweet. Not tried
against the real API: the owner's magpie has no Token Plan provider.
The tests use a fake DashScope serving the docs' shapes.

Run (on mote via mote-run, tree at 8634c4ad0 plus this diff):
- gofmt -l internal/: nothing.
- go test -count=1 -run 'TokenPlan|DashScope|Speech|Transcri|Video|Plan|Qwen|Qianwen|Alibaba'
  ./internal/gateway ./internal/provider ./internal/gui: ok, ok, ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows go
  build: all ok.
- go test -count=1 -timeout 45m ./...: 101 packages ok; internal/cli and
  internal/gui red on TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr,
  TestUpdateFindsAMagpieThatWroteNoRecord (#6223, #6471) and
  TestLaneLimitRoutes (#5150). mote has an ssh forward listening on
  127.0.0.1:3425, which those tests read. All four are red the same way,
  run alone on mote, at a just-fetched origin/main 589e4ba6d.
- Broken by hand: with the X-DashScope-Async header dropped,
  TestTokenPlanMakesVideos goes red (403 "does not support synchronous
  calls"); with -plus's default voice changed to alloy,
  TestTokenPlanSpeaks goes red.
- GUI: no asset changed, and the .cjs files run app.js on fixtures, so
  none can be reached. The Go GUI API that lists the plans' models ran
  in ./internal/gui above.
- Rebased on origin/main 589e4ba6d (6 commits, none touching these
  files) and run again at this head on mote: gofmt -l nothing; the
  targeted run above ok, ok, ok; vet (darwin, linux nogui, windows) of
  ./internal/gateway ./internal/provider and the three builds ok.
2026-11-18 19:59:27 +08:00
..