You’ll need to obtain an API key and set it as an environment variable named DEEPINFRA_API_TOKEN
(or pass it into the constructor), then call the model as shown below:
Copy
Ask AI
import { ChatDeepInfra } from "@langchain/community/chat_models/deepinfra";import { HumanMessage } from "@langchain/core/messages";const apiKey = process.env.DEEPINFRA_API_TOKEN;const model = "meta-llama/Meta-Llama-3-70B-Instruct";const chat = new ChatDeepInfra({ model, apiKey,});const messages = [new HumanMessage("Hello")];const res = await chat.invoke(messages);console.log(res);