AnthonyTlei
← All work

Project

/

Developer tooling

/

2026

langchain-codex-oauth

A LangChain and LangGraph adapter that bridged local ChatGPT OAuth, streaming responses, and tool calls into a familiar chat-model interface.

What exists
Status
Retired
Source
Public
Evidence
Public source · Package · Documentation · Reproducible harness
Stack
Python · LangChain · LangGraph · OAuth 2.0 · Server-Sent Events
Period
2026

01
Overview

What this is

langchain-codex-oauth was a small compatibility layer for a narrow gap: use Codex-capable ChatGPT models through a local OAuth session while keeping LangChain and LangGraph code shaped around their standard chat-model interface.

The adapter handled more than a single request. It translated messages and tool schemas, supported synchronous and asynchronous invocation, streamed server-sent events into LangChain chunks, reconstructed tool calls, exposed usage metadata, and included a local PKCE authentication flow. It was packaged as version 1.0.0 and later deliberately marked legacy when the ecosystem gained better-supported paths.

Built for local, single-user experiments and agent workflows that already used LangChain or LangGraph but needed to call the Codex response surface without reworking the surrounding application.

The problem

The model endpoint and the framework disagreed on authentication, request shape, streaming events, and tool-call semantics. A thin wrapper that only returned text would work for a demo but fail in the agent workflows the integration existed to support.

What I built and owned

I designed and implemented the adapter, OAuth flow, response and streaming translation, tool-call handling, structured-output compatibility, test suite, examples, and package documentation. I also defined the local-only boundaries and later marked the project legacy instead of presenting an unstable consumer integration as a production dependency.

02
Detail

How it works

A protocol bridge, not just an HTTP wrapper

LangChain expects a chat model to accept its messages and tools, emit its message and tool-call chunks, participate in callbacks, and behave consistently across invoke, async invoke, stream, and async stream. The consumer response endpoint used a different authentication and event model. The package exists in the translation layer between those expectations.

The difficult edge was streamed tool calling. A tool call arrives across several server-sent events, so the adapter has to preserve call identity and partial arguments, emit useful chunks as data arrives, and still reconstruct the final LangChain tool call correctly.

Diagram · select to open the full view

Text description of this diagram

A LangChain or LangGraph application calls ChatCodexOAuth using the familiar chat-model contract: messages, tool schemas, synchronous or asynchronous invocation, and callbacks. The adapter translates those inputs to the consumer response request shape and authenticates through a locally stored PKCE OAuth session.

The response surface returns server-sent events, tool calls, and usage metadata. The adapter reconstructs those events into LangChain message chunks and complete tool calls before returning them to the caller.

What had to line up

  • 01

    Local OAuth lifecycle

    PKCE authorization, callback handling, manual fallback, credential storage, and refresh behavior had to work without an API key.

  • 02

    Messages and tools

    Framework messages and tool schemas needed a stable translation into the endpoint request format.

  • 03

    Streaming state

    Server-sent events had to become LangChain chunks while preserving partial tool calls and final response metadata.

  • 04

    Framework compatibility

    The adapter supported sync, async, structured output, stop sequences, callbacks, and LangGraph usage rather than only a bespoke demo path.

Local-use boundary

This package was for local, single-user experimentation. It was not designed for account sharing, production hosting, or multi-user services, and the consumer endpoint could change independently of the package. The repository remains public evidence, but the integration is now legacy.

03
Result

What came of it

shippedVersion 1.0.0 was published to PyPI with public source, setup guidance, and runnable LangChain and LangGraph examples.View the PyPI package
reproducibleThe adapter covered synchronous and asynchronous invocation, streamed message chunks, tool-call reconstruction, structured output compatibility, stop handling, and usage metadata.Repository state reviewed 2026-08-13.
learningThe project was deliberately marked legacy when better-supported ecosystem paths emerged, preserving the evidence without recommending an unstable consumer integration as the default.

Something similar in mind?

If this is close to a problem you have, the fastest thing is usually a short conversation about what you are actually trying to change.

Discuss a project