r-assistant-gateway
v0.3.0
Published
Unofficial local gateway from Posit Assistant in RStudio and Positron to ChatGPT/Codex OAuth
Maintainers
Readme
R Assistant Gateway
Love Codex models, hate API prices? ☀️ 🌍 🌙 Use your existing ChatGPT/Codex subscription sign-in with Posit Assistant in RStudio or Positron.
r-assistant-gateway is a small local compatibility bridge between Posit
Assistant's OpenAI Responses client and ChatGPT/Codex. It uses
@carl-stone/openai-oauth to sign
in with your ChatGPT account and translates Posit Assistant's requests into the
request contract accepted by ChatGPT/Codex.
It is intentionally only that bridge. It is not a general OpenAI proxy or an API-key replacement for other applications.
Unofficial community project. This project is not affiliated with, endorsed by, or supported by Posit or OpenAI.
Before you start
You need:
- Node.js 24 or newer;
- RStudio or Positron with Posit Assistant installed; and
- a ChatGPT/Codex Plus or Pro subscription.
Tested with Posit Assistant 1.3.0 and 1.3.1. Compatibility with older versions is unknown.
The gateway uses your ChatGPT/Codex sign-in. You do not need an OpenAI API key.
Quick start
With Node.js installed, run these commands in a Terminal window:
npm install --global r-assistant-gateway
r-assistant-gateway login
r-assistant-gatewayThe last command keeps the gateway running in the foreground. Leave that Terminal window open while you use Posit Assistant.
To run it in the background instead, use:
r-assistant-gateway --detachConnect Posit Assistant
Choose the OpenAI provider in either IDE:
- RStudio: in the Posit Assistant pane, select gear > Configure AI providers > OpenAI.
- Positron: open the Command Palette, run Authentication: Configure Language Model Providers, and select OpenAI. The separately named OpenAI Compatible provider defaults to Chat Completions; this gateway uses Responses.
Enter the same connection settings in either IDE:
| Setting | Value |
| --- | --- |
| Base URL | http://127.0.0.1:10532/v1 |
| API key | local-gateway |
local-gateway is only a non-secret placeholder required by the OpenAI setup
form. The gateway does not use it as an OpenAI API key; upstream requests use
your ChatGPT/Codex sign-in. A non-empty value also lets Posit Assistant discover
the models available through your account from the gateway. One running gateway
can serve both IDEs on the same computer. In Positron, open the chat with
View: Show Posit Assistant. See the official
Positron provider instructions
for the provider dialog.
A model is missing from the Positron selector
Posit Assistant 1.3.1 in Positron filters OpenAI model discovery to IDs beginning
with gpt-5, gpt-4, or o. This hides gpt-6-astra even when the gateway
correctly lists it. Add the model explicitly using Open AI Provider Settings
(JSON), which opens ~/.posit/ai/providers.json.
Merge this example into your existing providers.openai settings, preserving
any other providers or custom models:
{
"providers": {
"openai": {
"baseUrl": "http://127.0.0.1:10532/v1",
"models": {
"custom": [
{
"id": "gpt-6-astra",
"name": "GPT-6 Astra",
"protocol": "openai-responses",
"maxContextLength": 272000,
"supportsTools": true,
"supportsImages": true,
"supportsToolResultImages": true,
"supportsWebSearch": false,
"thinkingEffortLevels": ["low", "medium", "high", "xhigh", "max", "ultra"]
}
]
}
}
}
}Reopen the model selector; if needed, run Developer: Reload Window. This adds Astra alongside automatically discovered models. It does not grant access to models unavailable to your account. The example reflects the Astra metadata used in the September 2026 validation; check current model capabilities when adding other models. See Posit’s custom model settings reference.
Start, check, and stop the gateway
These commands are useful when the gateway runs in the background:
r-assistant-gateway status
r-assistant-gateway logs --follow
r-assistant-gateway doctor
r-assistant-gateway stopRun r-assistant-gateway again to start it in the foreground after stopping
it. The default port is 10532, which matches the Posit Assistant URL above.
You can choose another port with, for example, --port 10533; if you do, change
the provider's base URL to match.
What the gateway translates
Posit Assistant uses the OpenAI Responses wire format in both IDEs when the OpenAI provider is selected. For current Codex models it can send developer and user input, images and files, tool definitions, function calls, structured function outputs, encrypted reasoning, and explicit prompt-cache controls.
ChatGPT/Codex accepts most of that request directly. The gateway removes only known incompatible fields:
prompt_cache_options;prompt_cache_breakpointmarkers on Posit's input content parts;previous_response_idand legacy prompt-cache retention fields; and- any other root field outside the current Codex request contract, including
Posit's
max_output_tokens.
The model, messages, images, files, reasoning, tools, function calls and structured results, cache key, and streaming response remain intact. The adapter never mutates the request object supplied by its caller.
The OAuth runtime handles sign-in, token refresh, model discovery, upstream transport, and server lifecycle. The gateway defaults its optional Responses history to process-local memory so ID-based continuations can be resolved when needed. That history is discarded whenever the gateway stops.
Tested versions
Gateway 0.2.x has been tested with Posit Assistant 1.3.0 and 1.3.1. Compatibility with older versions is unknown. These are tested configurations, not minimum version requirements:
| IDE | Tested Posit Assistant version | | --- | --- | | RStudio | 1.3.0 | | Positron | 1.3.1 |
Troubleshooting
Run the read-only diagnostic report with:
r-assistant-gateway doctorIt reports the installed gateway and OAuth runtime versions, Posit Assistant
in RStudio (positAssistant) and Positron (positronAssistant), and the active
gateway’s health. Each Assistant entry includes its version and installation
path. The compatibility check recognizes the tested configurations: RStudio
Assistant 1.3.0 or Positron Assistant 1.3.1, alongside the expected OAuth runtime.
An unrecognized Assistant version is untested, not necessarily incompatible. An older or
missing installation in the other IDE does not prevent success. The command
still exits unsuccessfully if the gateway health check fails.
Positron detection checks ~/.positron/extensions, using the extension registry
when available and ignoring removed extensions. For a custom extension directory
(such as a --extensions-dir setup), set POSITRON_EXTENSIONS_DIR. Detection
reports installed packages; it does not check whether an extension is enabled
in the active Positron profile. The diagnostic report does not read conversations
or credentials.
Common fixes:
- RStudio or Positron cannot connect: make sure the gateway is running and the base URL
is exactly
http://127.0.0.1:10532/v1. - The port is busy: stop the other process, or start with
r-assistant-gateway --port <number>and update the base URL. - Sign-in fails: run
r-assistant-gateway loginagain, then restart the gateway. - A conversation fails after restarting the gateway: start a new Posit Assistant conversation. Temporary continuation state is cleared on restart.
doctordoes not recognize your Assistant version: versions 1.3.0 and 1.3.1 are tested; compatibility with older versions is unknown. A failed version check does not establish that your installation cannot work. For an administrator-managed or otherwise nonstandard installation, setPOSIT_ASSISTANT_ROOTto RStudio’spai/bindirectory, orPOSITRON_EXTENSIONS_DIRto Positron’s extension directory, before runningdoctor.doctorreports an unexpected OAuth runtime: reinstall the matchingr-assistant-gatewayrelease rather than upgrading its runtime directly.- The background gateway is not working: run
status, inspectlogs, then usestopbefore starting it again.
Privacy and network behavior
By default, the gateway listens only on your computer at 127.0.0.1. It uses
the same host behavior as openai-oauth. An explicit non-loopback --host can
make the unauthenticated endpoint reachable by other computers; every client
that can reach it can use your ChatGPT/Codex subscription. Keep the default
unless that access is deliberate and protected by your network.
OAuth credentials and upstream transport are handled by the published OAuth runtime. Recent Responses items are held only in the running process, with default limits of 256 response-history entries and 2,000 items. They are never persisted by the gateway and are discarded when it stops or restarts.
On POSIX systems, gateway startup and login restrict the selected OAuth
credential file to its owner (0600).
Diagnostics are off by default. If enabled with --diagnostics, they contain
metadata only: request ID, model, schema-only removed-field patterns, cache
breakpoint count, status, duration, and safely available token counts. Prompts,
conversation content, tool arguments and results, credentials, headers, auth
material, and reasoning content are not logged.
Advanced CLI options
The gateway accepts the same public commands and options as its OAuth runtime,
including login, --host, --port, --models, --codex-version,
--base-url, OAuth overrides, --no-open, login timeout, --detach, status,
logs, stop, --responses-state, --responses-max-responses, and
--responses-max-items.
There are two intentional Posit defaults: port 10532 and process-local
Responses memory. You can override the port. Setting --responses-state
stateless disables continuation by response or item IDs, so doctor does not
consider that configuration healthy for Posit Assistant. doctor and
--diagnostics are specific to this gateway.
OAuth runtime limitations
- Use an IPv4 host such as the default
127.0.0.1. The pinned OAuth runtime does not correctly advertise an IPv6 host. - Cancelling a request in the client may not stop the upstream generation. The pinned runtime does not yet propagate HTTP disconnects to its upstream fetch.
- The delegated runtime also exposes unadapted chat-completion and image routes. They are outside this gateway's supported surface; this is another reason to keep the listener on the default loopback address.
Development
Start with the interface and reverse-engineering notes to see which traffic belongs to each IDE, Posit Assistant, the gateway, and Codex.
npm install
npm run verify
npm run check:contract
npm pack --dry-runnpm run verify performs typechecking, linting, unit tests, a TypeScript build,
and a detached end-to-end CLI test using a Posit Assistant 1.3.0-shaped request.
CI also performs an npm package dry run. A separate scheduled/manual workflow
verifies that every root field forwarded by the adapter remains accepted by
Codex. Dependabot watches npm and GitHub Actions dependencies.
Credits and license
This project uses
@carl-stone/openai-oauth, a
published fork of Evan Zhou's openai-oauth. The dependency ships its own
Apache-2.0 license and notice; this repository's required attribution is
included in NOTICE.
The original gateway code in this repository is copyright Carl Stone and is licensed under Apache-2.0. See LICENSE.
Legal
R Assistant Gateway is an unofficial community project. It is not affiliated with, endorsed by, or supported by Posit Software, PBC.
Posit, RStudio, Positron, and Posit Assistant are trademarks of Posit Software, PBC, all rights reserved, and may be registered in the United States Patent and Trademark Office and in other countries.
