@theokit/sdk 4.9.1 → 4.10.1

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.
package/dist/index.cjs CHANGED
@@ -15210,6 +15210,7 @@ var OpenAIClient = class {
15210
15210
  if (this.options.organization !== void 0) {
15211
15211
  headers["openai-organization"] = this.options.organization;
15212
15212
  }
15213
+ if (this.options.extraHeaders !== void 0) Object.assign(headers, this.options.extraHeaders);
15213
15214
  const providerId = this.options.providerName ?? this.name;
15214
15215
  let response;
15215
15216
  try {
@@ -16282,6 +16283,11 @@ function resolveApiKey2(envVars) {
16282
16283
  return void 0;
16283
16284
  }
16284
16285
  function selectTransport(profile, apiKey) {
16286
+ const applyTransform = () => {
16287
+ if (profile.transform === void 0) return {};
16288
+ const ctx = { apiKey };
16289
+ return { fetch: profile.transform.fetch?.(ctx), headers: profile.transform.headers?.(ctx) };
16290
+ };
16285
16291
  if (profile.apiMode === "chat_completions") {
16286
16292
  if (profile.name === "ollama") {
16287
16293
  const ollamaBase = process.env.OLLAMA_HOST ?? profile.baseUrl;
@@ -16298,6 +16304,10 @@ function selectTransport(profile, apiKey) {
16298
16304
  }
16299
16305
  const envOverride = resolveBaseUrlEnvOverride(profile.name);
16300
16306
  if (envOverride !== void 0) opts.baseUrl = envOverride;
16307
+ const t = applyTransform();
16308
+ if (t.fetch !== void 0) opts.fetch = t.fetch;
16309
+ const merged = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16310
+ if (merged !== void 0) opts.extraHeaders = merged;
16301
16311
  return new OpenAIClient(opts);
16302
16312
  }
16303
16313
  if (profile.apiMode === "anthropic_messages") {
@@ -16314,10 +16324,13 @@ function selectTransport(profile, apiKey) {
16314
16324
  return new BedrockAnthropicClient(realKey !== void 0 ? { apiKey: realKey } : {});
16315
16325
  }
16316
16326
  if (profile.apiMode === "responses_api") {
16327
+ const t = applyTransform();
16328
+ const mergedHeaders = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16317
16329
  return new ResponsesApiClient({
16318
16330
  apiKey,
16319
16331
  ...profile.baseUrl !== void 0 ? { baseUrl: profile.baseUrl } : {},
16320
- ...profile.extraHeaders !== void 0 ? { extraHeaders: profile.extraHeaders } : {},
16332
+ ...mergedHeaders !== void 0 ? { extraHeaders: mergedHeaders } : {},
16333
+ ...t.fetch !== void 0 ? { fetch: t.fetch } : {},
16321
16334
  providerName: profile.name
16322
16335
  });
16323
16336
  }