OpenPipe Node API Library
This library wraps TypeScript or Javascript OpenAI API calls and logs additional data to the configured OPENPIPE_BASE_URL
for further processing.
It is fully compatible with OpenAI's sdk and logs both streaming and non-streaming requests and responses.
Installation
npm install --save openpipe
yarn add openpipe
Import
ESM
import OpenAI from "openpipe/openai";
CJS
const OpenAI = require("openpipe/openai").default;
Usage
- Create a project at https://app.openpipe.ai
- Find your project's API key at https://app.openpipe.ai/settings
- Configure the OpenPipe client as shown below.
import OpenAI from "openpipe/openai";
const openai = new OpenAI({
apiKey: "my api key",
openpipe: {
apiKey: "my api key",
baseUrl: "my url",
},
});
async function main() {
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: "Say this is a test" }],
model: "gpt-4o",
store: true,
metadata: {
prompt_id: "extract_user_intent",
any_key: "any_value",
},
});
console.log(completion.choices);
}
main();