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 underlegacy_2x) and is actively developed; it is also reachable viaclient.agentStudio(). shared(com.alibaba.dashscope.shared.*) holds neutral constants used by both generations.assistants.*/threads.*have no 3.0 equivalent yet — keep thelegacy_2ximports for those until a replacement ships.
Reference & samples¶
- Javadoc for the frozen facades: legacy_2x packages (included in the auto-generated API Reference).
- Archived runnable 2.x samples: examples/legacy_2x/.
- The root README keeps a legacy appendix with the original 2.x quick-start documentation.
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
DashScopeClientin try-with-resources.