Skip to content

Conversation

@mr-brobot
Copy link

@mr-brobot mr-brobot commented Dec 29, 2025

What changes are proposed in this pull request?

WHAT:

  • Add http_async_client parameter to get_langchain_chat_open_ai_client() so async operations use authenticated Databricks credentials
  • Add new get_async_open_ai_client() method that returns a properly configured AsyncOpenAI client
  • Extract BearerAuth class to module-level _get_bearer_auth() function for reuse across sync and async clients
  • Refactor reserved parameter validation into shared _check_reserved_openai_params() and _build_openai_client_params() helper methods

WHY:
The get_langchain_chat_open_ai_client() method was only setting http_client but not http_async_client. This caused async operations like ainvoke() and astream() to use LangChain's default unauthenticated HTTP client, resulting in 401 errors against Databricks endpoints.

Additionally, users wanting to use OpenAI's native AsyncOpenAI client had no equivalent to get_open_ai_client() for async workflows.

The httpx Auth class with the generator-based auth_flow() pattern works identically for both sync and async operations, so the existing BearerAuth implementation was extracted and reused for both client types.

Fixes #1173
Fixes #847

How is this tested?

Unit tests added/updated in tests/test_open_ai_mixin.py:

  • test_langchain_open_ai_client - extended to verify both http_client.auth and http_async_client.auth are configured
  • Tests for async OpenAI client matching existing tests for sync OpenAI client

mr-brobot and others added 2 commits December 29, 2025 16:14
- Add http_async_client to get_langchain_chat_open_ai_client() to fix
  401 errors on async operations (ainvoke, astream) - fixes databricks#1173
- Add get_async_open_ai_client() method for native AsyncOpenAI - fixes databricks#847
- Extract BearerAuth to module-level _get_bearer_auth() for reuse
- Refactor reserved param validation into shared helper methods

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Josh Wiley <josh@cloudbend.dev>
Signed-off-by: Josh Wiley <josh@cloudbend.dev>
@github-actions
Copy link

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-py

Inputs:

  • PR number: 1175
  • Commit SHA: 5594bf0186562c43f999c991f4a293a135c4d52a

Checks will be approved automatically on success.

@mr-brobot mr-brobot changed the title fix(serving): add async HTTP client support for OpenAI integrations fix(serving): add async client support for OpenAI integrations Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant