Repository navigation
Description
Summary
The repository's only example, examples/oauth_pkce_example.py, fails immediately on
import. The four OAuth PKCE helpers it uses were removed from the package in April 2026,
but the example was left behind.
Steps to reproduce
uv sync
uv run python examples/oauth_pkce_example.pyActual behavior
Traceback (most recent call last):
File "examples/oauth_pkce_example.py", line 10, in <module>
from openrouter.utils import (
...<4 lines>...
)
ImportError: cannot import name 'oauth_create_sha256_code_challenge' from 'openrouter.utils'
All four imported symbols are gone — grep -rn across src/ returns zero hits for each:
oauth_create_sha256_code_challengeoauth_create_authorization_urlCreateSHA256CodeChallengeRequestCreateAuthorizationUrlRequestWithPKCE
History
05f81a5"add oauth helpers" (2025-11-13) addedsrc/openrouter/utils/oauth_create_sha256_code_challenge.py
(120 lines) andsrc/openrouter/utils/oauth_create_authorization_url.py(95 lines), wired
their exports intosrc/openrouter/utils/__init__.py, and added this example.e6b0242"chore: clean up removed docs and update generated SDK files" (2026-04-02)
deleted both helper modules and theirutils/__init__.pyexports as part of a broad
regeneration. It touched no files underexamples/, so the example has been dead on
mainfor roughly four months.
Root cause, and why a straight revert will not hold
Both helpers were hand-written files placed inside src/openrouter/utils/, which is
otherwise entirely Speakeasy-generated. .genignore currently protects only:
pylintrc
docs/docs.json
docs/overview.mdx
Nothing there covers src/openrouter/utils/oauth_*.py, so the next regeneration was always
going to remove them — which is exactly what e6b0242 did. Restoring the files without
also adding them to .genignore would reintroduce the same silent deletion.
Suggested fix
Either direction resolves the broken example; the choice is whether the helpers are meant
to be part of the SDK:
- Drop the example. If the helpers were deliberately cut, delete
examples/oauth_pkce_example.py(and the now-emptyexamples/directory). Smallest
change, and it stops shipping code that cannot run. - Restore the helpers. Bring back both modules and their
utils/__init__.pyexports,
and add them to.genignoreso regeneration cannot wipe them again.
Worth noting for anyone hitting this in the meantime: the OAuth flow itself is not broken.
client.o_auth.create_auth_code and client.o_auth.exchange_auth_code_for_api_key are
both still present and generated. Only the client-side code-verifier/challenge generation
is missing, and that is a few lines of secrets + hashlib + base64 from the standard
library.
Environment
- openrouter 1.1.23 (main @ cb401a8)
- Python 3.11.9, httpx 0.28.1, pydantic 2.12.4
- Windows 11
Activity