Cohere
caution
You are currently on a page documenting the use of Cohere models as text completion models. Many popular models available on Cohere are chat completion models.
You may be looking for this page instead.
LangChain.js supports Cohere LLMs. Here's an example:
You'll first need to install the @langchain/cohere
package.
- npm
- Yarn
- pnpm
npm install @langchain/cohere
yarn add @langchain/cohere
pnpm add @langchain/cohere
import { Cohere } from "@langchain/cohere";
const model = new Cohere({
maxTokens: 20,
apiKey: "YOUR-API-KEY", // In Node.js defaults to process.env.COHERE_API_KEY
});
const res = await model.invoke(
"What would be a good company name a company that makes colorful socks?"
);
console.log({ res });
API Reference:
- Cohere from
@langchain/cohere