Skip to content

Legacy 2.x

Deprecated — removed in 4.0

The legacy 2.x surface is frozen: it receives no new features and will be removed in SDK 4.0. New code should use the 3.0 client; existing code should plan a migration.

What moved where

To keep existing 2.x code compiling on the 3.0 artifact, the complete 2.x surface was preserved as frozen facades under com.alibaba.dashscope.legacy_2x.*. Update imports by inserting the legacy_2x segment:

// 2.x (on the 2.x artifact)
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.exception.ApiException;

// 3.0 artifact, legacy facade
import com.alibaba.dashscope.legacy_2x.aigc.generation.Generation;
import com.alibaba.dashscope.legacy_2x.common.Message;
import com.alibaba.dashscope.legacy_2x.exception.ApiException;

The facades keep the historical behavior: checked ApiException / NoApiKeyException / InputRequiredException, ResultCallback streaming, Flowable-based streamCall, and per-capability entry objects (new Generation(), new ImageSynthesis(), …).

Every legacy type carries type-level @Deprecated; compile with -Xlint:deprecation to see the details and the suggested 3.0 replacement.

Not deprecated

  • AgentStudio moved to com.alibaba.dashscope.applications.agentstudio.* (not under legacy_2x) and is actively developed; it is also reachable via client.agentStudio().
  • shared (com.alibaba.dashscope.shared.*) holds neutral constants used by both generations.
  • assistants.* / threads.* have no 3.0 equivalent yet — keep the legacy_2x imports for those until a replacement ships.

Reference & samples

Migration

The Migrating from 2.x page has the full entry-point mapping table and a before/after example. The two changes that touch most code:

  • checked exceptions → the unchecked DashScopeException family (or raiseOnError(false) for result-style errors);
  • per-capability objects → one DashScopeClient in try-with-resources.