@probelabs/probe 0.6.0-rc316 → 0.6.0-rc318

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.
@@ -84,9 +84,32 @@ export function resolveApiKey(providerName) {
84
84
  }
85
85
  }
86
86
 
87
+ /**
88
+ * Resolve base URL for a provider from environment variables.
89
+ * Mirrors the env-var resolution in ProbeAgent and FallbackManager so that
90
+ * lightweight LLM calls (dedup, etc.) route through the same API gateway.
91
+ * @param {string} providerName
92
+ * @returns {string|undefined}
93
+ */
94
+ export function resolveBaseUrl(providerName) {
95
+ const llmBaseUrl = process.env.LLM_BASE_URL;
96
+ switch (providerName) {
97
+ case 'anthropic':
98
+ return process.env.ANTHROPIC_API_URL || process.env.ANTHROPIC_BASE_URL || llmBaseUrl;
99
+ case 'openai':
100
+ return process.env.OPENAI_API_URL || llmBaseUrl;
101
+ case 'google':
102
+ return process.env.GOOGLE_API_URL || llmBaseUrl;
103
+ case 'bedrock':
104
+ return process.env.AWS_BEDROCK_BASE_URL || llmBaseUrl;
105
+ default:
106
+ return llmBaseUrl;
107
+ }
108
+ }
109
+
87
110
  /**
88
111
  * Create a language model instance from provider name + model name.
89
- * Resolves API keys from environment automatically.
112
+ * Resolves API keys and base URLs from environment automatically.
90
113
  * Returns null on failure (graceful degradation for optional features).
91
114
  * @param {string} providerName - 'anthropic' | 'openai' | 'google' | 'bedrock'
92
115
  * @param {string} modelName - Model identifier (e.g., 'gemini-2.0-flash')
@@ -98,7 +121,8 @@ export async function createLanguageModel(providerName, modelName) {
98
121
  if (!resolvedModel) return null;
99
122
  try {
100
123
  const apiKey = resolveApiKey(providerName);
101
- const provider = createProviderInstance({ provider: providerName, ...(apiKey ? { apiKey } : {}) });
124
+ const baseURL = resolveBaseUrl(providerName);
125
+ const provider = createProviderInstance({ provider: providerName, ...(apiKey ? { apiKey } : {}), ...(baseURL ? { baseURL } : {}) });
102
126
  return provider(resolvedModel);
103
127
  } catch {
104
128
  return null;