microsoft/amplifier-module-provider-openai-chatgpt
Python
Captured source
source ↗microsoft/amplifier-module-provider-openai-chatgpt
Description: ChatGPT OpenAI provider module for the Amplifier project
Language: Python
License: MIT
Stars: 0
Forks: 1
Open issues: 1
Created: 2026-04-29T12:42:22Z
Pushed: 2026-05-31T21:11:19Z
Default branch: main
Fork: no
Archived: no
README:
Amplifier ChatGPT Subscription Provider Module
ChatGPT subscription auth provider for Amplifier -- uses raw HTTP + manual SSE against the ChatGPT backend API (chatgpt.com/backend-api/codex/responses).
Prerequisites
- Python 3.11+
- UV package manager
- A ChatGPT Plus/Pro/Team subscription with device code auth enabled in ChatGPT security settings
Purpose
Connects Amplifier to the ChatGPT backend API using OAuth device code authentication. This is a separate module from provider-openai because the ChatGPT backend is a distinct, undocumented API surface that rejects many standard OpenAI API parameters and requires raw HTTP + manual SSE parsing (the OpenAI Python SDK's streaming accumulator does not work against it).
Contract
| Field | Value | |-------|-------| | Module Type | Provider | | Mount Point | providers | | Entry Point | amplifier_module_provider_openai_chatgpt:mount |
Configuration
[providers.provider-openai-chatgpt] default_model = "gpt-5.5"
All Config Options
| Key | Type | Default | Description | |-----|------|---------|-------------| | default_model | str | "gpt-5.5" | Model to use for inference | | raw | bool | false | Include full request/response payloads in llm:request/llm:response hook events (for debugging) | | login_on_mount | bool | true | Trigger interactive device code login if tokens are absent or expired. Set false for non-interactive environments. | | token_file_path | str | ~/.amplifier/openai-chatgpt-oauth.json | Path to the OAuth token JSON file | | timeout | float | 300.0 | HTTP timeout in seconds for streaming requests | | models_cache_ttl | float | 3600 | How long (seconds) to cache the live model catalog before re-fetching |
Authentication
On first use, the provider initiates an OAuth device code flow:
1. Displays a verification URL (https://auth.openai.com/codex/device) and a code in the terminal 2. You open the URL in a browser and enter the code 3. Tokens are cached to ~/.amplifier/openai-chatgpt-oauth.json for subsequent use
Tokens auto-refresh silently when they expire. If the refresh token itself expires, the device code flow runs again.
Requires "Sign in with device code" to be enabled in your ChatGPT account security settings (Settings > Security).
Works in SSH/headless sessions -- the device code flow only requires a browser on any device, not the machine running Amplifier.
Features
- OAuth device code authentication with PKCE (no API key needed)
- Raw httpx + manual SSE streaming (not the OpenAI SDK)
- Automatic token refresh with 4-step fallback chain
- Dynamic model catalog from live API (cached, with fallback)
- Subscription plan type detection from OAuth JWT
- Tool calling support
- Reasoning effort support (
low/medium/high/xhighon all gpt-5.x models) -fastmodel suffix support (e.g.gpt-5.5-fast->gpt-5.5withservice_tier: "priority")- Production routing matrix for all 13 Amplifier agent roles
llm:request/llm:responsehook events with optional raw payload inclusion
Local Development
# Clone git clone https://github.com/microsoft/amplifier-module-provider-openai-chatgpt.git cd amplifier-module-provider-openai-chatgpt # Install deps (including dev group: amplifier-core, pytest, ruff) uv sync # Run tests uv run pytest tests/ -v # Run a specific test file uv run pytest tests/test_sse.py -v # Lint and format check uv run ruff check . uv run ruff format --check .
Testing with Amplifier
Register the module, install it, and add it through the standard provider management flow:
# 1. Register the module source amplifier module add provider-openai-chatgpt \ --source /path/to/amplifier-module-provider-openai-chatgpt # 2. Install the provider amplifier provider install openai-chatgpt --force # 3. Add and configure via the interactive wizard amplifier provider add openai-chatgpt # 4. Or use the management dashboard amplifier provider manage
You can also wire it into a bundle directly with an inline source: field:
--- bundle: name: test-openai-chatgpt version: 0.1.0 includes: - bundle: git+https://github.com/microsoft/amplifier-foundation@main providers: - module: provider-openai-chatgpt source: /path/to/amplifier-module-provider-openai-chatgpt config: default_model: gpt-5.5 --- # Test: provider-openai-chatgpt
amplifier run --bundle ./test-chatgpt.md "Hello, can you hear me?"
Routing Matrix
This module ships with a production routing matrix at routing/openai-chatgpt.yaml that maps all 13 Amplifier agent roles to the correct models. This is required for agent delegation to work -- without it, agents like web-research, explorer, and zen-architect will fail to resolve a provider.
To use it:
# Copy to your user routing directory cp routing/openai-chatgpt.yaml ~/.amplifier/routing/ # Activate it amplifier routing use openai-chatgpt # Verify amplifier routing show
The matrix uses two-tier fallback chains (gpt-5.5 -> gpt-5.4) so it works across subscription tiers. Role highlights:
| Role | Primary Model | Config | |------|--------------|--------| | general, creative, writing, vision | gpt-5.5 | -- | | fast | gpt-?.?-mini* (glob) | -- | | coding | gpt-?.?-codex* (glob) | -- | | reasoning, research, security-audit, critical-ops | gpt-5.5 | reasoning_effort: high | | critique | gpt-5.5 | reasoning_effort: xhigh |
See the matrix YAML header for full documentation on glob strategy, fallback philosophy, and differences from the standard openai routing matrix.
Supported Models
The model catalog is fetched dynamically from the ChatGPT backend API at GET /backend-api/codex/models. Available models depend on your subscription tier. The catalog is cached for 1 hour (configurable via models_cache_ttl).
Example catalog for a Plus subscription (as of April 2026):
| Model | Context Window | Priority | Speed Tiers | Reasoning | |-------|---------------|----------|-------------|-----------| | gpt-5.5 | 272K | 0…
Excerpt shown — open the source for the full document.
Notability
notability 3.0/10Routine component repo from Microsoft