跳到主要内容
您可以通过访问其官网注册 API 密钥来开始使用 AI21Labs 的 Jurassic 系列模型,并查看所有可用的基础模型。 以下是在 LangChain.js 中初始化实例的示例:
有关安装 LangChain 软件包的一般说明,请参阅此部分
npm
npm install @langchain/community @langchain/core
import { AI21 } from "@langchain/community/llms/ai21";

const model = new AI21({
  ai21ApiKey: "YOUR_AI21_API_KEY", // Or set as process.env.AI21_API_KEY
});

const res = await model.invoke(`Translate "I love programming" into German.`);

console.log({ res });

/*
  {
    res: "\nIch liebe das Programmieren."
  }
 */

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.