FREE AI INDEX / 统一产品界面我的收藏提交资源 ↗

Free AI Index / 从零开始Getting started / Alibaba Cloud Model Studio / 阿里云百炼

FIRST API CALL / aliyun-qwen

Alibaba Cloud Model Studio / 阿里云百炼:跑通第一次 API 调用Make your first Alibaba Cloud Model Studio / API call

先确认注册与免费条件,再按步骤获取密钥、安装依赖并验证返回结果。教程只使用环境变量读取密钥。Check signup and free terms first, then create a key, install dependencies and validate the response. Examples read credentials from environment variables.

官方文档复核Official docs reviewed: 2026-10-07独立 API 实测Independent API test: 尚未记录Not recorded

注册与网络前提Signup and network requirements

网络 / 地区
中国站新人免费额度仅限官方指定地域;本教程中的示例 endpoint 对应北京地域。
账号
阿里云账号、已开通百炼服务、对应地域的 API Key;使用部分能力需 Workspace ID。
手机号
阿里云注册验证要求以当前账号注册页为准。
实名认证
官方文档说明,开通服务时若提示未实名认证,需先完成实名认证。
信用卡 / 付款方式
免费额度与付费资源由模型、地域和账户条件决定;是否需绑卡未从快速开始页确认。

这些条件会因账号、地区和产品计划而变化。标注“待核验”表示 FreeLLM 尚未从当前链接的官方资料确认;不要据此推断为不需要。These requirements can vary by account, region and plan. “Unverified” means FreeLLM has not confirmed the condition from the linked official sources; it does not mean the requirement is absent.

获取并安全设置 API KeyGet and safely set your API key

在终端设置密钥Set the key in your terminal

以下命令只为当前终端会话设置环境变量。请在自己的电脑上把尖括号内容替换成真实密钥,不要把密钥发给 FreeLLM 或粘贴到公开代码。These commands set a variable for the current terminal session. Replace the angle-bracket text with your key on your own device; never send it to FreeLLM or commit it to source code.

Windows PowerShellWindows PowerShell

$env:DASHSCOPE_API_KEY = "<在此粘贴本地 API Key>"

macOS / LinuxmacOS / Linux

export DASHSCOPE_API_KEY="<在此粘贴本地 API Key>"

FreeLLM 资源记录FreeLLM resource records

详细操作步骤Detailed operation paths

每条路径都拆成前置条件、步骤、可复制命令和验证动作;免费条件仍以官方页面实时状态为准。curl 命令按 macOS / Linux shell 编写,Windows 用户可使用同页的 Python 或 Node.js 示例。Each path includes prerequisites, steps, copyable commands and a validation action; free terms still follow the provider's live official policy. The curl examples use a macOS/Linux shell; Windows users can run the Python or Node.js examples on this page.

百炼北京地域新人免费模型 API

api

EndpointEndpoint
https://dashscope.aliyuncs.com/compatible-mode/v1
认证Authentication
Authorization: Bearer API key
额度与限制Limits

通常每模型 100 万 Tokens,90 天有效;OAuth 认证另有每日 2000 次独立免费额度;具体模型额度与 RPM/TPM 以模型页为准。

前置条件Prerequisites

  • 阿里云百炼北京地域账户See official terms
  • 通用 DASHSCOPE API KeyDASHSCOPE API Key
  • 目标模型仍有新人免费额度See official terms

操作步骤Steps

  1. 确认免费额度

    在百炼免费额度页确认目标模型的剩余额度、90 天到期时间,并确认该模型支持免费额度。

  2. 开启用完即停

    已实名用户建议开启“免费额度用完即停”;未实名用户系统默认强制停止。

  3. 使用通用 API Key

    不要使用 Token Plan / Coding Plan 专属 Key;通用 Key 的实时推理会优先扣免费额度。

  4. 发送最小请求

    使用北京地域 OpenAI 兼容 Base URL 调用目标模型。

    可复制命令Copyable command
    export DASHSCOPE_API_KEY="你的 Key"
    curl https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions -H "Authorization: Bearer $DASHSCOPE_API_KEY" -H 'Content-Type: application/json' --data '{"model":"qwen-plus","messages":[{"role":"user","content":"Hello"}]}'

    预期结果Expected:HTTP 200;免费额度页面出现对应消耗,且没有现金账单。

  5. Python SDK 示例

    安装 OpenAI SDK;在运行环境设置 DASHSCOPE_API_KEY,示例代码通过环境变量读取密钥。

    可复制命令Copyable command
    python -m pip install -U openai
    
    import os
    from openai import OpenAI
    
    client = OpenAI(
        api_key=os.environ["DASHSCOPE_API_KEY"],
        base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    )
    response = client.chat.completions.create(
        model="qwen-plus",
        messages=[{"role": "user", "content": "用一句话解释 API 是什么。"}],
    )
    print(response.choices[0].message.content)

    预期结果Expected:终端打印模型生成的回复;再到提供商控制台确认请求状态和额度扣减。

  6. Node.js SDK 示例

    安装 OpenAI SDK;在运行环境设置 DASHSCOPE_API_KEY,示例代码通过环境变量读取密钥。

    可复制命令Copyable command
    npm install openai
    
    import OpenAI from "openai";
    
    const client = new OpenAI({
      apiKey: process.env.DASHSCOPE_API_KEY,
      baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1",
    });
    const response = await client.chat.completions.create({
      model: "qwen-plus",
      messages: [{ role: "user", content: "用一句话解释 API 是什么。" }],
    });
    console.log(response.choices[0].message.content);

    预期结果Expected:Node.js 打印模型生成的回复;再到提供商控制台确认请求状态和额度扣减。

验证动作Validation

请求成功,并在免费额度页确认扣减来自目标模型的新人免费额度;已实名账号确认用完即停已开启。

常见问题Common issues
  • 只有北京地域支持新人模型免费额度。。
  • Token Plan/Coding Plan 专属 Key 不会消耗新人免费额度。Token Plan/Coding Plan Key 。
  • 已实名用户未开启用完即停时,额度耗尽后可能自动转 PAYG。, PAYG。

官方来源Official sources

decision-model-preview System One 限时免费 API

api

EndpointEndpoint
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/systemone
认证Authentication
Authorization: Bearer API key
额度与限制Limits

1,200 RPM / 2,000,000 TPM in both Beijing and Singapore according to the current official model page.

前置条件Prerequisites

  • 百炼 API KeyAPI Key
  • 业务空间 Workspace IDWorkspace ID
  • 模型页仍显示限时免费See official terms

操作步骤Steps

  1. 确认限免

    在官方 decision-model-preview 模型页确认北京/新加坡价格仍为“限时免费”。

  2. 准备 Workspace

    记录百炼业务空间 Workspace ID,并使用对应地域 endpoint。

  3. 发送 System One 请求

    POST /compatible-mode/v1/systemone,提交 state 与 choice/noul/score 类型问题;模型返回结构化判定与置信度。

    操作Action:按 https://help.aliyun.com/zh/model-studio/decision-model-api 的最新示例构造请求。

  4. 检查账单

    调用后检查控制台价格/账单;限免结束后停止大批量调用。

  5. Python SDK 示例

    安装 OpenAI SDK;在运行环境设置 DASHSCOPE_API_KEY,示例代码通过环境变量读取密钥。

    可复制命令Copyable command
    python -m pip install -U openai
    
    import os
    from openai import OpenAI
    
    client = OpenAI(
        api_key=os.environ["DASHSCOPE_API_KEY"],
        base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    )
    response = client.chat.completions.create(
        model="qwen-plus",
        messages=[{"role": "user", "content": "用一句话解释 API 是什么。"}],
    )
    print(response.choices[0].message.content)

    预期结果Expected:终端打印模型生成的回复;再到提供商控制台确认请求状态和额度扣减。

  6. Node.js SDK 示例

    安装 OpenAI SDK;在运行环境设置 DASHSCOPE_API_KEY,示例代码通过环境变量读取密钥。

    可复制命令Copyable command
    npm install openai
    
    import OpenAI from "openai";
    
    const client = new OpenAI({
      apiKey: process.env.DASHSCOPE_API_KEY,
      baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1",
    });
    const response = await client.chat.completions.create({
      model: "qwen-plus",
      messages: [{ role: "user", content: "用一句话解释 API 是什么。" }],
    });
    console.log(response.choices[0].message.content);

    预期结果Expected:Node.js 打印模型生成的回复;再到提供商控制台确认请求状态和额度扣减。

验证动作Validation

请求返回结构化 decision results;控制台模型价格仍为限时免费且账单未产生付费调用。

常见问题Common issues
  • 它不是 chat/completions 文本生成模型。chat/completions 。
  • Endpoint 需要 Workspace ID。Endpoint Workspace ID。
  • 限免结束时间未公开,必须复核价格页。, 。

官方来源Official sources