instructor icon indicating copy to clipboard operation
instructor copied to clipboard

OpenAI provider in from_provider ignores base_url kwarg (can’t point client to custom endpoint)

Open albertkklam opened this issue 1 month ago • 0 comments

Is your feature request related to a problem? Please describe. When using instructor.from_provider("openai/", base_url="..."), the base_url kwarg is ignored. The OpenAI client is instantiated as openai.OpenAI(api_key=...) (or AsyncOpenAI) without forwarding base_url, so requests always go to the default api.openai.com. This prevents routing traffic through OpenAI-compatible gateways/proxies (e.g., self-hosted gateways, Helicone-style observability layers, local mock servers), and makes it inconsistent with other providers (e.g., databricks, perplexity, deepseek, openrouter) that already honor base_url.

Describe the solution you'd like Update the OpenAI branch of from_provider to forward base_url (and, ideally, other client kwargs for parity) into openai.OpenAI(...) / openai.AsyncOpenAI(...).

Describe alternatives you've considered Manually constructing an openai.OpenAI(base_url=..., api_key=...) client and calling instructor.from_openai(client, ...)—functional but bypasses the nice ergonomics of from_provider.

Additional context Several other provider branches already accept and pass base_url (e.g., databricks, perplexity, deepseek, openrouter), so this change brings openai to feature parity.

albertkklam avatar Nov 12 '25 15:11 albertkklam