Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6c53ac3
feat(models): server-side filters + rich metadata for models.list (A1)
Nov 17, 2026
5321508
feat(fine-tunes): add model compression (quantization) sub-resource (D1)
Nov 17, 2026
3386de5
feat(batches): add client.batches.files compatible-mode File resource…
Nov 17, 2026
9f414fa
feat(batches): add client.batches job plane create/get/list/cancel/wa…
Nov 17, 2026
f2378e5
feat(responses): add client.responses create/get/delete/input_items.l…
Nov 17, 2026
5636908
feat(models): auto-pagination, availability check, region/workspace c…
Nov 18, 2026
0c41657
feat(models): add read-only models.limits and models.permissions sub-…
Nov 18, 2026
47288e1
feat(batches): add download_output/download_error result helpers + in…
Nov 18, 2026
f2fdf67
feat(models): region safe passthrough + region-aware catalog cache (A4)
Nov 18, 2026
83b6f3c
feat(models): explicit cross-region RegionRouter with opt-in + cross-…
Nov 18, 2026
3d219fb
feat(batch): client.batch_chat.completions queued synchronous Batch C…
Nov 18, 2026
0c2ddcf
feat(conversations): client.conversations CRUD + items lifecycle (C2)
Nov 18, 2026
213ff8b
feat(messages): native Anthropic Messages resource (C3)
Nov 18, 2026
7a07fa7
feat(deployments): PTU throughput reservation + capacity instances/op…
Nov 18, 2026
a0fa141
style(deployments): apply pre-commit formatting + reduce create-body …
Nov 18, 2026
9053697
docs(anthropic): clarify web-search billing marker packaging is SDK-side
Nov 18, 2026
cb3e2f8
style: make pre-commit pass across control-plane modules
Nov 18, 2026
cb5bbb1
ci(unit_test): run 2.0 tests on Python 3.9/3.11/3.13 only
Nov 18, 2026
a870781
fix: address branch review findings across v2 resources
Nov 18, 2026
b03ab54
feat(management): RAM ManagementClient read-only integration layer (G…
Nov 19, 2026
328cec8
fix(resources): enforce non-empty and percent-encode IDs in paths
Nov 20, 2026
573da41
fix(api): percent-encode conversation, item, and response IDs in paths
Nov 20, 2026
586ba3a
fix(management): enforce explicit credential completeness to prevent …
Nov 20, 2026
75c34d9
test(logging): fix formatting in management logger filter assertions
Nov 20, 2026
71e8b51
style(tests): format assertion with multiline parentheses
Nov 20, 2026
d4557df
fix(deployments): apply PTU safeguards to merged request bodies
Nov 23, 2026
ff9f0f1
fix(management): secure validation errors and signed requests
Nov 23, 2026
0f376e1
Merge pull request #240 from dashscope/dev/v2.2-1
lzsweb Nov 23, 2026
9d99a0c
refactor(deployments): defer PTU from the first release
Nov 23, 2026
108229f
fix(api): prevent double encoding of IDs in URL paths and query param…
Nov 23, 2026
6368a5b
chore(docs): add automated docs build and release notes integration
Nov 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 7 additions & 36 deletions .github/release-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,52 +35,27 @@ invisible in the rendered Release page):

### 🚀 Highlights

- Qwen Live realtime audio sessions built on a shared realtime transport.
- New `dashscope.devkit`: offline self-diagnosis for failed calls plus static/record/replay HTTP mocking.
- Automated release pipeline — pushing a `v*` tag now builds, publishes to PyPI, and drafts the GitHub Release.
-

### ✨ Features

- audio: add Qwen Live sessions on the shared realtime transport (#231).
- audio: accept audio sources for voice enrollment.
- agentstudio: session mount fields for Bailian memory and OSS.
- devkit: add offline self-diagnosis for failed calls.
- devkit: add static/record/replay dev mock at the HTTP transport.
- transport: introduce `APIResponse` and a `raw` parameter for raw responses.
- transport: support per-request options across all resources.
- pagination: introduce a generic pagination base class and refactor resource list interfaces.
- parse: add fault-tolerant response model parsing and strict validation config.
- core: add client request ID and response validation exception.
- v2: extend typed parsing, per-request options, and pagination fixes to all resources.
- Enhance API response handling and resource methods.
-

### ♻️ Refactoring

- cli: migrate the agent runtime to `dashscope-agenticx` (#230).
- server: extract client disconnect response logic.
-

### 🐛 Bug Fixes

- tts: prevent `KeyError` for non-timestamp messages in speech parts.
- audio: preserve graceful Live and Realtime shutdown.
- reinforcement: preserve FaaS business errors and request context.
- reinforcement: address agentic RL review findings.
- reinforcement: allow local wheel paths in pip requirement tokens.
- core: unify API key resolution and improve error handling.
- v2: support more image models and input forms, including wan2.7 image responses.
- logging: correlate SDK 2.0 response errors with request IDs.
-

### 📚 Documentation

- None
-

### 🔧 CI & Chore

- release: add tag-triggered PyPI publishing workflow (#234).
- version: bump to 2.1.0.
- ci: pin Python 3.9 / unit-test runners to ubuntu-24.04.
- ci: run legacy unit tests on pushes and pull requests again.
- test: stabilize RL CLI help checks, align job list output, and move layer decoupling checks to the current suite.
-

### ⚠️ Breaking Changes

Expand All @@ -101,11 +76,7 @@ Thanks to all the contributors who made this release possible:
<!-- List @handles here. On the draft page, the "Generate release notes"
button in the top-right can auto-populate New Contributors. -->

- @zhansheng.lzs
- @luk384090-cloud
- @songguocola
- @foleydang
- @lzsweb
-

### 📝 Full Changelog

Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Docs

# FastAPI-style docs pipeline: every PR and main push builds the MkDocs
# Material site to validate it; pushes to main additionally deploy the HTML
# to GitHub Pages. Publishing a GitHub Release also rebuilds and deploys:
# the Release Notes page renders published releases at build time, so the
# tag-driven release.yml flow refreshes the docs without touching them.
on:
push:
branches: [main]
paths:
- 'docs/**'
- 'dashscope/**'
- 'mkdocs.yml'
- 'requirements-doc.txt'
- '.github/workflows/docs.yml'
pull_request:
paths:
- 'docs/**'
- 'dashscope/**'
- 'mkdocs.yml'
- 'requirements-doc.txt'
- '.github/workflows/docs.yml'
release:
types: [published]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
# Release events carry a tag ref; docs always track main (latest).
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'release' && 'refs/heads/main' || github.ref }}
- uses: actions/setup-python@v5
with:
python-version: '3.12'
# mkdocstrings imports the real package, so install it alongside the
# doc toolchain (httpx/pydantic etc. come in as runtime dependencies).
- run: python -m pip install -r requirements-doc.txt .
- name: Build HTML
# GITHUB_TOKEN lifts the anonymous GitHub API rate limit for the
# release-notes rendering in docs/hooks.py (public data, read-only).
env:
GITHUB_TOKEN: ${{ github.token }}
run: mkdocs build --strict
- name: Upload site artifact
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main')
|| github.event_name == 'release'
uses: actions/upload-pages-artifact@v3
with:
path: site

deploy:
needs: build
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main')
|| github.event_name == 'release'
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
5 changes: 1 addition & 4 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# The 2.0 surface runs on the odd CPython legs only (3.9/3.11/3.13).
# ubuntu-latest (26.04) ships no CPython 3.9 build, so pin the
# still-supported 3.9 leg to 24.04 and keep the rest on latest.
include:
- os: ubuntu-24.04
python-version: '3.9'
- os: ubuntu-latest
python-version: '3.10'
- os: ubuntu-latest
python-version: '3.11'
- os: ubuntu-latest
python-version: '3.12'
- os: ubuntu-latest
python-version: '3.13'

Expand Down
10 changes: 10 additions & 0 deletions dashscope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
from dashscope._quickstart import chat
from dashscope.client import AsyncClient, Client
from dashscope.errors import DashScopeError, ErrorCode
from dashscope.region_router import (
AsyncRegionRouter,
ModelAvailability,
RegionModelInfo,
RegionRouter,
)
from dashscope.transport.ws_connection import WsConnection, WsTask

# cn-beijing defaults to the legacy dashscope.aliyuncs.com endpoints;
Expand Down Expand Up @@ -297,10 +303,14 @@ def __dir__():
"VideoSynthesis",
# dashscope 2.0
"AsyncClient",
"AsyncRegionRouter",
"Client",
"Config",
"DashScopeError",
"ErrorCode",
"ModelAvailability",
"RegionModelInfo",
"RegionRouter",
"Settings",
"WsConnection",
"WsTask",
Expand Down
7 changes: 6 additions & 1 deletion dashscope/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ def close_shared_sync_session() -> None: ...
def set_region(region: str, workspace_id: Optional[str] = ...) -> None: ...

# Lazily resolved compatibility modules.
# ``applications`` is a real 2.0 subpackage: re-export it as a module so type
# checkers and griffe keep access to its submodules (e.g. applications.finetune
# and applications.agentstudio). Declaring it as ``applications: Any`` would
# let griffe's stub merge shadow the submodule with a plain attribute.
from dashscope import applications as applications

aigc: Any
agentstudio: Any
api_entities: Any
app: Any
applications: Any
assistants: Any
audio: Any
cli: Any
Expand Down
93 changes: 89 additions & 4 deletions dashscope/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from __future__ import annotations

import os
import re
import threading
import warnings
from dataclasses import dataclass
Expand Down Expand Up @@ -234,10 +235,66 @@ def _legacy_fallback(host: str) -> str:
return host


# RFC1123 DNS label: lowercase letters/digits/hyphen, 1-63 chars, no
# leading/trailing hyphen. ``region`` and ``workspace`` are interpolated
# into the gateway host (``{workspace}.{region}.maas.aliyuncs.com``), so
# any character outside this set (dot, slash, ``@``, uppercase, ...) could
# rewrite the host and must be rejected before it reaches a URL.
_SAFE_LABEL_RE = re.compile(r"^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$")


def _is_safe_region_label(region: str) -> bool:
return isinstance(region, str) and bool(_SAFE_LABEL_RE.match(region))


def _validate_region(region: str) -> str:
if region not in VALID_REGIONS:
"""Format-check a region that may be interpolated into a gateway host.

The static whitelist is no longer a hard gate -- it would block newly
launched regions before an SDK upgrade. Membership is decided by
:func:`_gateway_region` from the workspace/base_url context; here we
only reject labels that could rewrite the host.
"""
if not _is_safe_region_label(region):
raise ValueError(
f"invalid region {region!r}: expected a lowercase DNS label "
f"(letters, digits, hyphens), e.g. 'cn-beijing'",
)
return region


def _gateway_region(region: str, workspace: Optional[str]) -> str:
"""Apply the region allowance policy for a default gateway host.

- workspace configured: any safe label passes; an unknown region
(not in ``VALID_REGIONS``) warns instead of rejecting, so a newly
launched region works without an SDK upgrade.
- no workspace (legacy shared gateway): the region must have a known
gateway mapping, otherwise the shared endpoint cannot be built.

The workspace is host-interpolated too, so it must also be a safe
label. An explicit ``base_url`` bypasses this entirely (the caller
never builds a default host).
"""
region = _validate_region(region)
if workspace:
if not _is_safe_region_label(workspace):
raise ValueError(
f"invalid workspace {workspace!r}: expected a lowercase "
f"DNS label (letters, digits, hyphens)",
)
if region not in VALID_REGIONS:
warnings.warn(
f"region {region!r} is not a known DashScope region; "
f"passing it through to the workspace gateway. Ensure "
f"the workspace and API key belong to this region.",
UserWarning,
stacklevel=2,
)
elif region not in LEGACY_GATEWAY_HOSTS:
raise ValueError(
f"invalid region {region!r}, expected one of {VALID_REGIONS}",
f"invalid region {region!r}: no shared gateway mapping; "
f"configure a workspace or an explicit base_url",
)
return region

Expand All @@ -261,7 +318,7 @@ def _protocol_default_base_url(
workspace: Optional[str],
region: Optional[str] = None,
) -> str:
region = _validate_region(region or DEFAULT_REGION)
region = _gateway_region(region or DEFAULT_REGION, workspace)
if workspace:
host = WORKSPACE_GATEWAY_TEMPLATE.format(
workspace=workspace,
Expand Down Expand Up @@ -294,6 +351,26 @@ def compatible_mode_base_url(
return _protocol_default_base_url("openai", workspace, region)


def anthropic_base_url(
workspace: Optional[str],
region: Optional[str] = None,
configured_base_url: Optional[str] = None,
) -> str:
"""Endpoint root for the Anthropic-compatible Messages API.

Messages lives under ``/apps/anthropic`` (the wire path is
``/v1/messages`` beneath it), independent of the chat ``protocol``
setting -- the same rule ``compatible_mode_base_url`` applies. An
explicit base_url stays the service root (callers point it at
``.../apps/anthropic``); otherwise the default gateway host carries
the fixed anthropic path. The root deliberately does not end in
``/v1`` so clients appending ``/v1/messages`` do not double it.
"""
if configured_base_url is not None:
return configured_base_url
return _protocol_default_base_url("anthropic", workspace, region)


def workspace_ws_url(
workspace: Optional[str],
path: str,
Expand All @@ -307,7 +384,7 @@ def workspace_ws_url(
gateway (``wss://dashscope.aliyuncs.com`` for cn-beijing) with a
warning.
"""
region = _validate_region(region or DEFAULT_REGION)
region = _gateway_region(region or DEFAULT_REGION, workspace)
if workspace:
host = WORKSPACE_WS_GATEWAY_TEMPLATE.format(
workspace=workspace,
Expand Down Expand Up @@ -443,6 +520,14 @@ def region(self) -> str:
@region.setter
def region(self, value: str) -> None:
_validate_region(value)
if value not in VALID_REGIONS:
warnings.warn(
f"region {value!r} is not a known DashScope region; it "
f"will pass through to the workspace gateway (or require "
f"an explicit base_url / known shared-gateway mapping).",
UserWarning,
stacklevel=2,
)
with self._lock:
self._explicit["region"] = value

Expand Down
2 changes: 1 addition & 1 deletion dashscope/cli/commands/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def list_models(
provider: Optional[str] = typer.Option(
None,
"--provider",
help="Filter by provider or source (client-side, per page).",
help="Filter by provider (server-side; folds into providers).",
),
) -> None:
"""List available models."""
Expand Down
13 changes: 11 additions & 2 deletions dashscope/cli/config_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,13 @@ def _enum_choices() -> Dict[str, Tuple[str, Tuple[str, ...]]]:
"""
from dashscope._config import ( # pylint: disable=import-outside-toplevel
VALID_PROTOCOLS,
VALID_REGIONS,
)
from dashscope.cli.output import ( # pylint: disable=import-outside-toplevel
OUTPUT_FORMATS,
)

return {
"protocol": ("protocol", tuple(VALID_PROTOCOLS)),
"region": ("region", tuple(VALID_REGIONS)),
"output": ("output format", tuple(OUTPUT_FORMATS)),
}

Expand Down Expand Up @@ -230,6 +228,17 @@ def _validate(key: str, value: Any) -> Any:
f"{', '.join(allowed)}",
)
return value
if key == "region":
from dashscope._config import ( # pylint: disable=import-outside-toplevel
_is_safe_region_label,
)

if not _is_safe_region_label(value):
raise usage_error(
f"invalid region {value!r}, expected a lowercase DNS "
f"label (letters, digits, hyphens), e.g. 'cn-beijing'",
)
return value
if key in _POSITIVE_SECONDS:
return _validate_number(key, value, integer=False, positive=True)
if key in _NON_NEGATIVE_INTS:
Expand Down
Loading
Loading