Skip to content

adding more support for custom openai BASE_URL deployments#38

Open
Barneyjm wants to merge 3 commits intolangchain-ai:mainfrom
Barneyjm:main
Open

adding more support for custom openai BASE_URL deployments#38
Barneyjm wants to merge 3 commits intolangchain-ai:mainfrom
Barneyjm:main

Conversation

@Barneyjm
Copy link

Description

adding support for custom BASE_URL deployments of OpenAI. aligns with existing Langchain packages

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

Checklist

  • I have read the Contributing Guide
  • I have tested my changes locally
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Add screenshots to demonstrate UI changes.
See highlighted box for custom base url being shown:

Screenshot 2026-01-20 at 11 51 25 AM

Additional Notes

Any additional information reviewers should know.

Enables configuration of custom base URLs for OpenAI-compatible APIs
through environment variables. This supports:
- Azure OpenAI endpoints
- Custom proxy servers
- Local LLM deployments (Ollama, LocalAI, vLLM, etc.)
- Any OpenAI-compatible API

Environment variables:
- OPENAI_API_BASE: Custom endpoint URL (e.g., http://localhost:11434/v1 for Ollama)
- OPENAI_API_TYPE: API type (set to 'azure' for Azure OpenAI)
- OPENAI_API_VERSION: API version (required for Azure, e.g., '2024-02-01')
- OPENAI_API_KEY: API key (optional for local endpoints like Ollama)

When OPENAI_API_BASE is set, the runtime uses the custom endpoint
instead of the default OpenAI API. Azure-specific headers are
automatically applied when OPENAI_API_TYPE=azure. Local endpoints
that don't require authentication (like Ollama) work without an API key.

Examples:
- Ollama: OPENAI_API_BASE=http://localhost:11434/v1 (no key needed)
- Azure: OPENAI_API_BASE=https://your-resource.openai.azure.com
         OPENAI_API_TYPE=azure
         OPENAI_API_VERSION=2024-02-01
         OPENAI_API_KEY=your-key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant