(input: CodexProbeInput)
| 89 | } |
| 90 | |
| 91 | export 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 |
no test coverage detected