Qwen on Alibaba Cloud Model Studio (DashScope), through its OpenAI-compatible endpoint. Built on hot.dev/openai: requests go through ::openai::api/Endpoint, and ::qwen::ai/provider registers Qwen with the hot-ai run loop via OpenAI's chat-tools adapter.

The base URL is chosen by base-url(), in this order:

  1. qwen.base.url: used as-is.
  2. qwen.workspace.id + qwen.region: the workspace domain https://{workspace}.{region-id}.maas.aliyuncs.com/compatible-mode/v1.
  3. qwen.region alone: the region's shared domain.

API keys are bound to the region they were created in; a key sent to another region's endpoint gets a 401.

A region or workspace id builds a hostname, so both are checked strictly: a region must be one of REGIONS or its aliases, and a workspace id a plain DNS label. For one call, see ::qwen::api/resolve.

Values

BASE_URL

BASE_URL: Str "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"

International (Singapore) OpenAI-compatible base URL; the default.

BASE_URL_CN

BASE_URL_CN: Str "https://dashscope.aliyuncs.com/compatible-mode/v1"

Mainland China (Beijing) OpenAI-compatible base URL.

BASE_URL_HK

BASE_URL_HK: Str "https://cn-hongkong.dashscope.aliyuncs.com/compatible-mode/v1"

China (Hong Kong) OpenAI-compatible base URL.

BASE_URL_US

BASE_URL_US: Str "https://dashscope-us.aliyuncs.com/compatible-mode/v1"

US (Virginia) OpenAI-compatible base URL.

COMPATIBLE_PATH

COMPATIBLE_PATH: Str "/compatible-mode/v1"

DEFAULT_REGION

DEFAULT_REGION: Str "intl"

REGIONS

REGIONS: Map {
  intl: {
    id: "ap-southeast-1",
    base-url: BASE_URL
  },
  us: {
    id: "us-east-1",
    base-url: BASE_URL_US
  },
  cn: {
    id: "cn-beijing",
    base-url: BASE_URL_CN
  },
  hk: {
    id: "cn-hongkong",
    base-url: BASE_URL_HK
  },
  eu: {
    id: "eu-central-1",
    base-url: null
  },
  jp: {
    id: "ap-northeast-1",
    base-url: null
  }
}

Model Studio regions: id is the Alibaba Cloud region id used in workspace domains, base-url the shared domain (null where the region is only reachable through a workspace domain). Aliases map to the same entry: intl/singapore/ap-southeast-1, us/virginia/us-east-1, cn/beijing/cn-beijing, hk/hongkong/cn-hongkong, eu/frankfurt/eu-central-1, jp/tokyo/ap-northeast-1.

REGION_ALIASES

REGION_ALIASES: Map {
  intl: "intl",
  international: "intl",
  singapore: "intl",
  ap-southeast-1: "intl",
  us: "us",
  virginia: "us",
  us-east-1: "us",
  cn: "cn",
  china: "cn",
  beijing: "cn",
  cn-beijing: "cn",
  hk: "hk",
  hongkong: "hk",
  hong-kong: "hk",
  cn-hongkong: "hk",
  eu: "eu",
  frankfurt: "eu",
  germany: "eu",
  eu-central-1: "eu",
  jp: "jp",
  japan: "jp",
  tokyo: "jp",
  ap-northeast-1: "jp"
}

Functions

base-url

fn (): Str

The base URL from ctx: qwen.base.url, else qwen.workspace.id + qwen.region, else the qwen.region shared domain (default intl, Singapore).

Example

::qwen/base-url()  // => "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
Context Vars: qwen.base.url, qwen.region, qwen.workspace.id

is-workspace-id

fn (value: Str): Bool

True when value can be a workspace id: a plain DNS label of letters, digits and inner hyphens. Anything else could change which host a request goes to, so it never gets into a URL.

Example

::qwen/is-workspace-id("llm-abc123")        // => true
::qwen/is-workspace-id("evil.example/x?y")  // => false

region-info

fn (region: Str?): Map

Look up a region by name or alias (case-insensitive). Null or empty means the default (intl). Unknown names return an Err.

Example

::qwen/region-info("Singapore").id  // => "ap-southeast-1"
::qwen/region-info("us").base-url    // => "https://dashscope-us.aliyuncs.com/compatible-mode/v1"

resolve-base-url

fn (base-url: Str?, region: Str?, workspace-id: Str?): Str

Pure base-URL selection: an explicit base-url wins, then a workspace domain when workspace-id is set, then the region's shared domain. Regions without a shared domain (eu, jp) need a workspace id. A workspace id that isn't a plain DNS label is an Err (see is-workspace-id).

Example

::qwen/resolve-base-url(null, "us", null)
// => "https://dashscope-us.aliyuncs.com/compatible-mode/v1"
::qwen/resolve-base-url(null, "eu", "ws-123")
// => "https://ws-123.eu-central-1.maas.aliyuncs.com/compatible-mode/v1"