Optional
api?: TCohereApiThe API instance to use for making requests. Defaults to CohereChatApi.
Optional
auth?: CohereAuthConfigAuthentication configuration for Cohere. If not supplied, it will be loaded from the environment.
Optional
client?: HttpClient<THttpClientOptions>HTTP client to use for requests. If not supplied, the built-in fetch-based implementation will be used.
The model ID as defined by Cohere.
The Cohere Model Provider with the api specified by params.api
If no auth is passed and COHERE_API_KEY is not found in process.env
import { createCohereModelProvider } from "generative-ts";
const commandR = createCohereModelProvider({
modelId: "command-r-plus", // Cohere defined model ID
// you can explicitly pass auth here, otherwise by default it is read from process.env
});
const response = await commandR.sendRequest({
$prompt: "Brief History of NY Mets:",
preamble: "Talk like Jafar from Aladdin",
// all other Cohere /generate options available here
});
console.log(response.text);
import { createCohereModelProvider, CohereGenerateApi } from "generative-ts";
const command = createCohereModelProvider({
api: CohereGenerateApi,
modelId: "command",
});
const response = await command.sendRequest({
$prompt: "Brief History of NY Mets:",
});
Creates a Cohere ModelProvider with the CohereChatApi or legacy CohereGenerateApi
Compatible APIs
Provider Setup and Notes
Create an API account at Cohere
Obtain a Cohere API key and either pass them explicitly in
auth
or set them in the environment asCOHERE_API_KEY
By default, this will use the Cohere /chat API. To use the Legacy Cohere /generate API instead, pass CohereGenerateApi as the
api
parameter.Model Parameters
Model IDs