@urun-sh/openai 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/{ResponsesClient-BYx3YLGo.d.ts → ResponsesClient-BE3-hx3m.d.ts} +2 -0
  2. package/dist/{ResponsesClient-Dft3bg3b.d.cts → ResponsesClient-DjZWjlFH.d.cts} +2 -0
  3. package/dist/chunk-2T2YYBVX.js +1 -0
  4. package/dist/chunk-3WAJD62J.js +4 -0
  5. package/dist/{chunk-K23AZPI4.js → chunk-5HKWNK3O.js} +1 -1
  6. package/dist/chunk-7M6LY6DR.js +2 -0
  7. package/dist/chunk-BSHT6RZZ.js +1 -0
  8. package/dist/{chunk-GBBY3PCZ.js → chunk-FP4RSAIE.js} +1 -1
  9. package/dist/chunk-HR5H6S7L.js +1 -0
  10. package/dist/chunk-NY23USZF.js +57 -0
  11. package/dist/chunk-VLRMJRLS.js +6 -0
  12. package/dist/gemini-live.cjs +2 -2
  13. package/dist/gemini-live.d.cts +17 -2
  14. package/dist/gemini-live.d.ts +7 -2
  15. package/dist/gemini-live.js +1 -1
  16. package/dist/hosted/bin.cjs +65 -37
  17. package/dist/hosted/bin.js +3 -3
  18. package/dist/hosted/index.cjs +46 -19
  19. package/dist/hosted/index.d.cts +760 -272
  20. package/dist/hosted/index.d.ts +203 -107
  21. package/dist/hosted/index.js +1 -1
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.d.cts +4 -4
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +1 -1
  26. package/dist/{models-NYMZrklp.d.cts → models-DUdx_Y6X.d.cts} +1 -1
  27. package/dist/pi-extension/index.cjs +7 -7
  28. package/dist/pi-extension/index.d.cts +1 -1
  29. package/dist/pi-extension/index.d.ts +1 -1
  30. package/dist/pi-extension/index.js +1 -1
  31. package/dist/pi-extension/standalone.cjs +48 -48
  32. package/dist/proxy/cli.cjs +54 -40
  33. package/dist/proxy/cli.js +14 -14
  34. package/dist/proxy/index.cjs +33 -22
  35. package/dist/proxy/index.d.cts +546 -4
  36. package/dist/proxy/index.d.ts +185 -4
  37. package/dist/proxy/index.js +1 -1
  38. package/dist/responses-turn-Dr37N3kH.d.ts +486 -0
  39. package/dist/responses-turn-tNUHq5b0.d.cts +1807 -0
  40. package/dist/{translator-C9uPKypK.d.ts → translator-BCoRFaTs.d.ts} +1 -1
  41. package/dist/{translator-CcDBEfvm.d.cts → translator-Bh0Bp_Ie.d.cts} +3 -3
  42. package/dist/{video-out-D20UuJ8G.d.cts → video-out-CCksIcj8.d.cts} +5 -5
  43. package/package.json +12 -11
  44. package/dist/chunk-4MSBS7M6.js +0 -1
  45. package/dist/chunk-5NXM4IO3.js +0 -2
  46. package/dist/chunk-CWJRDBDC.js +0 -1
  47. package/dist/chunk-OI2OY32M.js +0 -1
  48. package/dist/chunk-RQBD4OAA.js +0 -6
  49. package/dist/chunk-STFRT5OY.js +0 -1
  50. package/dist/chunk-VNM4M4P3.js +0 -40
  51. package/dist/server-DuH_5OD9.d.ts +0 -84
  52. package/dist/server-wmUnMewW.d.cts +0 -206
  53. /package/dist/{chunk-YSFSRI3D.js → chunk-5CCJUNH7.js} +0 -0
  54. /package/dist/{models-NYMZrklp.d.ts → models-DUdx_Y6X.d.ts} +0 -0
  55. /package/dist/{video-out-CWesbk12.d.ts → video-out-IGQ4YQ-c.d.ts} +0 -0
@@ -1,5 +1,186 @@
1
- export { O as OpenAIProxyOptions, P as ProxyClients, a as ProxyIdentity, b as ProxyVideoOutLane, c as createOpenAIProxy } from '../server-DuH_5OD9.js';
2
- export { h as GEMINI_LIVE_PATH, V as VIDEO_OUT_SETUP_KEY } from '../translator-C9uPKypK.js';
3
- import 'node:http';
4
- import '../video-out-CWesbk12.js';
1
+ import { Server, IncomingMessage } from 'node:http';
2
+ import { f as ProxyHandlerOptions, P as ProxyClients } from '../responses-turn-Dr37N3kH.js';
3
+ export { D as DialObserver, a as DialReport, g as ProxyIdentity, h as ProxyVideoOutLane, S as SessionGoneError, U as UnknownModelError } from '../responses-turn-Dr37N3kH.js';
4
+ export { h as GEMINI_LIVE_PATH, V as VIDEO_OUT_SETUP_KEY } from '../translator-BCoRFaTs.js';
5
+ import { WebSocket } from 'ws';
6
+ import '../models-DUdx_Y6X.js';
7
+ import '../video-out-IGQ4YQ-c.js';
5
8
  import '../types-lsVTbNcH.js';
9
+
10
+ interface OpenAIProxyOptions extends ProxyHandlerOptions {
11
+ clients: ProxyClients;
12
+ }
13
+
14
+ declare function createOpenAIProxy(options: OpenAIProxyOptions): Server;
15
+
16
+ type GeminiLiveClients = Pick<ProxyClients, 'createResponse' | 'openAudio' | 'openVideo' | 'openVideoOut' | 'sessionHandle' | 'onSessionEnd'>;
17
+ interface LiveSnapshot {
18
+ model: string;
19
+
20
+ proxyHandle: string;
21
+
22
+ transcript: Array<Record<string, unknown>>;
23
+ }
24
+
25
+ declare class ResumptionRegistry {
26
+ private readonly snapshots;
27
+ store(scope: string, handle: string, snapshot: LiveSnapshot): void;
28
+ get(scope: string, handle: string): LiveSnapshot | undefined;
29
+ }
30
+
31
+ interface GeminiLiveCall {
32
+ clients: GeminiLiveClients;
33
+
34
+ scope: string;
35
+
36
+ onBindResumeHandle?: (handle: string) => void;
37
+
38
+ clientsForResume?: (resumeHandle: string) => Promise<GeminiLiveClients>;
39
+
40
+ release?: () => Promise<void>;
41
+ }
42
+
43
+ type GeminiLiveAuthenticate = (credential: string, req: IncomingMessage) => Promise<GeminiLiveCall>;
44
+ interface GeminiLiveOptions {
45
+
46
+ clients?: GeminiLiveClients;
47
+
48
+ apiKey?: string;
49
+
50
+ authenticate?: GeminiLiveAuthenticate;
51
+ }
52
+
53
+ declare function attachGeminiLive(server: Server, options: GeminiLiveOptions): () => Promise<void>;
54
+
55
+ declare function serveGeminiLiveSocket(ws: WebSocket, call: GeminiLiveCall, registry?: ResumptionRegistry): void;
56
+
57
+ declare const OPENAI_REALTIME_PATH = "/v1/realtime";
58
+
59
+ type OpenAIRealtimeResolver<S = unknown> = ((req: IncomingMessage) => Promise<RealtimeBinding<S>>) | {
60
+ resolve(req: IncomingMessage): Promise<RealtimeBinding<S>>;
61
+ };
62
+ interface RealtimeBinding<S = unknown> {
63
+
64
+ session?: S & {
65
+ sendResponseCreate?(params: unknown, input: unknown[], requestId: string): AsyncIterable<unknown>;
66
+ };
67
+ clients?: Pick<ProxyClients, 'createResponse'>;
68
+
69
+ voice: boolean;
70
+
71
+ audioSession?: {
72
+ audio: {
73
+ appendInputAudio(base64Pcm16: string): void;
74
+ onOutputAudio(handler: (b64: string) => void): () => void;
75
+ };
76
+
77
+ openaiRealtimeClaims?: Set<RealtimeBinding['audioSession']>;
78
+ };
79
+
80
+ model?: string;
81
+
82
+ resumed?: boolean;
83
+
84
+ turns?: () => AsyncIterable<{
85
+ kind: 'delta' | 'final' | 'turn_start' | 'turn_end' | 'turn_eager_end' | 'turn_resumed';
86
+ text?: string;
87
+ confidence?: number;
88
+ startMs?: number;
89
+ }>;
90
+
91
+ release?: () => Promise<void> | void;
92
+ }
93
+ interface OpenAIRealtimeOptions<S = unknown> {
94
+ resolver: OpenAIRealtimeResolver<S>;
95
+ }
96
+
97
+ declare function attachOpenAIRealtime<S = unknown>(server: Server, options: OpenAIRealtimeOptions<S>): () => Promise<void>;
98
+
99
+ declare class OpenAIRealtimeConnection<S = unknown> {
100
+ readonly id: string;
101
+ private readonly ws;
102
+ private readonly binding;
103
+ private readonly onClosed?;
104
+ private config;
105
+ private readonly sessionId;
106
+ private readonly conversationId;
107
+ private readonly items;
108
+
109
+ private pendingAudioBytes;
110
+ private pendingAudioTotalBytes;
111
+
112
+ private frozenAudio;
113
+ private inFlight;
114
+ private activeResponseId;
115
+
116
+ private responseFlushed;
117
+ private cancelled;
118
+ private voiceClaimed;
119
+ private audioLaneOwner;
120
+ private audioUnsubscribe;
121
+ private outOfTurnAudioWarned;
122
+ private audioOnlyTranscriptGapWarned;
123
+ private closed;
124
+
125
+ private turnLaneAbort;
126
+
127
+ private turnTranscript;
128
+
129
+ private lastCommittedTranscript;
130
+ constructor(opts: {
131
+ ws: WebSocket;
132
+ binding: RealtimeBinding<S>;
133
+ onClosed?: (conn: OpenAIRealtimeConnection<S>) => void;
134
+ });
135
+
136
+ private startTurnLane;
137
+
138
+ private onTurnEvent;
139
+
140
+ private takeTurnTranscript;
141
+ private onMessage;
142
+ private handle;
143
+
144
+ private ensureVoice;
145
+
146
+ private claimVoiceBinding;
147
+ private releaseVoiceBinding;
148
+ private warnAudioOnlyTranscriptGap;
149
+
150
+ private upstreamStream;
151
+ private startResponse;
152
+
153
+ private onOutputAudioFrame;
154
+
155
+ private messageItemAdded;
156
+
157
+ private messageItemOpenForAudio;
158
+ private beginMessageItem;
159
+ private beginAudioMessageItem;
160
+
161
+ private closeOpenItems;
162
+ private responseObject;
163
+ private failedResponse;
164
+
165
+ private doneResponse;
166
+ private upstreamErrorBody;
167
+ private emitUpstreamFault;
168
+
169
+ private cancelResponse;
170
+ private pushItem;
171
+ private itemToProtocol;
172
+ private send;
173
+ private fail;
174
+
175
+ private teardown;
176
+ }
177
+
178
+ declare function realtimeModelOf(req: IncomingMessage): string | undefined;
179
+
180
+ declare function realtimeBindingFor(clients: Pick<ProxyClients, 'createResponse'> & Partial<Pick<ProxyClients, 'supportsAudio' | 'openAudio'>>, model: string | undefined): Promise<RealtimeBinding<ProxyClients>>;
181
+
182
+ declare function fixedClientsResolver(clients: ProxyClients, apiKey?: string): {
183
+ resolve(req: IncomingMessage): Promise<RealtimeBinding<ProxyClients>>;
184
+ };
185
+
186
+ export { type GeminiLiveCall, type GeminiLiveClients, OPENAI_REALTIME_PATH, type OpenAIProxyOptions, OpenAIRealtimeConnection, type OpenAIRealtimeOptions, type OpenAIRealtimeResolver, ProxyClients, type RealtimeBinding, ResumptionRegistry, attachGeminiLive, attachOpenAIRealtime, createOpenAIProxy, fixedClientsResolver, realtimeBindingFor, realtimeModelOf, serveGeminiLiveSocket };
@@ -1 +1 @@
1
- import{b as t}from"../chunk-VNM4M4P3.js";import"../chunk-4MSBS7M6.js";import{a as r,h as o}from"../chunk-5NXM4IO3.js";import"../chunk-CWJRDBDC.js";import{c as e}from"../chunk-YSFSRI3D.js";e();export{r as GEMINI_LIVE_PATH,o as VIDEO_OUT_SETUP_KEY,t as createOpenAIProxy};
1
+ import{Q as I,a as n,b as p,c as m,f as l,g as a,h as x,i as s,j as O,k as f}from"../chunk-NY23USZF.js";import{d as r,e as i}from"../chunk-3WAJD62J.js";import{a as o,h as t}from"../chunk-7M6LY6DR.js";import"../chunk-BSHT6RZZ.js";import{c as e}from"../chunk-5CCJUNH7.js";e();export{o as GEMINI_LIVE_PATH,a as OPENAI_REALTIME_PATH,l as OpenAIRealtimeConnection,n as ResumptionRegistry,i as SessionGoneError,r as UnknownModelError,t as VIDEO_OUT_SETUP_KEY,p as attachGeminiLive,x as attachOpenAIRealtime,I as createOpenAIProxy,f as fixedClientsResolver,O as realtimeBindingFor,s as realtimeModelOf,m as serveGeminiLiveSocket};
@@ -0,0 +1,486 @@
1
+ import { C as CatalogRow } from './models-DUdx_Y6X.js';
2
+ import { IncomingMessage } from 'node:http';
3
+ import { a as AudioBridge, h as VideoFrameLane, j as VideoOutLane } from './video-out-IGQ4YQ-c.js';
4
+
5
+ interface ProxyIdentity {
6
+ app: string;
7
+ org: string;
8
+ fn: string;
9
+
10
+ base_url: string;
11
+ proxy_version: string;
12
+ }
13
+
14
+ type TurnCatalogIdentity = {
15
+ kind: 'catalog';
16
+ model_id: string;
17
+ variant: string;
18
+ } | {
19
+ kind: 'not-a-catalog-model';
20
+ model: string | null;
21
+ } | {
22
+ kind: 'unresolved';
23
+ reason: string;
24
+ };
25
+
26
+ interface DialReport {
27
+
28
+ sessionId: string | null;
29
+
30
+ identity: TurnCatalogIdentity;
31
+ }
32
+
33
+ type DialObserver = (dial: DialReport) => void;
34
+
35
+ interface InferenceRecord {
36
+ readonly event: 'inference_request';
37
+ readonly ts: string;
38
+ readonly inference_id: string;
39
+ readonly method: string;
40
+ readonly path: string;
41
+ readonly status: number | null;
42
+ readonly delivered: boolean;
43
+ readonly stream_error: boolean;
44
+ readonly model: string | null;
45
+ readonly stream: boolean | null;
46
+ readonly org: string | null;
47
+ readonly duration_ms: number;
48
+ readonly ttft_ms: number | null;
49
+
50
+ readonly prompt_tokens: number | null;
51
+ readonly completion_tokens: number | null;
52
+ readonly output_units: number | null;
53
+
54
+ readonly session_id: string | null;
55
+
56
+ readonly queue_ms: number | null;
57
+ readonly prefill_ms: number | null;
58
+ readonly decode_ms: number | null;
59
+ readonly total_ms: number | null;
60
+
61
+ readonly catalog: TurnCatalogIdentity;
62
+ }
63
+
64
+ interface SharedEndpointRow {
65
+ model_id: string;
66
+ variant: string;
67
+
68
+ app_slug: string;
69
+
70
+ function: string;
71
+
72
+ gpu_spec?: string | null;
73
+
74
+ warm?: number | null;
75
+
76
+ compat_default?: boolean | null;
77
+ }
78
+
79
+ interface SharedCatalogBlock {
80
+ shared_org_id: string;
81
+ endpoints: SharedEndpointRow[];
82
+ }
83
+
84
+ interface TokenPricing {
85
+ input: number;
86
+ output: number;
87
+ }
88
+
89
+ type Side = 'input' | 'output';
90
+
91
+ interface ModelPriceRow {
92
+ model_id: string;
93
+
94
+ variant: string | null;
95
+ side: Side;
96
+
97
+ usd: number;
98
+
99
+ effective_at: number;
100
+
101
+ expires_at: number | null;
102
+ }
103
+
104
+ type OpenRouterProviderDoc = {
105
+ data: OpenRouterProviderModel[];
106
+ };
107
+ interface OpenRouterProviderModel {
108
+ schema_version: '2.4';
109
+
110
+ id: string;
111
+ name: string;
112
+ created: number;
113
+
114
+ quantization: string | null;
115
+ description: string;
116
+ hugging_face_id: string;
117
+ input_modalities: Array<Record<string, unknown>>;
118
+ output_modalities: Array<Record<string, unknown>>;
119
+ }
120
+
121
+ interface DeployedApp {
122
+ app_slug: string;
123
+ function_name?: string | null;
124
+ deployment_status?: string | null;
125
+ [k: string]: unknown;
126
+ }
127
+
128
+ declare class UnknownModelError extends Error {
129
+ }
130
+
131
+ declare class SessionGoneError extends Error {
132
+ }
133
+
134
+ interface RouterModelEntry {
135
+ id: string;
136
+ object: 'model';
137
+ created: number;
138
+ owned_by: string;
139
+
140
+ name?: string;
141
+
142
+ description?: string;
143
+
144
+ task?: string;
145
+
146
+ engine?: string;
147
+
148
+ gpu_spec?: string;
149
+
150
+ context_length?: number;
151
+
152
+ pricing?: TokenPricing;
153
+
154
+ warm?: number;
155
+ }
156
+ interface RouterModelList {
157
+ object: 'list';
158
+ data: RouterModelEntry[];
159
+ }
160
+
161
+ interface RouterImageModelEntry extends RouterModelEntry {
162
+ image_modes: ImageCapabilityMode[];
163
+ }
164
+ interface RouterImageModelList {
165
+ object: 'list';
166
+ data: RouterImageModelEntry[];
167
+ }
168
+
169
+ interface RouteTarget {
170
+ appSlug: string;
171
+
172
+ fnName?: string;
173
+
174
+ sharedApp?: boolean;
175
+
176
+ modelId?: string;
177
+
178
+ variant?: string;
179
+ }
180
+ interface ModelRouterOptions<S> {
181
+
182
+ defaultApp: string | null;
183
+
184
+ fnName: string;
185
+
186
+ openSession: (target: RouteTarget) => S | Promise<S>;
187
+
188
+ closeSession: (entry: S) => Promise<void>;
189
+
190
+ listApps: (() => Promise<DeployedApp[]>) | null;
191
+
192
+ listCatalog: (() => Promise<CatalogRow[]>) | null;
193
+
194
+ listPrices: (() => Promise<ModelPriceRow[]>) | null;
195
+
196
+ warn?: (line: string) => void;
197
+
198
+ appsTtlMs?: number;
199
+
200
+ sessionKey?: (entry: S) => string;
201
+
202
+ shared?: (() => Promise<SharedCatalogBlock | null>) | null;
203
+ }
204
+
205
+ type ImageCapabilityMode = 'generation' | 'edit';
206
+
207
+ declare class ModelRouter<S> {
208
+ private readonly opts;
209
+ private readonly pool;
210
+ private appsCache;
211
+ private rowsCache;
212
+ constructor(opts: ModelRouterOptions<S>);
213
+
214
+ seed(appSlug: string, entry: S): void;
215
+ private deployedApps;
216
+
217
+ private sharedBlock;
218
+ private sharedCache;
219
+
220
+ private catalogRows;
221
+ private pricesCache;
222
+
223
+ private priceRows;
224
+
225
+ private pricesForListing;
226
+
227
+ private warn;
228
+
229
+ private servable;
230
+ private availableIds;
231
+
232
+ private noDefaultApp;
233
+
234
+ private resolveTarget;
235
+
236
+ catalogIdentityFor(model: string | undefined): Promise<{
237
+ model_id: string;
238
+ variant: string;
239
+ } | null>;
240
+
241
+ servingAppSlugFor(model: string | undefined): Promise<string>;
242
+
243
+ resolveApp(model: string | undefined): Promise<string>;
244
+
245
+ sessionFor(model: string | undefined): Promise<{
246
+ app: string;
247
+ entry: S;
248
+ identity: TurnCatalogIdentity;
249
+ }>;
250
+ private keyOf;
251
+
252
+ handleFor(model: string | undefined): Promise<{
253
+ app: string;
254
+ handle: string;
255
+ }>;
256
+
257
+ sessionForHandle(handle: string): Promise<{
258
+ app: string;
259
+ entry: S;
260
+ }>;
261
+
262
+ evict(app: string, entry: S): Promise<void>;
263
+
264
+ modelList(): Promise<RouterModelList>;
265
+
266
+ openRouterModels(): Promise<OpenRouterProviderDoc>;
267
+
268
+ supportsImages(model: string | undefined, mode: ImageCapabilityMode): Promise<boolean>;
269
+
270
+ supportsAudio(model: string | undefined): Promise<boolean>;
271
+
272
+ imageModelList(): Promise<RouterImageModelList>;
273
+
274
+ closeAll(): Promise<void>;
275
+ }
276
+
277
+ interface InferenceUsageRecord {
278
+
279
+ inference_id: string;
280
+
281
+ model_id: string;
282
+
283
+ identity_kind: string;
284
+
285
+ variant: string | null;
286
+ task: string;
287
+ http_status: number;
288
+ started_at: string;
289
+ completed_at: string;
290
+
291
+ prompt_tokens: number | null;
292
+ completion_tokens: number | null;
293
+ output_units: number | null;
294
+
295
+ cost_nano_usd: number | null;
296
+ price_version: string | null;
297
+ priced_at: string | null;
298
+ }
299
+
300
+ interface UsageRowRejection {
301
+
302
+ where: string;
303
+
304
+ reason: string;
305
+ }
306
+
307
+ type UsageRowReporter = (rejection: UsageRowRejection) => void | Promise<void>;
308
+
309
+ interface UsageLane {
310
+
311
+ authorize(req: IncomingMessage): string;
312
+
313
+ lookup(credential: string, inferenceIds: readonly string[]): Promise<InferenceUsageRecord[]>;
314
+ }
315
+
316
+ interface LedgerWrite {
317
+
318
+ inference_id: string;
319
+
320
+ model_id: string;
321
+
322
+ identity_kind: 'catalog_model' | 'caller_org_app';
323
+ variant: string | null;
324
+ task: string;
325
+ http_status: number;
326
+ started_at: string;
327
+ completed_at: string;
328
+
329
+ billable_outcome: boolean;
330
+
331
+ session_id: string | null;
332
+
333
+ prompt_tokens: number | null;
334
+ completion_tokens: number | null;
335
+ output_units: number | null;
336
+
337
+ queue_ms: number | null;
338
+ prefill_ms: number | null;
339
+ decode_ms: number | null;
340
+ total_ms: number | null;
341
+ }
342
+
343
+ interface LedgerRecorded {
344
+ inference_id: string;
345
+
346
+ cost_nano_usd: number | null;
347
+
348
+ price_version: string | null;
349
+
350
+ unpriced_reason: string | null;
351
+ }
352
+
353
+ declare const LEDGER_FAILURE_REASONS: readonly ["duplicate", "duplicate_foreign", "auth", "surface", "unknown", "dwell_expired", "dropped_on_exit"];
354
+ type LedgerFailureReason = (typeof LEDGER_FAILURE_REASONS)[number];
355
+
356
+ interface LedgerFailure {
357
+ readonly ledgerFailureReason: LedgerFailureReason;
358
+ }
359
+
360
+ declare const LEDGER_SKIP_REASONS: readonly ["no_response_head", "no_org", "model_unresolved", "no_model_named", "queue_full"];
361
+ type LedgerSkipReason = (typeof LEDGER_SKIP_REASONS)[number];
362
+
363
+ type LedgerOutcome =
364
+
365
+ {
366
+ outcome: 'written';
367
+ reason: 'priced' | 'unpriced';
368
+ }
369
+
370
+ | {
371
+ outcome: 'already_written';
372
+ reason: 'priced' | 'unpriced';
373
+ }
374
+
375
+ | {
376
+ outcome: 'skipped';
377
+ reason: LedgerSkipReason;
378
+ }
379
+
380
+ | {
381
+ outcome: 'failed';
382
+ reason: LedgerFailureReason;
383
+ };
384
+
385
+ interface LedgerLane {
386
+
387
+ write(req: IncomingMessage, entry: LedgerWrite): Promise<LedgerRecorded>;
388
+
389
+ observe(outcome: LedgerOutcome): void;
390
+
391
+ report?(line: string): void;
392
+ }
393
+
394
+ interface ResponsesCreateParams {
395
+ model?: string;
396
+ input: unknown;
397
+ stream?: boolean;
398
+ tools?: unknown;
399
+ tool_choice?: unknown;
400
+ temperature?: number;
401
+ max_output_tokens?: number;
402
+
403
+ instructions?: string;
404
+ top_p?: number;
405
+ stop?: string[];
406
+
407
+ reasoning_effort?: string;
408
+ chat_template_kwargs?: Record<string, unknown>;
409
+
410
+ response_format?: unknown;
411
+ }
412
+
413
+ interface SessionEndInfo {
414
+
415
+ timeLeftMs: number | null;
416
+
417
+ reason: string;
418
+ }
419
+
420
+ interface ProxyClients {
421
+
422
+ readonly tenant?: string;
423
+
424
+ createResponse(params: ResponsesCreateParams, onDial?: DialObserver): Promise<AsyncIterable<unknown>> | AsyncIterable<unknown>;
425
+
426
+ listModels(): Promise<unknown>;
427
+
428
+ openRouterModels?(): Promise<unknown>;
429
+
430
+ supportsImages?(model: string | undefined, mode: 'generation' | 'edit'): Promise<boolean>;
431
+
432
+ supportsAudio?(model: string | undefined): Promise<boolean>;
433
+
434
+ listImageModels?(): Promise<unknown>;
435
+
436
+ catalogIdentity(model: string | undefined): Promise<{
437
+ model_id: string;
438
+ variant: string;
439
+ } | null>;
440
+
441
+ servingAppSlug?(model: string | undefined): Promise<string | null>;
442
+
443
+ openAudio?(model: string | undefined): Promise<ProxyAudioLane>;
444
+
445
+ openVideo?(model: string | undefined): Promise<ProxyVideoLane>;
446
+
447
+ openVideoOut?(model: string | undefined): Promise<ProxyVideoOutLane>;
448
+
449
+ sessionHandle(model: string | undefined): Promise<string>;
450
+
451
+ createResponseOn(handle: string, params: ResponsesCreateParams): Promise<AsyncIterable<unknown>> | AsyncIterable<unknown>;
452
+
453
+ onSessionEnd(handle: string, cb: (end: SessionEndInfo) => void): Promise<() => void>;
454
+ }
455
+
456
+ type ProxyAudioLane = Pick<AudioBridge, 'appendInputAudio' | 'onOutputAudio'>;
457
+
458
+ type ProxyVideoLane = Pick<VideoFrameLane, 'sendInputFrame'>;
459
+
460
+ type ProxyVideoOutLane = Pick<VideoOutLane, 'codec' | 'onOutputFrame' | 'onLaneError'>;
461
+
462
+ type ProxyClientsFor = (req: IncomingMessage) => ProxyClients | Promise<ProxyClients>;
463
+ interface ProxyHandlerOptions {
464
+
465
+ clients: ProxyClients | ProxyClientsFor;
466
+
467
+ apiKey?: string;
468
+
469
+ identity?: ProxyIdentity;
470
+
471
+ statusOf?: (err: unknown) => {
472
+ status: number;
473
+ openaiType: string;
474
+ anthropicType: string;
475
+ } | null;
476
+
477
+ requestLog?: (line: string) => void;
478
+
479
+ usage?: UsageLane;
480
+
481
+ ledger?: LedgerLane;
482
+
483
+ observe?: (record: InferenceRecord) => void;
484
+ }
485
+
486
+ export { type DialObserver as D, type InferenceRecord as I, type LedgerFailure as L, ModelRouter as M, type ProxyClients as P, SessionGoneError as S, UnknownModelError as U, type DialReport as a, type InferenceUsageRecord as b, type LedgerOutcome as c, type LedgerRecorded as d, type LedgerWrite as e, type ProxyHandlerOptions as f, type ProxyIdentity as g, type ProxyVideoOutLane as h, type UsageRowReporter as i };