GenAI.Provider.Qwen (Noizu Labs, GenAI Wrapper v0.3.10)

Copy Markdown View Source

Module for interacting with Alibaba Cloud Model Studio (DashScope) Qwen models.

DashScope exposes an OpenAI-compatible API. Two billing endpoints are supported:

  • On-demand (default): https://dashscope-intl.aliyuncs.com/compatible-mode/v1 with config :genai, :qwen, api_key: (QWEN_API_KEY, DASHSCOPE_API_KEY fallback).
  • Token plan: https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1 with token_api_key: (QWEN_TOKEN_KEY). Enable via token_plan: true or mode: :token_plan in config, models/1 options, or provider settings.

Regional on-demand overrides go on config :genai, :qwen, base_url:. Token-plan host overrides go on token_plan_base_url:.

Summary

Functions

Bearer token for the active plan (api_key on-demand, token_api_key on token plan).

Compatible-mode root URL. Token-plan mode selects the token-plan host; an explicit per-request :base_url still wins.

Full Model Studio catalog via native GET /api/v1/models (paginated).

Return config_key inference provide application config stored under :genai entry

Obtain map of effective settings: settings, model_settings, provider_settings, config_settings, etc.

Prepare endpoint and method to make inference call to

Retrieves a list of models supported by the DashScope compatible-mode API.

Native Model Studio API root (/api/v1) derived from the active compatible-mode URL.

Prepare request body to be passed to inference call.

Build and run inference thread

Build and run inference thread in streaming mode

True when token-plan mode is set (token_plan: true or mode: :token_plan).

Functions

api_key(settings \\ [], options \\ [])

Bearer token for the active plan (api_key on-demand, token_api_key on token plan).

base_url(settings \\ [])

Compatible-mode root URL. Token-plan mode selects the token-plan host; an explicit per-request :base_url still wins.

catalog(settings \\ [])

Full Model Studio catalog via native GET /api/v1/models (paginated).

Unlike models/0 (OpenAI-compatible, ~160 chat/image/embed ids), this includes video, extra audio, and capability metadata. Options (keyword):

  • :page_size — default 100
  • :language — default "en-US"
  • :capabilities — string or list, e.g. "TR" or ["TG", "Reasoning"]
  • :providers — string or list, e.g. "qwen"

chat(messages, tools, settings)

chat(model, messages, tools, hyper_parameters, provider_settings \\ [], context \\ nil, options \\ nil)

Callback implementation for GenAI.InferenceProviderBehaviour.chat/7.

config_key()

Return config_key inference provide application config stored under :genai entry

default_encoder()

effective_settings(model, session, context, options \\ nil)

Obtain map of effective settings: settings, model_settings, provider_settings, config_settings, etc.

endpoint(model, settings, session, context, options \\ nil)

Prepare endpoint and method to make inference call to

generate_media(request, options)

Callback implementation for GenAI.InferenceProviderBehaviour.generate_media/2.

headers(options)

headers(model, settings, session, context, options \\ nil)

Prepare request headers

models(settings \\ [])

Retrieves a list of models supported by the DashScope compatible-mode API.

native_base_url(settings \\ [])

Native Model Studio API root (/api/v1) derived from the active compatible-mode URL.

Used by catalog/1 — the OpenAI-compatible /models list omits video and some audio ids.

request_body(model, messages, tools, settings, session, context, options \\ nil)

Prepare request body to be passed to inference call.

run(session, context, options \\ nil)

Build and run inference thread

standardize_model(model)

Callback implementation for GenAI.InferenceProviderBehaviour.standardize_model/1.

stream(session, context, options \\ nil)

Build and run inference thread in streaming mode

supported_modalities()

Callback implementation for GenAI.InferenceProviderBehaviour.supported_modalities/0.

token_plan?(settings \\ [])

True when token-plan mode is set (token_plan: true or mode: :token_plan).