Skip to main content

Use the OpenAI Python SDK with your own ChatGPT subscription

Project description

login-with-chatgpt

Use the official openai Python package with your own ChatGPT subscription. Authentication follows the OAuth and ChatGPT-backed Codex transport implemented by the reference login-with-chatgpt project.

[!WARNING] This package uses a private, undocumented ChatGPT Codex endpoint. It is not the OpenAI API, has no compatibility or availability guarantee, and may stop working when the upstream protocol changes. Requests consume the signed-in user's own ChatGPT plan.

Install and sign in

uvx login-with-chatgpt login
uv add login-with-chatgpt

Browser PKCE is the default. For SSH, containers, or other headless environments:

uvx login-with-chatgpt login --device

Credentials are stored in the operating system keyring. The SDK never falls back to a plaintext token file.

OpenAI-compatible Responses client

login_with_chatgpt.OpenAI() returns an actual openai.OpenAI instance, so upstream response types, exceptions, parsing, streaming, and tool helpers remain available.

from login_with_chatgpt import OpenAI

client = OpenAI()
response = client.responses.create(
    model="gpt-5.5",
    input="Explain Python descriptors in three sentences.",
)
print(response.output_text)

Async code uses AsyncOpenAI().

Structured output

from pydantic import BaseModel
from login_with_chatgpt import OpenAI


class Answer(BaseModel):
    summary: str
    points: list[str]


client = OpenAI()
response = client.responses.parse(
    model="gpt-5.5",
    input="Summarize OAuth PKCE.",
    text_format=Answer,
)
print(response.output_parsed)

The supported surface is deliberately limited to POST /responses. Use ChatGPTAccount().list_models() or login-with-chatgpt models for model listing.

Guaranteed request features are text, SSE streaming, Pydantic structured output, function tools, image URL/data URL input, function-result continuation, and stateless multi-turn input replay. The SDK does not execute function tools.

Stateful response parameters (previous_response_id, conversation, background mode, and store=True) are rejected. Output token limits are also rejected because the private endpoint does not honor them; the SDK never silently removes a caller-specified usage limit.

Profiles and diagnostics

login-with-chatgpt --profile work login
login-with-chatgpt profiles
login-with-chatgpt use work
login-with-chatgpt status
login-with-chatgpt models
login-with-chatgpt doctor
login-with-chatgpt logout

Profile precedence is: explicit --profile / Python argument, LOGIN_WITH_CHATGPT_PROFILE, active profile, then default.

Development

uv sync --dev
uv run ruff check .
uv run pyright
uv run pytest
uv build

Real-account contract checks are opt-in because they consume subscription usage:

$env:LOGIN_WITH_CHATGPT_LIVE_MODEL = "gpt-5.5"
uv run pytest -m live

On POSIX shells, use export instead of set. Live tests use the currently active credential profile and are never run by CI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

login_with_chatgpt-0.1.0.tar.gz (68.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

login_with_chatgpt-0.1.0-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file login_with_chatgpt-0.1.0.tar.gz.

File metadata

  • Download URL: login_with_chatgpt-0.1.0.tar.gz
  • Upload date:
  • Size: 68.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for login_with_chatgpt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2fcc0d4e115af29852037548fa0d7be9aac8c3ff04bd3ea6a747223c7973830a
MD5 5e59d37d154cd91a181ae023f8847de5
BLAKE2b-256 73204aa6f6ce49d88c7b0991e965435d2f30e3b4d14f60db3055e01083f271c3

See more details on using hashes here.

File details

Details for the file login_with_chatgpt-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for login_with_chatgpt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9667b83f19ab6880ff187865ac5ac23b0f3f13c0a3a5f2c06f1dadf3ce67d112
MD5 de3400ef6c1f9a5b06f01c124df5b95c
BLAKE2b-256 907f1cd43579c6c0e88d4c58ebf8b23d87ded98bfc684d6b372febd3fa2535b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page