文档

API详情

更新时间:
一键部署

ChatGLM

说明

支持的领域 / 任务:aigc

模型概览

模型名

模型简介

chatglm-6b-v2

该模型为ChatGLM2系列,仅支持prompt格式输入。

chatglm3-6b

该模型为ChatGLM3系列,支持输入输出token合计是7500,其中单轮最大输出token为1500,单轮最大输入token为6000(如果超过该阈值按最后一次完整的对话进行截断),支持message和prompt格式输入,支持流式调用。

SDK使用

前提条件

文本生成

以下示例展示了调用ChatGLM模型对一个用户指令进行响应的代码。

说明

需要使用您的API-KEY替换示例中的 YOUR_DASHSCOPE_API_KEY ,代码才能正常运行。

设置API-KEY

export DASHSCOPE_API_KEY=YOUR_DASHSCOPE_API_KEY

通过message访问

重要

目前只有chatglm3-6b支持message方式访问。

from http import HTTPStatus
from dashscope import Generation


def call_with_messages():
    messages = [
        {'role': 'system', 'content':'You are a helpful assistant.'},
        {'role': 'user', 'cont ent': '介绍下杭州'}]
    gen = Generation()
    response = gen.call(
        'chatglm3-6b',
        messages=messages,
        result_format='message',  # set the result is message format.
    )
    print(response)

if __name__ == '__main__':
    call_with_messages()
// Copyright (c) Alibaba, Inc. and its affiliates.

import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.MessageManager;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;

public class Main {
  public static void usage()
      throws NoApiKeyException, ApiException, InputRequiredException {
    MessageManager msgManager = new MessageManager(10);
    Message systemMsg = Message.builder().role(Role.SYSTEM.getValue()).content("You are a helpful assistant.").build();
    Message userMsg = Message.builder().role(Role.USER.getValue()).content("介绍下杭州").build();
    msgManager.add(systemMsg);
    msgManager.add(userMsg);

    GenerationParam param = GenerationParam.builder()
        .model("chatglm3-6b")
        .messages(msgManager.get())
        .build();
    Generation gen = new Generation();
    GenerationResult result = gen.call(param);
    System.out.println(JsonUtils.toJson(result));
  }

  public static void main(String[] args) {
    try {
      usage();
    } catch (ApiException | NoApiKeyException | InputRequiredException e) {
      System.out.println(e.getMessage());
    }
    System.exit(0);
  }
}

通过prompt调用

from http import HTTPStatus
import dashscope

def call_with_prompt():
    prompt = '介绍下杭州'
    rsp = dashscope.Generation.call(model='chatglm3-6b',
                                    prompt=prompt,
                                    history=[])
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        print(rsp.output)
        print(rsp.usage)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))


if __name__ == '__main__':
    call_with_prompt()
// 参数定义,保存文件为ChatGLMParam.java
import static com.alibaba.dashscope.utils.ApiKeywords.HISTORY;
import static com.alibaba.dashscope.utils.ApiKeywords.PROMPT;

import com.alibaba.dashscope.base.HalfDuplexServiceParam;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.utils.ApiKeywords;
import com.alibaba.dashscope.utils.JsonUtils;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;

@EqualsAndHashCode(callSuper = true)
@Data
@SuperBuilder
public class ChatGLMParam extends HalfDuplexServiceParam {
  /** The input prompt. */
  private String prompt;

  /** { "user":"今天天气好吗?", "bot":"今天天气不错,要出去玩玩嘛?" }, */
  private List<List<String>> history;

  @Override
  public JsonObject getInput() {
    JsonObject jsonObject = new JsonObject();
    jsonObject.addProperty(PROMPT, getPrompt());
    JsonArray ar = JsonUtils.toJsonElement(history).getAsJsonArray();
    jsonObject.add(HISTORY, ar);
    return jsonObject;
  }

  /**
   * Get the websocket binary data, only for websocket binary input data.
   *
   * @return Generation param has no binary data.
   */
  @Override
  public ByteBuffer getBinaryData() {
    return null;
  }

  @Override
  public JsonObject getHttpBody() {
    JsonObject requestObject = new JsonObject();
    requestObject.addProperty(ApiKeywords.MODEL, getModel());
    requestObject.add(ApiKeywords.INPUT, getInput());
    Map<String, Object> params = getParameters();
    if (params != null && !params.isEmpty()) {
      requestObject.add(ApiKeywords.PARAMETERS, JsonUtils.parametersToJsonObject(params));
    }
    return requestObject;
  }

  @Override
  public void validate() throws InputRequiredException {}
}

// ChatGlm主类,保存成Main.java,需要用到参数类

import java.util.Arrays;

import com.alibaba.dashscope.common.DashScopeResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.GeneralHalfDuplexApi;
import com.alibaba.dashscope.utils.JsonUtils;

public class Main {
  public static void usage()
      throws NoApiKeyException, ApiException, InputRequiredException {
    GeneralHalfDuplexApi gen = new GeneralHalfDuplexApi();
    ChatGLMParam param = ChatGLMParam.builder().model("chatglm3-6b").prompt("介绍下杭州").history(Arrays.asList()).build();
    DashScopeResult result = gen.call(param);
    System.out.println(JsonUtils.toJson(result));
  }

  public static void main(String[] args) {
    try {
      usage();
    } catch (ApiException | NoApiKeyException | InputRequiredException e) {
      System.out.println(e.getMessage());
    }
    System.exit(0);
  }
}

通过流式调用

from http import HTTPStatus
from dashscope import Generation


def call_with_stream():
    messages = [
        {'role': 'user', 'content': '介绍下杭州?'}]
    responses = Generation.call(
        model='chatglm3-6b',
        messages=messages,
        result_format='message',  # set the result to be "message" format.
        stream=True,
        incremental_output=True  # get streaming output incrementally
    )
    full_content = ''  # with incrementally we need to merge output.
    for response in responses:
        if response.status_code == HTTPStatus.OK:
            full_content = response.output.choices[0]['message']['content']
            print(response)
        else:
            print('Request id: %s, Status code: %s, error code: %s, error message: %s' % (
                response.request_id, response.status_code,
                response.code, response.message
            ))
    print('Full response:\n' + full_content)


if __name__ == '__main__':
    call_with_stream()
// Copyright (c) Alibaba, Inc. and its affiliates.

import java.util.Arrays;
import java.util.concurrent.Semaphore;
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.aigc.generation.models.QwenParam;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.ResultCallback;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import io.reactivex.Flowable;

public class Main {
  public static void streamCallWithMessage()
      throws NoApiKeyException, ApiException, InputRequiredException {
    Generation gen = new Generation();
    Message userMsg = Message
    .builder()
    .role(Role.USER.getValue())
    .content("介绍下杭州?")
    .build();
    QwenParam param =
        QwenParam.builder().model("chatglm3-6b").messages(Arrays.asList(userMsg))
            .resultFormat(QwenParam.ResultFormat.MESSAGE)
            .topP(0.8)
            .incrementalOutput(true) // get streaming output incrementally
            .build();
    Flowable<GenerationResult> result = gen.streamCall(param);
    StringBuilder fullContent = new StringBuilder();
    result.blockingForEach(message -> {
      fullContent.append(message.getOutput().getChoices().get(0).getMessage().getContent());
      System.out.println(JsonUtils.toJson(message));
    });
    System.out.println("Full content: \n" + fullContent.toString());
  }

  public static void streamCallWithCallback()
      throws NoApiKeyException, ApiException, InputRequiredException,InterruptedException {
    Generation gen = new Generation();
    Message userMsg = Message
    .builder()
    .role(Role.USER.getValue())
    .content("介绍下杭州?")
    .build();
    QwenParam param = QwenParam
    .builder()
    .model("chatglm3-6b")
    .resultFormat(QwenParam.ResultFormat.MESSAGE)
    .messages(Arrays.asList(userMsg))
    .topP(0.8)
    .incrementalOutput(true) // get streaming output incrementally
    .build();
    Semaphore semaphore = new Semaphore(0);
    StringBuilder fullContent = new StringBuilder();
    gen.streamCall(param, new ResultCallback<GenerationResult>() {

      @Override
      public void onEvent(GenerationResult message) {
        fullContent.append(message.getOutput().getChoices().get(0).getMessage().getContent());
        System.out.println(message);
      }
      @Override
      public void onError(Exception err){
        System.out.println(String.format("Exception: %s", err.getMessage()));
        semaphore.release();
      }

      @Override
      public void onComplete(){
        System.out.println("Completed");
        semaphore.release();
      }
      
    });
    semaphore.acquire();
    System.out.println("Full content: \n" + fullContent.toString());
  }
  public static void main(String[] args) {
    try {
      streamCallWithMessage();
    } catch (ApiException | NoApiKeyException | InputRequiredException e) {
      System.out.println(e.getMessage());
    }
    try {
      streamCallWithCallback();
    } catch (ApiException | NoApiKeyException | InputRequiredException | InterruptedException e) {
      System.out.println(e.getMessage());
    }
    System.exit(0);
  }
}

参数配置

参数

类型

默认值

说明

model

string

-

chatglm-6b-v2/chatglm3-6b。

prompt

string

-

用户按当前输入的期望模型执行指令。

history

list

[]

输入输出字符串列表。

stream (可选)

bool

False

是否使用流式输出。当以stream模式输出结果时,接口返回结果为generator,需要通过迭代获取结果,默认每次输出为当前生成的整个序列,最后一次输出为最终全部生成结果,可以通过参数incremental_output为False改变输出模式为非增量输出。

incremental_output (可选)

bool

False

控制流式输出模式,即后面内容会包含已经输出的内容;设置为True,将开启增量输出模式,后面输出不会包含已经输出的内容,您需要自行拼接整体输出,参考流式输出示例代码。

messages

list dict

-

用户输入的内容,dict内主要包含2个key:role和content,其中role支持user、assistant、system,content为对应role的text输入。目前仅chatglm3-6b支持。

result_format

string

-

用户返回的内容类型,默认为text,当输入格式为messages时可配置为message。

返回结果

  • 非流式返回结果示例

{
    "status_code": 200,
    "request_id": "375d11ad-a8f5-962e-a3fd-32d8f4d17000",
    "code": "",
    "message": "",
    "output": {
        "text": {
            "history": [
                [
                    "介绍下杭州",
                    "\n 杭州是中华人民共和国浙江省的省会,位于中国东南沿海地区,地处长江三角洲南翼。杭州拥有悠久的历史和灿烂的文化,自古以来就是著名的历史文化名城。杭州的地理位置优越,交通便捷,是长江三角洲地区的重要城市之一。\n\n杭州的气候属于亚热带季风气候,四季分明,温暖湿润,雨量充沛。全年气温适中,平均气温在 16-22℃ 之间。杭州的四季风光各具特色,春天的杭州生机盎然,夏天的杭州热情洋溢,秋天的杭州硕果累累,冬天的杭州银装素裹。\n\n杭州是中国著名的旅游胜地,拥有许多著名的旅游景点,如西湖、灵隐寺、宋城、西溪湿地等。此外,杭州还有许多特色美食,如龙井虾仁、西湖醋鱼、东坡肉等。\n\n杭州是中国的互联网科技产业发达的城市之一,拥有阿里巴巴、网易等知名互联网公司。此外,杭州还是中国的金融中心之一,拥有许多金融机构和保险公司。\n\n总之,杭州是一个历史悠久、文化底蕴深厚、风景秀丽、科技发达的城市,是中国重要的经济、文化和科技中心之一。"
                ]
            ],
            "response": "\n 杭州是中华人民共和国浙江省的省会,位于中国东南沿海地区,地处长江三角洲南翼。杭州拥有悠久的历史和灿烂的文化,自古以来就是著名的历史文化名城。杭州的地理位置优越,交通便捷,是长江三角洲地区的重要城市之一。\n\n杭州的气候属于亚热带季风气候,四季分明,温暖湿润,雨量充沛。全年气温适中,平均气温在 16-22℃ 之间。杭州的四季风光各具特色,春天的杭州生机盎然,夏天的杭州热情洋溢,秋天的杭州硕果累累,冬天的杭州银装素裹。\n\n杭州是中国著名的旅游胜地,拥有许多著名的旅游景点,如西湖、灵隐寺、宋城、西溪湿地等。此外,杭州还有许多特色美食,如龙井虾仁、西湖醋鱼、东坡肉等。\n\n杭州是中国的互联网科技产业发达的城市之一,拥有阿里巴巴、网易等知名互联网公司。此外,杭州还是中国的金融中心之一,拥有许多金融机构和保险公司。\n\n总之,杭州是一个历史悠久、文化底蕴深厚、风景秀丽、科技发达的城市,是中国重要的经济、文化和科技中心之一。"
        }
    },
    "usage": {
        "input_tokens":4 ,
        "output_tokens": 242
    }
}
  • 流式返回结果示例

{"status_code": 200, "request_id": "99bc52af-e64f-9a9f-9f47-6673bc99e828", "code": "", "message": "", "output": {"text": null, "finish_reason": null, "choices": [{"finish_reason": "null", "message": {"role": "assistant", "content": "西红柿牛腩是一道", "content_type": "text"}}]}, "usage": {"input_tokens": 12, "output_tokens": 3}}
{"status_code": 200, "request_id": "99bc52af-e64f-9a9f-9f47-6673bc99e828", "code": "", "message": "", "output": {"text": null, "finish_reason": null, "choices": [{"finish_reason": "null", "message": {"role": "assistant", "content": "西红柿牛腩是一道美味可口的菜肴,以下是制作西红柿牛肉", "content_type": "text"}}]}, "usage": {"input_tokens": 12, "output_tokens": 11}}
... ... ... ...
... ... ... ...
{"status_code": 200, "request_id": "99bc52af-e64f-9a9f-9f47-6673bc99e828", "code": "", "message": "", "output": {"text": null, "finish_reason": null, "choices": [{"finish_reason": "stop", "message": {"role": "assistant", "content": "西红柿牛腩是一道美味可口的菜肴,以下是制作西红柿牛肉的步骤:\n\n所需材料: \n- 牛腩 500克\n - 大西红柿 4个\n  -洋葱 1个 (切碎)\n   -大蒜 3瓣 ,切碎\n    -生姜 2片\n     -盐 适量\n      -黑胡椒 少许\n       -糖 少量\n        -酱油 适当\n         -水 足够\n          -香菜 若干\n           -油 适当的量\n            -面粉 适量的量(可选) 用于裹牛肉\n             -其他蔬菜(如胡萝卜、土豆等)可根据个人口味添加\n              \n步骤如下:  \n1. 将牛腩切成3-4厘米见方的块,用面粉或玉米淀粉裹好,备用。\n2. 在锅中加入适量的油,油热后加入洋葱、大蒜和生姜,翻炒至洋葱变透明。 注意不要炒糊。   \n3.加入牛肉块。用中火将牛肉两面煎至微黄色。煎好的牛肉取出备用,锅中油留用。  (如果之前选择不加面粉,此步骤可以直接进行)  如果牛肉比较大块的话,这一步可能需要翻煎几次,确保牛肉熟透。    \n4.在同一个锅中加入切好的西红柿块儿,翻炒均匀,然后加入适量的水,将西红柿煮烂。加入糖和酱油,搅拌均匀。如果西红柿比较酸,可以适当加入一些糖来平衡口感。     \n5.将煎过的牛肉重新加入锅中,转小火慢慢炖煮,直到牛肉变得非常软烂,汤汁变得浓稠。期间可以适时尝味,根据个人口味加盐和黑胡椒粉。      \n6.炖好的西红柿牛楠,撒上切好的香菜,即可出锅。可以搭配米饭或者面食食用。", "content_type": "text"}}]}, "usage": {"input_tokens": 12, "output_tokens": 366}}
  • 返回参数说明

返回参数

类型

说明

status_code

int

200(HTTPStatus.OK)表示请求成功,否则表示请求失败,可以通过code获取错误码,通过message字段获取错误详细信息。

request_Id

string

系统生成的标志本次调用的id。

code

string

表示请求失败,表示错误码,成功忽略。

message

string

失败,表示失败详细信息,成功忽略。

output

dict

调用结果信息,对于千问模型,包含输出text。

usage

dict

计量信息,表示本次请求计量数据。

text

dict

模型生成回复以及历史对话信息,response为本次输出,history为历史对话列表。

input_tokens

int

用户输入文本转换成Token后的长度,目前都是0,不支持统计。

output_tokens

int

模型生成回复转换为Token后的长度,目前都是0,不支持统计。

HTTP调用接口

功能描述

ChatGLM模型同时支持 HTTP 调用来完成客户的响应。

前提条件

提交接口调用

POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation

入参描述

传参方式

字段

类型

必选

描述

示例值

Header

Content-Type

String

请求类型:application/json

application/json

Accept

String

*/*,选择text/event-stream则会开启 SSE 响应,默认无设置

text/event-stream

Authorization

String

API-Key,例如:Bearer d1**2a

Bearer d1**2a

X-DashScope-WorkSpace

String

指明本次调用需要使用的workspace;需要注意的是,对于子账号Apikey调用,此参数为必选项,子账号必须归属于某个workspace才能调用;对于主账号Apikey此项为可选项,添加则使用对应的workspace身份,不添加则使用主账号身份。

ws_QTggmeAxxxxx

X-DashScope-SSE

String

跟Accept: text/event-stream 二选一即可启用SSE响应

enable

Body

model

String

指明需要调用的模型

chatglm3-6b

input.prompt

String

文本内容,支持中英文。

你好

input.history

List

用户与模型的对话历史。

[]

input.messages

List Dict

用户多轮对话信息输入。

[ {

"role": "user",

"content": "你好"

}]

parameters.incremental_output

Bool

用于控制流式输出模式,默认False,即后面内容会包含已经输出的内容;设置为True,将开启增量输出模式,后面输出不会包含已经输出的内容,您需要自行拼接整体输出,参考流式输出示例代码。

parameters.result_formatt

String

"text"表示旧版本的text

"message"表示兼容openai的message

"text"

出参描述

字段

类型

描述

示例值

output.text

Object

本次请求的算法输出内容。

我建议你去颐和园

request_id

String

本次请求的系统唯一码

7574ee8f-38a3-4b1e-9280-11c33ab46e51

请求示例(SSE关闭)

以下示例展示通过CURL命令来调用 chatglm3-6b模型的脚本(SSE 关闭)。

说明

需要使用您的API-KEY替换示例中的 your-dashscope-api-key ,代码才能正常运行。

curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation' \
--header 'Authorization: Bearer <YOUR-DASHSCOPE-API-KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "chatglm3-6b",
    "input":{
        "messages":[      
            {
                "role": "system",
                "content": "You are a helpful assistant."
            },
            {
                "role": "user",
                "content": "你好,请介绍一下故宫"
            }
        ]
    },
    "parameters": {
        "result_format": "message"
    }
}'
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation' \
--header 'Authorization: Bearer <YOUR-DASHSCOPE-API-KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "chatglm3-6b-v1",
    "input": {
        "prompt": "介绍下杭州",
        "history": []
    },
    "parameters":{
    }
}'

响应示例(SSE关闭)

{
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content_type": "text",
                    "content": "故宫,位于中国北京市中心,是中国明清两代的皇家宫殿,也是世界上现存规模最大、保存最为完整的木质结构古建筑之一。故宫始建于明成祖永乐四年(1406年),历时15年建成。它是明朝和清朝两代皇帝的皇家居所,共有24位皇帝在此居住和执政。\n\n故宫占地面积72万平方米,建筑面积约10万平方米。它共有宫殿建筑990多座,房屋8960间。整个建筑群按照南北中轴线布局,分为外朝和内廷两部分。外朝天子殿、中和殿和保和殿组成,是皇帝举行盛大典礼和处理政务的地方;内庭包括乾清宫、坤宁宫和储秀宫等,为皇帝和皇后居住的地方,同时也是皇帝处理日常政务的场所。此外,故宫还有御花园、东西六宫等众多宫殿和建筑。"
                }
            }
        ]
    },
    "usage": {
        "output_tokens": 180,
        "input_tokens": 11
    },
    "request_id": "3719bbfa-0ab8-997d-9207-21355f7320b3"
}

请求示例(SSE开启)

以下示例展示通过CURL命令来调用 chatglm3-6b模型的脚本(SSE 关闭)。

说明

需要使用您的API-KEY替换示例中的 your-dashscope-api-key ,代码才能正常运行。

curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation' \
--header 'Authorization: Bearer <YOUR-DASHSCOPE-API-KEY>' \
--header 'Content-Type: application/json' \
--header 'X-DashScope-SSE: enable' \
--data '{
    "model": "chatglm3-6b",
    "input":{
        "messages":[      
            {
                "role": "system",
                "content": "You are a helpful assistant."
            },
            {
                "role": "user",
                "content": "你好,请介绍一下故宫"
            }
        ]
    },
    "parameters": {
        "result_format": "message"
    }
}'
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation' \
--header 'Authorization: Bearer <YOUR-DASHSCOPE-API-KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "chatglm3-6b-v1",
    "input": {
        "prompt": "介绍下杭州",
        "history": []
    },
    "parameters":{
    }
}'

响应示例(SSE开启)

id:1
event:result
data:{"output":{"finish_reason":"null","text":"\n "},"usage":{"output_tokens":3,"input_tokens":15},"request_id":"1117fb64-5dd9-9df0-a5ca-d7ee0e97032d"}

id:2
event:result
data:{"output":{"finish_reason":"null","text":"\n 故宫(The Forbidden City)"},"usage":{"output_tokens":12,"input_tokens":15},"request_id":"1117fb64-5dd9-9df0-a5ca-d7ee0e97032d"}

... ... ... ...
... ... ... ...

id:25
event:result
data:{"output":{"finish_reason":"stop","text":"\n 故宫(The Forbidden City)是中国明清两代的皇宫,位于北京市中心,是世界上最大、保存最为完整的木质结构古建筑之一。故宫于明成祖永乐四年(1406年)开始建设,历经14年方告完成,共有9800余间房屋、300多座建筑。故宫以其丰富的文化遗产、精美的建筑艺术和悠久的历史而闻名于世界。\n\n故宫是中国古代宫殿建筑之精华,其建筑风格、布局严谨、精美、华丽,色彩斑斓,富丽堂皇。故宫也是世界上保存最完整、规模最宏大的古代木质结构建筑群之一,其建筑精美、色彩斑斓,富有变化和层次感,堪称中国古代建筑艺术的杰作。\n\n除此之外,故宫还有众多珍贵的文物和艺术品,包括古代瓷器、书画、玉器、金银器等,是中国和世界文化遗产的重要代表之一。"},"usage":{"output_tokens":190,"input_tokens":12},"request_id":"1117fb64-5dd9-9df0-a5ca-d7ee0e97032d"}
}

异常响应示例

在访问请求出错的情况下,输出结果中会通过 code 和 message 指明出错原因。

{
    "code":"InvalidApiKey",
    "message":"Invalid API-key provided.",
    "request_id":"fb53c4ec-1c12-4fc4-a580-cdb7c3261fc1"
}

状态码说明

大语言模型服务平台通用状态码请查阅:状态码说明

  • 本页导读 (1)
文档反馈