MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / probeOpenAI

Function probeOpenAI

src/workspaces/agent-probe.ts:91–111  ·  view source on GitHub ↗
(input: CodexProbeInput)

Source from the content-addressed store, hash-verified

89}
90
91export async function probeOpenAI(input: CodexProbeInput): Promise<ProbeResult> {
92 const client = new OpenAI({ apiKey: input.apiKey, baseURL: input.baseUrl });
93 if (input.wireApi === 'responses') {
94 const resp = await client.responses.create({
95 model: input.model,
96 input: 'Hi',
97 max_output_tokens: 512,
98 });
99 return { text: resp.output_text ?? '' };
100 }
101 const resp = await client.chat.completions.create({
102 model: input.model,
103 messages: [{ role: 'user', content: 'Hi' }],
104 max_tokens: 512,
105 });
106 const choice = resp.choices[0]?.message as { content?: string | null; reasoning_content?: string | null } | undefined;
107 // Prefer the final answer; fall back to the reasoning trace so a reasoning
108 // model that returned only thinking still shows it spoke (not "(empty reply)").
109 const text = choice?.content?.trim() || choice?.reasoning_content?.trim() || '';
110 return { text };
111}
112
113/**
114 * Single dispatcher: probe an endpoint by its wire shape. The one place that

Callers 1

probeByWireShapeFunction · 0.85

Calls 1

createMethod · 0.65

Tested by

no test coverage detected