[Feature]: Allow for custom llm proxies #18

Open
opened 2026-02-16 09:17:48 -05:00 by yindo · 0 comments
Owner

Originally created by @0xthc on GitHub (Jan 24, 2026).

Problem Statement

I would like to be able to go through a proxy instead of direct providers APIs

Proposed Solution

export interface ModelConfig {
  id: string
  name: string
  provider: ProviderId
  model: string
  description?: string
  available: boolean
  base_url?: string  // Add this
  custom?: boolean    // Add this to identify custom models
}

function getModelInstance(
  modelId?: string,
  customConfig?: { base_url?: string }
): ChatAnthropic | ChatOpenAI | ChatGoogleGenerativeAI | string {
  const model = modelId || getDefaultModel()
  
  if (model.startsWith("claude")) {
    const apiKey = getApiKey("anthropic") || "dummy-not-used"
    
    const config: any = {
      model,
      anthropicApiKey: apiKey
    }
    
    // Add base URL if provided
    if (customConfig?.base_url) {
      config.clientOptions = {
        baseURL: customConfig.base_url
      }
    }
    
    return new ChatAnthropic(config)
  }
  // ... rest of the function
}

Use Case

I have proxies already setup for internal gateways

Originally created by @0xthc on GitHub (Jan 24, 2026). ## Problem Statement I would like to be able to go through a proxy instead of direct providers APIs ## Proposed Solution ```typescript export interface ModelConfig { id: string name: string provider: ProviderId model: string description?: string available: boolean base_url?: string // Add this custom?: boolean // Add this to identify custom models } function getModelInstance( modelId?: string, customConfig?: { base_url?: string } ): ChatAnthropic | ChatOpenAI | ChatGoogleGenerativeAI | string { const model = modelId || getDefaultModel() if (model.startsWith("claude")) { const apiKey = getApiKey("anthropic") || "dummy-not-used" const config: any = { model, anthropicApiKey: apiKey } // Add base URL if provided if (customConfig?.base_url) { config.clientOptions = { baseURL: customConfig.base_url } } return new ChatAnthropic(config) } // ... rest of the function } ``` ## Use Case I have proxies already setup for internal gateways
yindo added the enhancement label 2026-02-16 09:17:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/openwork#18