Skip to content

feat(core): add gateway OAuth bearer authentication#38805

Open
John Kennedy (jkennedyvz) wants to merge 4 commits into
cc/gateway-base-urlfrom
john/dcode-add-oauth-bearer-auth-mode-for-langsmith-gateway
Open

feat(core): add gateway OAuth bearer authentication#38805
John Kennedy (jkennedyvz) wants to merge 4 commits into
cc/gateway-base-urlfrom
john/dcode-add-oauth-bearer-auth-mode-for-langsmith-gateway

Conversation

@jkennedyvz

Copy link
Copy Markdown
Contributor

Gateway-backed chat clients can now use a LangSmith OAuth access token as an Authorization: Bearer credential without treating it as a provider API key. The shared transport adapter removes provider auth headers before sending the request, and the OpenAI, Anthropic, and Fireworks clients use it when an OAuth token is configured.

Release note

Add OAuth bearer authentication for LangSmith Gateway chat requests in the OpenAI, Anthropic, and Fireworks integrations.

This contribution was prepared with AI assistance.

@github-actions github-actions Bot added anthropic `langchain-anthropic` package issues & PRs core `langchain-core` package issues & PRs feature For PRs that implement a new feature; NOT A FEATURE REQUEST fireworks `langchain-fireworks` package issues & PRs integration PR made that is related to a provider partner package integration internal openai `langchain-openai` package issues & PRs size: M 200-499 LOC labels Jul 11, 2026
@jkennedyvz John Kennedy (jkennedyvz) force-pushed the john/dcode-add-oauth-bearer-auth-mode-for-langsmith-gateway branch 2 times, most recently from af7aa8f to 9f5d498 Compare July 11, 2026 20:28
@jkennedyvz John Kennedy (jkennedyvz) changed the base branch from master to cc/gateway-base-url July 11, 2026 20:28
@jkennedyvz John Kennedy (jkennedyvz) marked this pull request as ready for review July 11, 2026 20:29
@jkennedyvz John Kennedy (jkennedyvz) force-pushed the john/dcode-add-oauth-bearer-auth-mode-for-langsmith-gateway branch from 9f5d498 to 82001a8 Compare July 11, 2026 20:30
@github-actions github-actions Bot added size: S 50-199 LOC and removed size: M 200-499 LOC labels Jul 11, 2026

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open SWE Review found 3 potential issues.

Open in WebView Open SWE trace

Comment on lines +1004 to +1007
langsmith_gateway_oauth_token: SecretStr | None = Field(
default_factory=secret_from_env("LANGSMITH_GATEWAY_OAUTH_TOKEN", default=None),
exclude=True,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Scope OAuth token to gateway requests

The environment token is loaded unconditionally, even when LANGSMITH_GATEWAY is unset/false and this client resolves to https://api.anthropic.com. In that normal direct-provider configuration, _gateway_oauth_auth replaces the provider credential with the LangSmith bearer token, disclosing the OAuth credential to Anthropic and causing authentication to fail. The same unconditional default exists in ChatFireworks and BaseChatOpenAI; Fireworks sends it to its direct endpoint, while OpenAI sends it whenever a direct base_url is supplied (and otherwise now crashes constructing an HTTPX client with base_url=None). Please only activate this credential when the resolved endpoint is actually LangSmith Gateway.

(Refers to lines 1004-1007)


Your feedback helps Open SWE learn. React with 👍 or 👎 to tell us if this review comment was useful.

Comment thread libs/partners/fireworks/langchain_fireworks/chat_models.py Outdated
Comment thread libs/partners/openai/langchain_openai/chat_models/_client_utils.py Outdated
@github-actions github-actions Bot added size: M 200-499 LOC and removed size: S 50-199 LOC labels Jul 11, 2026

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/partners/openai/langchain_openai/chat_models/base.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

anthropic `langchain-anthropic` package issues & PRs core `langchain-core` package issues & PRs feature For PRs that implement a new feature; NOT A FEATURE REQUEST fireworks `langchain-fireworks` package issues & PRs integration PR made that is related to a provider partner package integration internal openai `langchain-openai` package issues & PRs size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant