@navetacandra/deepinfra
is a Node.js package that provides a DeepInfra API consumer with no APIKEY needed. This package is designed to be lightweight and does not use any additional dependencies.
To install the package, use npm:
npm install @navetacandra/deepinfra
const { Conversation } = require('@navetacandra/deepinfra');
const conversation = new Conversation({
history: [], // load conversation history
stream: false, // if true, returns a stream of the response
rewritedTo: '' // redirected URL to the DeepInfra API
});
await conversation.init(); // initialize the conversation
console.log(conversation.models);
conversation.setModel('meta-llama/Meta-Llama-3.1-70B-Instruct');
// asynchronously
console.log(await conversation.completion('Hello, how are you?'));
// or stream
conversation.on('chat', chat => console.log(chat));
conversation.on('completion', response => process.stdout.write(response));
conversation.completion('Hello, how are you?');
conversation.on('chat', chat => console.log(chat)); // on new chat pushed
conversation.on('completion', response => process.stdout.write(response)); // on completion stream response
conversation.on('error', error => console.error(error)); // on error created
See the usage section for detailed examples on how to use this package, or see the examples folder in the repository.
This package is designed to be lightweight and does not rely on any additional dependencies.