Skip to main content

ChatPrem

设置

¥Setup

  1. 创建 Prem AI 账户并获取你的 API 密钥 此处

    ¥Create a Prem AI account and get your API key here.

  2. 内联导出或设置你的 API 密钥。ChatPrem 类默认为 process.env.PREM_API_KEY

    ¥Export or set your API key inline. The ChatPrem class defaults to process.env.PREM_API_KEY.

export PREM_API_KEY=your-api-key

你可以按如下方式使用 Prem AI 提供的模型:

¥You can use models provided by Prem AI as follows:

npm install @langchain/community @langchain/core
import { ChatPrem } from "@langchain/community/chat_models/premai";
import { HumanMessage } from "@langchain/core/messages";

const model = new ChatPrem({
// In Node.js defaults to process.env.PREM_API_KEY
apiKey: "YOUR-API-KEY",
// In Node.js defaults to process.env.PREM_PROJECT_ID
project_id: "YOUR-PROJECT_ID",
});

console.log(await model.invoke([new HumanMessage("Hello there!")]));

API Reference:

¥Related