npm install qianfan
import { Qianfan } from "qianfan";
const api_client = new Qianfan("API_KEY", "SECRET_KEY");
async function main() {
// 发起对话
const resp = await api_client.chat({
messages: [
{
role: "user",
content: "Hello World",
},
],
});
// 打印结果
console.log(resp.result);
// 文生图
const text2image_resp = await client.text2image({
prompt: "cat",
});
// 打印结果
console.log(text2image_resp);
}
main();
Qianfan JS SDK is released under the MIT license.