Skip to content

feat(pctx-py): replace deprecated api_key with arbitrary headers#105

Merged
Elias Posen (eliasposen) merged 2 commits into
mainfrom
py-headers
Jul 13, 2026
Merged

feat(pctx-py): replace deprecated api_key with arbitrary headers#105
Elias Posen (eliasposen) merged 2 commits into
mainfrom
py-headers

Conversation

@eliasposen

Copy link
Copy Markdown
Contributor

Summary

The api_key parameter on the Pctx client is deprecated — the system that validated the key is no longer maintained. This replaces it with a headers: dict[str, str] | None parameter: an arbitrary set of headers applied to every HTTP request and the WebSocket connection request.

No backwards-compatible shim is retained; api_key and the x-pctx-api-key header are removed entirely.

Changes

  • _client.pyPctx.__init__ now takes headers instead of api_key; spreads them into the httpx.AsyncClient and forwards them to the WebSocketClient.
  • _websocket_client.pyWebSocketClient takes headers and merges them into the connect request. The reserved x-code-mode-session header is applied after caller headers so it can't be clobbered.
  • manual_code_mode.py — updated the commented example to headers={"authorization": "Bearer xxxx"}.

Remaining api_key references in the repo (README, crewai/langchain scripts) are OpenRouter LLM keys and are unrelated.

Type choice

dict[str, str] | None — covers every practical "arbitrary headers" use. It cannot express duplicate header keys, but clients essentially never need repeated header names; the type can be widened later without a breaking change.

Verification

make lint and make typecheck pass. Client imports and instantiates with headers.

🤖 Generated with Claude Code

Elias Posen (eliasposen) and others added 2 commits July 8, 2026 12:52
The system that validated the pctx api_key is no longer maintained.
Replace the `api_key` client parameter with `headers: dict[str, str]`,
an arbitrary set of headers applied to every HTTP request and the
WebSocket connection request. No backwards-compatible shim is retained.

The reserved `x-code-mode-session` header is applied after caller
headers on the WebSocket connect so it cannot be clobbered.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@eliasposen Elias Posen (eliasposen) merged commit 6f17438 into main Jul 13, 2026
13 checks passed
@eliasposen Elias Posen (eliasposen) deleted the py-headers branch July 13, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant