Skip to content

fix: forward base_url and api_key to instructor client#5374

Open
mango766 wants to merge 1 commit intocrewAIInc:mainfrom
mango766:fix/internal-instructor-base-url
Open

fix: forward base_url and api_key to instructor client#5374
mango766 wants to merge 1 commit intocrewAIInc:mainfrom
mango766:fix/internal-instructor-base-url

Conversation

@mango766
Copy link
Copy Markdown

@mango766 mango766 commented Apr 9, 2026

Summary

Fixes #5204

When using an OpenAI-compatible provider with a custom base_url (e.g., vLLM, Ollama, or any self-hosted endpoint), InternalInstructor._create_instructor_client() silently discards the base_url and sends requests to api.openai.com instead.

This PR forwards the base_url and api_key from the LLM object to instructor.from_provider() so structured output parsing requests go to the correct endpoint.

Changes

  • Modified _create_instructor_client() in internal_instructor.py to extract base_url and api_key from the LLM object and pass them as kwargs to instructor.from_provider()

Test plan

  • Verify that using a custom base_url with an OpenAI-compatible LLM correctly routes requests to the specified endpoint
  • Verify that the default behavior (no base_url) still works correctly
  • Verify that LiteLLM path is unaffected (it bypasses _create_instructor_client())

…tructor

When using an OpenAI-compatible provider with a custom base_url (e.g.,
vLLM, Ollama, or any self-hosted endpoint), InternalInstructor silently
discards the base_url and sends requests to api.openai.com instead.

This forwards the base_url and api_key from the LLM object to
instructor.from_provider() so that structured output requests go to the
correct endpoint.

Fixes crewAIInc#5204

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

[BUG] InternalInstructor discards base_url when creating instructor client — breaks OpenAI-compatible endpoints

1 participant