MCPcopy Create free account
hub / github.com/CaviraOSS/OpenReason / callOpenAI

Function callOpenAI

src/api/openai.ts:3–7  ·  view source on GitHub ↗
(prompt: string, apiKey: string, model: string, timeout = 30000)

Source from the content-addressed store, hash-verified

1import { ChatOpenAI } from "@langchain/openai"
2
3export async function callOpenAI(prompt: string, apiKey: string, model: string, timeout = 30000): Promise<string> {
4 const client = new ChatOpenAI({ modelName: model, openAIApiKey: apiKey, timeout })
5 const res = await client.invoke(prompt)
6 return typeof res.content === "string" ? res.content : Array.isArray(res.content) ? res.content.map((c: any) => (typeof c === "string" ? c : c.text || "")).join("") : JSON.stringify(res.content)
7}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected