![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@lastmileai/lastmileai
Advanced tools
This library provides access to the LastMile AI API from Node.js. The code should reflect the same API endpoints documented here: https://lastmileai.dev/docs/api
This library requires a LastMile AI API Token, which can be obtained from https://lastmileai.dev/settings?page=tokens.
Important note: this library should only be used from a server-side context, where the API key can be securely accessed. Using this library from client-side browser code will expose your private API key!
npm install lastmileai
This library needs to be configured with your API Token (aka API key) obtained above. You can store the API key in an environment variable or alternative secure storage that can be accessed in your server-side code. For example, to initialize the library with the API key loaded from environment variable:
import { LastMile } from "lastmileai";
const lastmile = new LastMile({apiKey: process.env.LASTMILEAI_API_KEY ?? ""});
OpenAI completions are supported out-of the box for ChatGPT and GPT3 models:
const completion = await lastmile.createOpenAICompletion({
completionParams: {
model: "text-davinci-003",
prompt: "Your prompt here",
},
});
const responseText = completion.choices[0]?.text;
const completion = await lastmile.createOpenAIChatCompletion({
completionParams: {
model: "gpt-3.5-turbo",
messages: [
{ role: "user", content: "Your prompt here" },
],
},
});
const responseText = completion.choices[0].message?.content;
If you've tuned any GPT3-based custom models in LastMile or by using this library, you can easily perform inference/completions against the context of their associated datasets (stored in the model's embeddings):
const model = await lastmile.readModel("Your model ID");
const completion = await lastmile.createOpenAICompletion({
completionParams: {
model: "text-davinci-003",
prompt: "Your prompt here",
},
embeddingCollectionId: model.embeddingCollections[0]?.id,
});
const responseText = completion.choices[0]?.text;
FAQs
Node.js library for LastMile AI API
We found that @lastmileai/lastmileai demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.