Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning " AI How-Tos

Qwen3-Code Free User's Guide: Configuring the ModelScope API and Qwen CLI

2025-07-24 47

Recently, new code generation models Qwen3-Code It has attracted a lot of attention in the developer community. However, some developers have encountered unexpected cost issues when using their API services. Some developers have reported that after writing a small amount of code, they encountered the problem of exceeding the API usage limit and incurred unexpected costs. There are even cases that show that a single code submission led to hundreds of dollars of bills, this "code did not write much, the bill first to report" situation, undoubtedly bringing trouble to developers.

Fortunately, the Magic Tower community (ModelScope) provides a solution to this problem.ModelScope is an open source modeling community launched by Alibaba to promote the exchange and application of AI models. The platform provides free inference API call credits for a number of models, including the Qwen3-CodeThe free daily quota is up to 2,000, which is quite enough for most development and testing scenarios.

32d95353-b815-40a8-9a80-7d712bc8df1a.png

The following section describes how to pass the ModelScope free of charge Qwen3-Code combining Qwen CLI tools for development.

Get free API credentials

First, in the ModelScope Search on the community website and enter Qwen3-Code You can find the "View Code Demonstration" option on the model page.

41ff4fb3-af2d-41ae-a871-8089b6e5d901.png

When clicked, three core pieces of information are provided in the sample code:base_url,api_key cap (a poem) modelThe

from openai import OpenAI
client = OpenAI(
base_url='https://api-inference.modelscope.cn/v1/',
api_key='YOUR_MS_API_KEY', # 替换为你自己的ModelScope Token
# ModelScope Token, 示例: ms-4c51dab7-2022-4f56-a009-13adb22
)
response = client.chat.completions.create(
model='Qwen/Qwen3-Coder-480B-A35B-Instruct', # ModelScope Model-Id
messages=[
{
'role': 'system',
'content': 'You are a helpful assistant.'
},
{
'role': 'user',
'content': '你好'
}
],
stream=True
)
for chunk in response:
print(chunk.choices.delta.content, end='', flush=True)

API Key Requires user login ModelScope account before it can be generated and viewed. In addition, using the ModelScope of the inference service must first bind a valid Aliyun account on the backend management page.

ed3ceab3-afa1-4f84-bcd9-6e349e2c7f74.png

If the binding is not completed, you will receive the following error when calling the API:

{"errors":{"message":"Please bind your Alibaba Cloud account before use."},"request_id":"774509ee-a256-406b-b00d-900"}

Configuring the Qwen CLI Tool

Once you have completed the preparation of your API credentials, you can begin configuring the Qwen CLITheQwen CLI is a command-line tool that allows developers to work with the Qwen models to interact and enable fast code generation and completion.

First, the global installation Qwen CLI::

npm i -g @qwen-code/qwen-code

After successful installation, execute the following command to start the tool:

qwen

Next, configure the environment variables by setting the ModelScope The free API information provided is available to Qwen CLIThe

# API 密钥
export OPENAI_API_KEY="YOUR_MS_API_KEY"
# API 基础 URL
export OPENAI_BASE_URL="https://api-inference.modelscope.cn/v1/"
# 模型名称
export OPENAI_MODEL="Qwen/Qwen3-Coder-480B-A35B-Instruct"

If an error occurs during configuration or needs to be reset, you can simply delete the user's home directory under the .qwen configuration file and then reconfigure it.

Providing developers with free API call credits is a smart ecological strategy. It not only significantly lowers the entry threshold and cost of use for developers, but also inspires broader community participation and innovation, ultimately contributing to the prosperity of the modeling ecosystem.

de87e202-a68a-42cc-a538-0e0b4ec3e07a.png

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

inbox

Contact Us

Top

en_USEnglish