Skip to content

Commit f55e167

Browse files
committed
📦 NEW: LB-LLM-Key header support
1 parent c90312f commit f55e167

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

‎packages/core/src/common/request.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface RequestConfig {
1414
apiKey?: string;
1515
baseUrl: string;
1616
timeout?: number;
17+
llmKey?: string;
1718
}
1819

1920
interface SendOptions extends RequestOptions {
@@ -90,6 +91,7 @@ export class Request {
9091
return {
9192
'Content-Type': 'application/json',
9293
Authorization: `Bearer ${this.config.apiKey}`,
94+
'LB-LLM-Key': this.config.llmKey ?? '',
9395
...headers,
9496
};
9597
}

‎packages/core/src/pipes/pipes.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface RunOptions {
2828
tools?: Tools[];
2929
name?: string; // Pipe name for SDK,
3030
apiKey?: string; // pipe level key for SDK
31+
llmKey?: string; // LLM API key
3132
}
3233

3334
export interface RunOptionsStream extends RunOptions {
@@ -92,6 +93,7 @@ export class Pipe {
9293
private hasTools: boolean;
9394
private prod: boolean;
9495
private baseUrl: string;
96+
private entityApiKey?: string;
9597

9698
constructor(options: PipeOptions) {
9799
this.prod = options.prod ?? isProd();
@@ -102,6 +104,7 @@ export class Pipe {
102104
baseUrl: this.baseUrl,
103105
});
104106
this.pipe = options;
107+
this.entityApiKey = options.apiKey;
105108

106109
delete this.pipe.prod;
107110
delete this.pipe.apiKey;
@@ -272,6 +275,15 @@ export class Pipe {
272275
this.request = new Request({
273276
apiKey: options.apiKey,
274277
baseUrl: this.baseUrl,
278+
...((options.llmKey && {llmKey: options.llmKey}) || {}),
279+
});
280+
}
281+
282+
if (options.llmKey && !options.apiKey) {
283+
this.request = new Request({
284+
apiKey: this.entityApiKey,
285+
baseUrl: this.baseUrl,
286+
llmKey: options.llmKey,
275287
});
276288
}
277289

0 commit comments

Comments
 (0)