MCPcopy Create free account
hub / github.com/OpenPipe/OpenPipe / OpenAI

Class OpenAI

client-libs/typescript/src/openai.ts:20–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19export type ClientOptions = openai.ClientOptions & { openpipe?: OpenPipeConfig | OpenPipe };
20export default class OpenAI extends openai.OpenAI {
21 constructor({ openpipe, ...options }: ClientOptions = {}) {
22 super({ ...options });
23
24 const openpipeClient = openpipe instanceof OpenPipe ? openpipe : new OpenPipe(openpipe);
25 const openPipeApiKey = openpipeClient.baseClient.request.config.TOKEN;
26
27 if (typeof openPipeApiKey === "string" && openPipeApiKey.length > 0) {
28 this.chat.setClients(
29 openpipeClient,
30 new openai.OpenAI({
31 baseURL: openpipeClient.baseClient.request.config.BASE,
32 apiKey: openPipeApiKey,
33 }),
34 );
35 } else {
36 console.warn(
37 "You're using the OpenPipe client without an API key. No completion requests will be logged.",
38 );
39 }
40 }
41 chat: WrappedChat = new WrappedChat(this);
42}
43
44class WrappedChat extends openai.OpenAI.Chat {
45 setClients(opClient: OpenPipe, opCompletionClient: openai.OpenAI) {

Calls

no outgoing calls

Tested by 2