Qwen
Qwen
Tongyi Qianwen provides model inference services compatible with OpenAI.
Alibaba Cloud - Tongyi Qianwen
It refers to a model inference service whose interface design and usage are consistent with OpenAI's API.
This means developers can use the same code and methods as they would for OpenAI models to interact with these compatible services, significantly reducing integration costs.
useXAgent
This method is a ready-to-use solution for React environments provided by Ant Design X.
import { useXAgent } from '@ant-design/x';// ... react envconst [agent] = useXAgent({baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',model: 'qwen-plus',// Use cautiously in production!dangerouslyApiKey: 'DASHSCOPE_API_KEY',});function request() {agent.request({// Conversation messagesmessages: [{role: 'user',content: 'Hello',},],// Enable streamingstream: true,},{// Success callbackonSuccess: (sseChunks) => {// Triggered when the request completes// This will contain the parsed sseChunks},onError: (error) => {// Triggered in case of an error},onUpdate: (sse) => {// Triggered during stream updates// This will contain the parsed SSE object},},);}
XRequest
This method is a ready-to-use solution for JavaScript environments provided by Ant Design X.
import { XRequest } from '@ant-design/x';const xRequest = XRequest({baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',model: 'qwen-plus',// Use cautiously in production!dangerouslyApiKey: 'DASHSCOPE_API_KEY',});function request() {xRequest.create({// Conversation messagesmessages: [{role: 'user',content: 'Hello',},],// Enable streamingstream: true,},{// Success callbackonSuccess: (sseChunks) => {// Triggered when the request completes// This will contain the parsed sseChunks},onError: (error) => {// Triggered in case of an error},onUpdate: (sse) => {// Triggered during stream updates// This will contain the parsed SSE object},},);}