import { withSpendGuard, type OpenAIBindingOptions } from '../spend-guard'; /** * One-line spend governance for the OpenAI SDK and the OpenAI Agents SDK. * * Hook point: the OpenAI client's `chat.completions.create`. `withSpendGuard` * (the shared core binding) wraps that method so `guard.decide()` runs before * every dispatch and can block/downgrade. Because the OpenAI Agents SDK * (`@openai/agents`) drives the same underlying `OpenAI` client, passing the * guarded client to the agent runner governs every model call the agent makes. * * This is a thin, named re-export of `withSpendGuard` so the OpenAI integration * is discoverable at `@agentguard-run/spend/frameworks/openai`. It reuses the * existing enforcement verbatim — no second code path. * * @example OpenAI SDK * import OpenAI from 'openai'; * import { withSpendGuardOpenAI } from '@agentguard-run/spend/frameworks/openai'; * * const client = withSpendGuardOpenAI(new OpenAI(), { policy, scope }); * await client.chat.completions.create({ model: 'gpt-5', messages }); * * @example OpenAI Agents SDK * import OpenAI from 'openai'; * import { Agent, run, setDefaultOpenAIClient } from '@openai/agents'; * import { withSpendGuardOpenAI } from '@agentguard-run/spend/frameworks/openai'; * * setDefaultOpenAIClient(withSpendGuardOpenAI(new OpenAI(), { policy, scope })); * await run(new Agent({ name: 'assistant' }), 'hello'); */ export function withSpendGuardOpenAI(client: TClient, opts: OpenAIBindingOptions): TClient { return withSpendGuard(client, opts) as TClient; } export const withOpenAISpendGuard = withSpendGuardOpenAI; export type { OpenAIBindingOptions } from '../spend-guard';