codex-as-api 0.6.2__tar.gz → 0.6.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/PKG-INFO +69 -14
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/README.md +68 -13
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/RELEASES.md +54 -1
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/pyproject.toml +1 -1
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/src/codex_as_api/__init__.py +1 -1
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/src/codex_as_api/anthropic_adapter.py +9 -3
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/src/codex_as_api/model_capabilities.py +13 -6
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/src/codex_as_api/provider.py +19 -9
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/src/codex_as_api/server.py +92 -3
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/test_anthropic_adapter.py +24 -3
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/test_provider.py +76 -2
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/test_server.py +297 -1
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/.gitignore +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/LICENSE +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/THIRD_PARTY_NOTICES.md +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/config/model-capabilities.json +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/config/o200k_base.tiktoken +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/requirements-server.txt +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/requirements.txt +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/src/codex_as_api/auth.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/src/codex_as_api/codex_config.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/src/codex_as_api/messages.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/src/codex_as_api/o200k_tokenizer.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/src/codex_as_api/protocol.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/__init__.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/conftest.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/fixtures/o200k_base_encode_ordinary.json +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/test_auth.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/test_codex_config.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/test_messages.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/test_model_capabilities.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/test_o200k_tokenizer.py +0 -0
- {codex_as_api-0.6.2 → codex_as_api-0.6.4}/tests/test_protocol.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codex-as-api
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.4
|
|
4
4
|
Summary: Use ChatGPT/Codex OAuth as a local OpenAI-compatible API server.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Eunho-J/codex-as-api
|
|
6
6
|
Project-URL: Repository, https://github.com/Eunho-J/codex-as-api
|
|
@@ -49,7 +49,7 @@ Use ChatGPT / Codex OAuth as a local OpenAI-compatible API server.
|
|
|
49
49
|
- **Tool calling** — function calls, tool results, and parallel tool calls
|
|
50
50
|
- **Image support** — generation, inspection, multimodal Chat input, and capability-gated `original` image detail in classic Responses
|
|
51
51
|
- **Reasoning** — configurable effort/context, `standard` mode compatibility, persisted reasoning, and streaming thinking content
|
|
52
|
-
- **Codex features** — `prompt_cache_key`, process-local `response_id` continuation, subagent headers, and remote compaction
|
|
52
|
+
- **Codex features** — session-aware `prompt_cache_key`, process-local Chat `response_id` continuation, subagent headers, and remote compaction
|
|
53
53
|
- **Codex config aware** — reads `CODEX_HOME` / `~/.codex/config.toml` for model, reasoning-effort, and context-window settings
|
|
54
54
|
- **Token estimate & compaction helpers** — Anthropic-compatible `/v1/messages/count_tokens` and `/v1/messages/compact`
|
|
55
55
|
- **Auto auth** — reads `~/.codex/auth.json` and auto-refreshes OAuth tokens
|
|
@@ -310,13 +310,36 @@ curl -N http://localhost:18080/v1/messages \
|
|
|
310
310
|
}'
|
|
311
311
|
```
|
|
312
312
|
|
|
313
|
+
### Identifier and cache behavior
|
|
314
|
+
|
|
315
|
+
The two compatibility facades intentionally use the similarly named fields for
|
|
316
|
+
different jobs:
|
|
317
|
+
|
|
318
|
+
| Input or output | `/v1/chat/completions` | `/v1/messages` |
|
|
319
|
+
|---|---|---|
|
|
320
|
+
| `client_metadata.session_id` | Forwarded to Codex, used as the default `prompt_cache_key`, and required when Codex metadata mode is enabled | Not used or forwarded |
|
|
321
|
+
| `client_metadata.thread_id` | Codex metadata thread identity; defaults to `session_id` for a root request and preserves an explicit child thread | Not used or synthesized |
|
|
322
|
+
| `prompt_cache_key` | Explicit value wins; otherwise a non-empty `client_metadata.session_id` is used; otherwise omitted | Optional proxy extension; explicit value wins, otherwise the Claude Code session header is hashed |
|
|
323
|
+
| `x-claude-code-session-id` | Not used | SHA-256 of `codex-as-api:claude-code-session:<exact header value>` supplies cache affinity only |
|
|
324
|
+
| `previous_response_id` | Resolves a known entry from the 256-chain process-local history and replays full input/output over HTTP; never forwarded | Non-null values return Anthropic-style HTTP 400 because normal Messages is stateless |
|
|
325
|
+
| `cache_control` | Not an OpenAI Chat control | Validated as an Anthropic compatibility hint, then stripped before Codex transport |
|
|
326
|
+
|
|
327
|
+
Anthropic `cache_control` is a cache-boundary annotation, not an identifier.
|
|
328
|
+
This proxy accepts only `{"type":"ephemeral"}` with optional `ttl: "5m"` or
|
|
329
|
+
`"1h"` at request, system, message, content-block, and tool locations. The
|
|
330
|
+
private Codex request has no Anthropic breakpoint or TTL fields, so accepted
|
|
331
|
+
hints do not reproduce Anthropic caching semantics. Normal `/v1/messages`
|
|
332
|
+
responses do not expose the Chat-only `response_id`. The custom
|
|
333
|
+
`/v1/messages/compact` endpoint retains its documented local
|
|
334
|
+
`previous_response_id` support.
|
|
335
|
+
|
|
313
336
|
### `POST /v1/messages/count_tokens`
|
|
314
337
|
|
|
315
338
|
Anthropic-compatible token counting helper. Codex OAuth does not expose a count-only endpoint equivalent to Anthropic's native API, so this route counts text locally and returns context-window metadata for the effective backend model. Normalized model-visible messages, tool calls, tool-result metadata, reasoning, and tool schemas are counted once. Request-envelope and generation-control fields are excluded, and image inputs use a separate fixed estimate so inline base64 data is not counted as text.
|
|
316
339
|
|
|
317
340
|
GPT-5-family text uses a bundled port of official `tiktoken` `o200k_base` `encode_ordinary`: the same Unicode pre-tokenization regex, byte-pair merge algorithm, and merge-rank data are implemented in Python, TypeScript, and Rust. Official `tiktoken` maps `gpt-5` and its `gpt-5-`-prefixed variants to [`o200k_base`](https://github.com/openai/tiktoken/blob/08a5f3b2c987ada4fc5aa1f16c643c203fa8acaa/tiktoken/model.py#L7-L20); this project applies that GPT-5-family encoding to the bundled `gpt-5.*` Codex model IDs. The project does not depend on a `tiktoken` package or download encoding data at runtime. The last upstream synchronization check was **2026-07-14**, against [`tiktoken` 0.13.0 at `08a5f3b`](https://github.com/openai/tiktoken/tree/08a5f3b2c987ada4fc5aa1f16c643c203fa8acaa); the bundled rank file SHA-256 is `446a9538cb6c348e3516120d7c08b09f57c36495e2acfffe59a5bf8b0cfb1a2d`.
|
|
318
341
|
|
|
319
|
-
Official Codex also has a [`ceil(UTF-8 bytes / 4)` truncation helper](https://github.com/openai/codex/blob/
|
|
342
|
+
Official Codex also has a [`ceil(UTF-8 bytes / 4)` truncation helper](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/utils/string/src/truncate.rs#L4-L84), but Codex documents the history estimate using that helper as [a coarse lower bound rather than a tokenizer-accurate count](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/core/src/context_manager/history.rs#L162-L186). This endpoint therefore uses exact `o200k_base` ordinary text tokenization instead. The complete request count remains an estimate because protocol-wrapper overhead and image cost are local constants, but the former byte-as-token and raw-payload double count that could overstate ordinary Claude Code requests by about 8x is removed.
|
|
320
343
|
|
|
321
344
|
```bash
|
|
322
345
|
curl http://localhost:18080/v1/messages/count_tokens \
|
|
@@ -399,7 +422,7 @@ These features are extensions beyond the standard OpenAI API, designed for Codex
|
|
|
399
422
|
|
|
400
423
|
`prompt_cache_key` keeps related prefixes in the same backend cache family. Use one stable, privacy-safe key per conversation or application prefix.
|
|
401
424
|
|
|
402
|
-
Official Codex [
|
|
425
|
+
Official Codex 0.145.0 and current `main` [default this field to Responses metadata `session_id`](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/core/src/client.rs#L483-L486), unless an explicit override is present. This proxy follows the same precedence on Chat requests: explicit `prompt_cache_key`, then a non-empty `client_metadata.session_id`, then omission. It does not generate a process-wide session or reuse `thread_id` as the cache key.
|
|
403
426
|
|
|
404
427
|
The private Codex OAuth HTTP and WebSocket request structures do not contain public GPT-5.6 `prompt_cache_options` or content-block `prompt_cache_breakpoint` fields. This proxy treats explicit `null` as omitted and rejects non-null controls with HTTP 400 instead of forwarding a request that the private route rejects or silently pretending the requested cache policy was applied. Use a public Responses API client when explicit cache policy or breakpoints are required. See OpenAI's [public prompt caching guide](https://developers.openai.com/api/docs/guides/prompt-caching#prompt-cache-breakpoints).
|
|
405
428
|
|
|
@@ -444,7 +467,7 @@ GPT-5.6 requests can instead use the public Responses-shaped object:
|
|
|
444
467
|
- Responses Lite uses `all_turns` as the Codex wire default. An explicitly different context is rejected instead of silently overwritten; use `responses_lite: false` when the backend route supports classic Responses and another context is required.
|
|
445
468
|
- Remote compact keeps its existing private Codex `reasoning_effort` field but does not accept public `reasoning.mode` or `reasoning.context`.
|
|
446
469
|
|
|
447
|
-
Anthropic `thinking` values map as `enabled → high`, `adaptive → medium`, and `disabled → none`. Claude Code's `output_config.effort` takes precedence over
|
|
470
|
+
Anthropic `thinking` values map as `enabled → high`, `adaptive → medium`, and `disabled → none`. Claude Code's `output_config.effort` takes precedence over adaptive or enabled thinking and supports `low`, `medium`, `high`, `xhigh`, and `max`. Call-level `thinking.disabled` takes precedence over ambient `output_config.effort`, so Claude Code WebSearch/WebFetch auxiliary calls use `none` instead of failing the compatibility check with HTTP 400. The supported reasoning context and verbosity extensions are also available on `/v1/messages`, image generation, and inspection requests; Pro and non-null public cache policy/breakpoints or `safety_identifier` fail explicitly on the private Codex provider.
|
|
448
471
|
|
|
449
472
|
The pinned official Codex HTTP request has no `stop` field. Omitted, `null`, and empty stop values are omitted from the private request; any non-empty OpenAI `stop` or Anthropic `stop_sequences` value returns HTTP 400 before the private transport starts.
|
|
450
473
|
|
|
@@ -454,7 +477,7 @@ The mapping is intentionally transport-aware:
|
|
|
454
477
|
|---|---|
|
|
455
478
|
| `reasoning.mode: "standard"` | Omit mode; send the resolved effort/context |
|
|
456
479
|
| `reasoning.mode: "pro"` | HTTP 400; no official Codex alias |
|
|
457
|
-
| `prompt_cache_key` | Forward
|
|
480
|
+
| `prompt_cache_key` | Forward an explicit value; otherwise use non-empty `client_metadata.session_id` |
|
|
458
481
|
| Non-null `prompt_cache_options` / breakpoint | HTTP 400; `null` is omitted and there is no private field |
|
|
459
482
|
| Non-null `safety_identifier` | HTTP 400; `null` is omitted and OAuth account/thread IDs are not semantic aliases |
|
|
460
483
|
| Non-empty `stop` / `stop_sequences` | HTTP 400; no private field |
|
|
@@ -462,7 +485,7 @@ The mapping is intentionally transport-aware:
|
|
|
462
485
|
| `service_tier: "fast"` | Send `service_tier: "priority"` |
|
|
463
486
|
| `service_tier: "default"` | Omit the field |
|
|
464
487
|
|
|
465
|
-
Authenticated tests on July 10, 2026 verified both official continuation paths with `gpt-5.6-sol`: a direct private Responses WebSocket completed a second delta request using the exact prior `response.id`, and the private HTTP endpoint completed the same continuation when the full prior input/output history was replayed. The proxy implements the HTTP replay strategy. Direct HTTP forwarding of `previous_response_id`, Pro, public cache controls, and `safety_identifier` was rejected and is not used. See OpenAI's [reasoning mode documentation](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode) and the official Codex [HTTP/WebSocket request structures](https://github.com/openai/codex/blob/
|
|
488
|
+
Authenticated tests on July 10, 2026 verified both official continuation paths with `gpt-5.6-sol`: a direct private Responses WebSocket completed a second delta request using the exact prior `response.id`, and the private HTTP endpoint completed the same continuation when the full prior input/output history was replayed. The proxy implements the HTTP replay strategy. Direct HTTP forwarding of `previous_response_id`, Pro, public cache controls, and `safety_identifier` was rejected and is not used. See OpenAI's [reasoning mode documentation](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode) and the official Codex [HTTP/WebSocket request structures](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/codex-api/src/common.rs#L251-L307).
|
|
466
489
|
|
|
467
490
|
### `responses_lite`
|
|
468
491
|
|
|
@@ -508,15 +531,15 @@ Set `parallel_tool_calls: true` to request parallel tool calls when the selected
|
|
|
508
531
|
|
|
509
532
|
### `client_metadata` and `codex_metadata`
|
|
510
533
|
|
|
511
|
-
`client_metadata` is forwarded to the Codex backend. Set `codex_metadata: true` or `CODEX_AS_API_CODEX_METADATA=on` to
|
|
534
|
+
`client_metadata` is forwarded to the Codex backend. Set `codex_metadata: true` or `CODEX_AS_API_CODEX_METADATA=on` to add Codex-style turn metadata. Metadata mode requires a non-empty caller-supplied `client_metadata.session_id`; it preserves that session, defaults a missing root `thread_id` to the session, and preserves an explicit child `thread_id`.
|
|
512
535
|
|
|
513
|
-
|
|
536
|
+
The installation ID and process window ID remain stable, while `turn_id` and `x-codex-turn-metadata` are regenerated for each request. Metadata `thread_id` is neither a `previous_response_id` alias nor a cache key. An explicit `prompt_cache_key` wins; otherwise the non-empty session ID supplies cache affinity.
|
|
514
537
|
|
|
515
538
|
### `previous_response_id`
|
|
516
539
|
|
|
517
540
|
Non-streaming responses and the final streaming finish chunk expose the real upstream Responses ID as `response_id`. The provider keeps up to 256 completed chains in a process-local LRU store. Passing a known ID as `previous_response_id` prepends the saved semantic input and exact prior `response.output_item.done` items—including encrypted reasoning and tool items—to the new input, then sends one full private HTTP request. The ID itself is never forwarded and is never converted to `thread_id`.
|
|
518
541
|
|
|
519
|
-
That event source is intentional: the official Codex SSE parser [takes semantic items from `response.output_item.done`](https://github.com/openai/codex/blob/
|
|
542
|
+
That event source is intentional: the official Codex SSE parser [takes semantic items from `response.output_item.done`](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/codex-api/src/sse/responses.rs#L327-L337), while its [`response.completed` shape contains the response ID, usage, and `end_turn`](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/codex-api/src/sse/responses.rs#L112-L120), not replay history. The authenticated private HTTP rollout likewise returned an empty `response.completed.output`; the proxy therefore commits the completed output-item events instead of treating that extra field as conversation state.
|
|
520
543
|
|
|
521
544
|
Only a real `response.completed` event commits a chain. Branches from an older retained ID are supported. Restarting the server or evicting an old entry removes that local state; an unknown ID returns HTTP 400 before any upstream request.
|
|
522
545
|
|
|
@@ -642,14 +665,18 @@ curl -N http://localhost:18080/v1/chat/completions \
|
|
|
642
665
|
|
|
643
666
|
## Using with Claude Code
|
|
644
667
|
|
|
645
|
-
The `/v1/messages` endpoint implements the Anthropic Messages gateway shape used by Claude Code.
|
|
668
|
+
The `/v1/messages` endpoint implements the Anthropic Messages gateway shape used by Claude Code. The current request shape was reproduced with Claude Code `2.1.220`; streaming, real Codex OAuth chat, request-level GPT model routing, adaptive thinking, `--effort max`, and Fast Mode remain covered.
|
|
646
669
|
|
|
647
670
|
Start the proxy first. `CODEX_AS_API_MODEL` is the fallback used when Claude Code sends a built-in Anthropic model name:
|
|
648
671
|
|
|
649
672
|
```bash
|
|
650
|
-
CODEX_AS_API_MODEL=gpt-5.6-terra
|
|
673
|
+
CODEX_AS_API_MODEL=gpt-5.6-terra \
|
|
674
|
+
CODEX_AS_API_RESPONSES_LITE=off \
|
|
675
|
+
codex-as-api
|
|
651
676
|
```
|
|
652
677
|
|
|
678
|
+
`CODEX_AS_API_RESPONSES_LITE=off` is required for Claude Code hosted WebSearch on GPT-5.6. Official Codex Responses Lite uses a client-side standalone `web.run` tool, while this gateway receives Anthropic's hosted `web_search` declaration and has no standalone executor; classic Responses preserves that hosted tool. WebFetch does not use a hosted Responses tool, but still needs the disabled-thinking precedence fix when process-level effort is enabled.
|
|
679
|
+
|
|
653
680
|
To keep the built-in Fable, Opus, Sonnet, and Haiku rows and append one GPT row, launch the GPT-routed Claude Code process with these variables:
|
|
654
681
|
|
|
655
682
|
```bash
|
|
@@ -662,7 +689,14 @@ CLAUDE_CODE_ATTRIBUTION_HEADER=0 \
|
|
|
662
689
|
claude
|
|
663
690
|
```
|
|
664
691
|
|
|
665
|
-
Run `/model` and select **GPT-5.6 Sol**. The custom entry is appended to the built-in rows rather than replacing them. Claude Code `2.1.
|
|
692
|
+
Run `/model` and select **GPT-5.6 Sol**. The custom entry is appended to the built-in rows rather than replacing them. Claude Code `2.1.220` recognizes this GPT model ID without a custom capability declaration: `/effort low|medium|high|xhigh|max`, the picker effort control, and `claude --effort ...` are translated from Claude Code's `output_config.effort` to the Codex reasoning effort. Claude Code Fast Mode's `speed: "fast"` is translated to the Codex `priority` service tier.
|
|
693
|
+
|
|
694
|
+
Claude Code sends `x-claude-code-session-id` for gateway request grouping. This
|
|
695
|
+
proxy hashes the exact header value into a stable `prompt_cache_key`; it does
|
|
696
|
+
not turn the header into Codex `session_id` or `thread_id` metadata. A
|
|
697
|
+
top-level `prompt_cache_key` is supported as a proxy extension and takes
|
|
698
|
+
precedence. Normal Messages requests remain stateless, so callers must send
|
|
699
|
+
full message history.
|
|
666
700
|
|
|
667
701
|
If managed settings define an `availableModels` allowlist, that list must include the exact `ANTHROPIC_CUSTOM_MODEL_OPTION` value, such as `gpt-5.6-sol`; otherwise Claude Code hides or rejects the custom row.
|
|
668
702
|
|
|
@@ -720,7 +754,7 @@ The provider handles:
|
|
|
720
754
|
## Release & package publishing
|
|
721
755
|
|
|
722
756
|
- Bump versions in `pyproject.toml`, `src/codex_as_api/__init__.py`, `src/codex_as_api/server.py`, `ts/package.json`, `ts/package-lock.json`, `rust/Cargo.toml`, and `rust/Cargo.lock`.
|
|
723
|
-
- Publish a GitHub Release such as `v0.6.
|
|
757
|
+
- Publish a GitHub Release such as `v0.6.4` from the matching commit.
|
|
724
758
|
- The manually-dispatched `Publish npm packages` workflow builds/tests the TypeScript package, runs `npm pack --dry-run`, publishes `codex-as-api` to npmjs when `NPM_TOKEN` is configured, and publishes `@eunho-j/codex-as-api` to GitHub Packages with `GITHUB_TOKEN`.
|
|
725
759
|
|
|
726
760
|
Publishing to npmjs requires an authenticated npm session (`npm login` beforehand; `npm whoami` should succeed). From the repository root, the publish itself is one command:
|
|
@@ -763,6 +797,27 @@ npm test
|
|
|
763
797
|
|
|
764
798
|
## Release Notes
|
|
765
799
|
|
|
800
|
+
### v0.6.4
|
|
801
|
+
|
|
802
|
+
- Remove process-global generated Codex session/thread identities and require
|
|
803
|
+
explicit session identity when Codex metadata mode is enabled.
|
|
804
|
+
- Resolve Chat cache affinity as explicit `prompt_cache_key`, then
|
|
805
|
+
`client_metadata.session_id`, then omission.
|
|
806
|
+
- Derive Claude Code cache affinity from `x-claude-code-session-id` without
|
|
807
|
+
fabricating Codex metadata; keep normal Anthropic Messages stateless.
|
|
808
|
+
- Validate and strip Anthropic `cache_control` compatibility hints without
|
|
809
|
+
claiming unavailable breakpoint or TTL semantics.
|
|
810
|
+
- Update current compatibility evidence to Codex `0.145.0`, Codex `main` at
|
|
811
|
+
`bd2de422aa287b97b06ca6425a10935bcf1b3731`, and Claude Code `2.1.220`.
|
|
812
|
+
|
|
813
|
+
### v0.6.3
|
|
814
|
+
|
|
815
|
+
- Accept Claude Code auxiliary requests that combine ambient `output_config.effort` with call-level `thinking.disabled`.
|
|
816
|
+
- Give explicit disabled thinking precedence and send Codex reasoning effort `none` instead of returning HTTP 400.
|
|
817
|
+
- Document and test `CODEX_AS_API_RESPONSES_LITE=off` for Claude Code hosted WebSearch on GPT-5.6; WebFetch needs no Responses Lite override.
|
|
818
|
+
- Preserve fail-loudly validation for invalid effort values and unsupported `output_config` fields.
|
|
819
|
+
- Add Python, TypeScript, and Rust adapter regressions, streamed `/v1/messages` coverage, and a `/count_tokens` regression for the WebSearch/WebFetch request shape.
|
|
820
|
+
|
|
766
821
|
### v0.6.2
|
|
767
822
|
|
|
768
823
|
- Fix `/v1/messages/count_tokens` overcounting that could trigger Claude Code autocompaction on every turn.
|
|
@@ -15,7 +15,7 @@ Use ChatGPT / Codex OAuth as a local OpenAI-compatible API server.
|
|
|
15
15
|
- **Tool calling** — function calls, tool results, and parallel tool calls
|
|
16
16
|
- **Image support** — generation, inspection, multimodal Chat input, and capability-gated `original` image detail in classic Responses
|
|
17
17
|
- **Reasoning** — configurable effort/context, `standard` mode compatibility, persisted reasoning, and streaming thinking content
|
|
18
|
-
- **Codex features** — `prompt_cache_key`, process-local `response_id` continuation, subagent headers, and remote compaction
|
|
18
|
+
- **Codex features** — session-aware `prompt_cache_key`, process-local Chat `response_id` continuation, subagent headers, and remote compaction
|
|
19
19
|
- **Codex config aware** — reads `CODEX_HOME` / `~/.codex/config.toml` for model, reasoning-effort, and context-window settings
|
|
20
20
|
- **Token estimate & compaction helpers** — Anthropic-compatible `/v1/messages/count_tokens` and `/v1/messages/compact`
|
|
21
21
|
- **Auto auth** — reads `~/.codex/auth.json` and auto-refreshes OAuth tokens
|
|
@@ -276,13 +276,36 @@ curl -N http://localhost:18080/v1/messages \
|
|
|
276
276
|
}'
|
|
277
277
|
```
|
|
278
278
|
|
|
279
|
+
### Identifier and cache behavior
|
|
280
|
+
|
|
281
|
+
The two compatibility facades intentionally use the similarly named fields for
|
|
282
|
+
different jobs:
|
|
283
|
+
|
|
284
|
+
| Input or output | `/v1/chat/completions` | `/v1/messages` |
|
|
285
|
+
|---|---|---|
|
|
286
|
+
| `client_metadata.session_id` | Forwarded to Codex, used as the default `prompt_cache_key`, and required when Codex metadata mode is enabled | Not used or forwarded |
|
|
287
|
+
| `client_metadata.thread_id` | Codex metadata thread identity; defaults to `session_id` for a root request and preserves an explicit child thread | Not used or synthesized |
|
|
288
|
+
| `prompt_cache_key` | Explicit value wins; otherwise a non-empty `client_metadata.session_id` is used; otherwise omitted | Optional proxy extension; explicit value wins, otherwise the Claude Code session header is hashed |
|
|
289
|
+
| `x-claude-code-session-id` | Not used | SHA-256 of `codex-as-api:claude-code-session:<exact header value>` supplies cache affinity only |
|
|
290
|
+
| `previous_response_id` | Resolves a known entry from the 256-chain process-local history and replays full input/output over HTTP; never forwarded | Non-null values return Anthropic-style HTTP 400 because normal Messages is stateless |
|
|
291
|
+
| `cache_control` | Not an OpenAI Chat control | Validated as an Anthropic compatibility hint, then stripped before Codex transport |
|
|
292
|
+
|
|
293
|
+
Anthropic `cache_control` is a cache-boundary annotation, not an identifier.
|
|
294
|
+
This proxy accepts only `{"type":"ephemeral"}` with optional `ttl: "5m"` or
|
|
295
|
+
`"1h"` at request, system, message, content-block, and tool locations. The
|
|
296
|
+
private Codex request has no Anthropic breakpoint or TTL fields, so accepted
|
|
297
|
+
hints do not reproduce Anthropic caching semantics. Normal `/v1/messages`
|
|
298
|
+
responses do not expose the Chat-only `response_id`. The custom
|
|
299
|
+
`/v1/messages/compact` endpoint retains its documented local
|
|
300
|
+
`previous_response_id` support.
|
|
301
|
+
|
|
279
302
|
### `POST /v1/messages/count_tokens`
|
|
280
303
|
|
|
281
304
|
Anthropic-compatible token counting helper. Codex OAuth does not expose a count-only endpoint equivalent to Anthropic's native API, so this route counts text locally and returns context-window metadata for the effective backend model. Normalized model-visible messages, tool calls, tool-result metadata, reasoning, and tool schemas are counted once. Request-envelope and generation-control fields are excluded, and image inputs use a separate fixed estimate so inline base64 data is not counted as text.
|
|
282
305
|
|
|
283
306
|
GPT-5-family text uses a bundled port of official `tiktoken` `o200k_base` `encode_ordinary`: the same Unicode pre-tokenization regex, byte-pair merge algorithm, and merge-rank data are implemented in Python, TypeScript, and Rust. Official `tiktoken` maps `gpt-5` and its `gpt-5-`-prefixed variants to [`o200k_base`](https://github.com/openai/tiktoken/blob/08a5f3b2c987ada4fc5aa1f16c643c203fa8acaa/tiktoken/model.py#L7-L20); this project applies that GPT-5-family encoding to the bundled `gpt-5.*` Codex model IDs. The project does not depend on a `tiktoken` package or download encoding data at runtime. The last upstream synchronization check was **2026-07-14**, against [`tiktoken` 0.13.0 at `08a5f3b`](https://github.com/openai/tiktoken/tree/08a5f3b2c987ada4fc5aa1f16c643c203fa8acaa); the bundled rank file SHA-256 is `446a9538cb6c348e3516120d7c08b09f57c36495e2acfffe59a5bf8b0cfb1a2d`.
|
|
284
307
|
|
|
285
|
-
Official Codex also has a [`ceil(UTF-8 bytes / 4)` truncation helper](https://github.com/openai/codex/blob/
|
|
308
|
+
Official Codex also has a [`ceil(UTF-8 bytes / 4)` truncation helper](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/utils/string/src/truncate.rs#L4-L84), but Codex documents the history estimate using that helper as [a coarse lower bound rather than a tokenizer-accurate count](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/core/src/context_manager/history.rs#L162-L186). This endpoint therefore uses exact `o200k_base` ordinary text tokenization instead. The complete request count remains an estimate because protocol-wrapper overhead and image cost are local constants, but the former byte-as-token and raw-payload double count that could overstate ordinary Claude Code requests by about 8x is removed.
|
|
286
309
|
|
|
287
310
|
```bash
|
|
288
311
|
curl http://localhost:18080/v1/messages/count_tokens \
|
|
@@ -365,7 +388,7 @@ These features are extensions beyond the standard OpenAI API, designed for Codex
|
|
|
365
388
|
|
|
366
389
|
`prompt_cache_key` keeps related prefixes in the same backend cache family. Use one stable, privacy-safe key per conversation or application prefix.
|
|
367
390
|
|
|
368
|
-
Official Codex [
|
|
391
|
+
Official Codex 0.145.0 and current `main` [default this field to Responses metadata `session_id`](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/core/src/client.rs#L483-L486), unless an explicit override is present. This proxy follows the same precedence on Chat requests: explicit `prompt_cache_key`, then a non-empty `client_metadata.session_id`, then omission. It does not generate a process-wide session or reuse `thread_id` as the cache key.
|
|
369
392
|
|
|
370
393
|
The private Codex OAuth HTTP and WebSocket request structures do not contain public GPT-5.6 `prompt_cache_options` or content-block `prompt_cache_breakpoint` fields. This proxy treats explicit `null` as omitted and rejects non-null controls with HTTP 400 instead of forwarding a request that the private route rejects or silently pretending the requested cache policy was applied. Use a public Responses API client when explicit cache policy or breakpoints are required. See OpenAI's [public prompt caching guide](https://developers.openai.com/api/docs/guides/prompt-caching#prompt-cache-breakpoints).
|
|
371
394
|
|
|
@@ -410,7 +433,7 @@ GPT-5.6 requests can instead use the public Responses-shaped object:
|
|
|
410
433
|
- Responses Lite uses `all_turns` as the Codex wire default. An explicitly different context is rejected instead of silently overwritten; use `responses_lite: false` when the backend route supports classic Responses and another context is required.
|
|
411
434
|
- Remote compact keeps its existing private Codex `reasoning_effort` field but does not accept public `reasoning.mode` or `reasoning.context`.
|
|
412
435
|
|
|
413
|
-
Anthropic `thinking` values map as `enabled → high`, `adaptive → medium`, and `disabled → none`. Claude Code's `output_config.effort` takes precedence over
|
|
436
|
+
Anthropic `thinking` values map as `enabled → high`, `adaptive → medium`, and `disabled → none`. Claude Code's `output_config.effort` takes precedence over adaptive or enabled thinking and supports `low`, `medium`, `high`, `xhigh`, and `max`. Call-level `thinking.disabled` takes precedence over ambient `output_config.effort`, so Claude Code WebSearch/WebFetch auxiliary calls use `none` instead of failing the compatibility check with HTTP 400. The supported reasoning context and verbosity extensions are also available on `/v1/messages`, image generation, and inspection requests; Pro and non-null public cache policy/breakpoints or `safety_identifier` fail explicitly on the private Codex provider.
|
|
414
437
|
|
|
415
438
|
The pinned official Codex HTTP request has no `stop` field. Omitted, `null`, and empty stop values are omitted from the private request; any non-empty OpenAI `stop` or Anthropic `stop_sequences` value returns HTTP 400 before the private transport starts.
|
|
416
439
|
|
|
@@ -420,7 +443,7 @@ The mapping is intentionally transport-aware:
|
|
|
420
443
|
|---|---|
|
|
421
444
|
| `reasoning.mode: "standard"` | Omit mode; send the resolved effort/context |
|
|
422
445
|
| `reasoning.mode: "pro"` | HTTP 400; no official Codex alias |
|
|
423
|
-
| `prompt_cache_key` | Forward
|
|
446
|
+
| `prompt_cache_key` | Forward an explicit value; otherwise use non-empty `client_metadata.session_id` |
|
|
424
447
|
| Non-null `prompt_cache_options` / breakpoint | HTTP 400; `null` is omitted and there is no private field |
|
|
425
448
|
| Non-null `safety_identifier` | HTTP 400; `null` is omitted and OAuth account/thread IDs are not semantic aliases |
|
|
426
449
|
| Non-empty `stop` / `stop_sequences` | HTTP 400; no private field |
|
|
@@ -428,7 +451,7 @@ The mapping is intentionally transport-aware:
|
|
|
428
451
|
| `service_tier: "fast"` | Send `service_tier: "priority"` |
|
|
429
452
|
| `service_tier: "default"` | Omit the field |
|
|
430
453
|
|
|
431
|
-
Authenticated tests on July 10, 2026 verified both official continuation paths with `gpt-5.6-sol`: a direct private Responses WebSocket completed a second delta request using the exact prior `response.id`, and the private HTTP endpoint completed the same continuation when the full prior input/output history was replayed. The proxy implements the HTTP replay strategy. Direct HTTP forwarding of `previous_response_id`, Pro, public cache controls, and `safety_identifier` was rejected and is not used. See OpenAI's [reasoning mode documentation](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode) and the official Codex [HTTP/WebSocket request structures](https://github.com/openai/codex/blob/
|
|
454
|
+
Authenticated tests on July 10, 2026 verified both official continuation paths with `gpt-5.6-sol`: a direct private Responses WebSocket completed a second delta request using the exact prior `response.id`, and the private HTTP endpoint completed the same continuation when the full prior input/output history was replayed. The proxy implements the HTTP replay strategy. Direct HTTP forwarding of `previous_response_id`, Pro, public cache controls, and `safety_identifier` was rejected and is not used. See OpenAI's [reasoning mode documentation](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode) and the official Codex [HTTP/WebSocket request structures](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/codex-api/src/common.rs#L251-L307).
|
|
432
455
|
|
|
433
456
|
### `responses_lite`
|
|
434
457
|
|
|
@@ -474,15 +497,15 @@ Set `parallel_tool_calls: true` to request parallel tool calls when the selected
|
|
|
474
497
|
|
|
475
498
|
### `client_metadata` and `codex_metadata`
|
|
476
499
|
|
|
477
|
-
`client_metadata` is forwarded to the Codex backend. Set `codex_metadata: true` or `CODEX_AS_API_CODEX_METADATA=on` to
|
|
500
|
+
`client_metadata` is forwarded to the Codex backend. Set `codex_metadata: true` or `CODEX_AS_API_CODEX_METADATA=on` to add Codex-style turn metadata. Metadata mode requires a non-empty caller-supplied `client_metadata.session_id`; it preserves that session, defaults a missing root `thread_id` to the session, and preserves an explicit child `thread_id`.
|
|
478
501
|
|
|
479
|
-
|
|
502
|
+
The installation ID and process window ID remain stable, while `turn_id` and `x-codex-turn-metadata` are regenerated for each request. Metadata `thread_id` is neither a `previous_response_id` alias nor a cache key. An explicit `prompt_cache_key` wins; otherwise the non-empty session ID supplies cache affinity.
|
|
480
503
|
|
|
481
504
|
### `previous_response_id`
|
|
482
505
|
|
|
483
506
|
Non-streaming responses and the final streaming finish chunk expose the real upstream Responses ID as `response_id`. The provider keeps up to 256 completed chains in a process-local LRU store. Passing a known ID as `previous_response_id` prepends the saved semantic input and exact prior `response.output_item.done` items—including encrypted reasoning and tool items—to the new input, then sends one full private HTTP request. The ID itself is never forwarded and is never converted to `thread_id`.
|
|
484
507
|
|
|
485
|
-
That event source is intentional: the official Codex SSE parser [takes semantic items from `response.output_item.done`](https://github.com/openai/codex/blob/
|
|
508
|
+
That event source is intentional: the official Codex SSE parser [takes semantic items from `response.output_item.done`](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/codex-api/src/sse/responses.rs#L327-L337), while its [`response.completed` shape contains the response ID, usage, and `end_turn`](https://github.com/openai/codex/blob/bd2de422aa287b97b06ca6425a10935bcf1b3731/codex-rs/codex-api/src/sse/responses.rs#L112-L120), not replay history. The authenticated private HTTP rollout likewise returned an empty `response.completed.output`; the proxy therefore commits the completed output-item events instead of treating that extra field as conversation state.
|
|
486
509
|
|
|
487
510
|
Only a real `response.completed` event commits a chain. Branches from an older retained ID are supported. Restarting the server or evicting an old entry removes that local state; an unknown ID returns HTTP 400 before any upstream request.
|
|
488
511
|
|
|
@@ -608,14 +631,18 @@ curl -N http://localhost:18080/v1/chat/completions \
|
|
|
608
631
|
|
|
609
632
|
## Using with Claude Code
|
|
610
633
|
|
|
611
|
-
The `/v1/messages` endpoint implements the Anthropic Messages gateway shape used by Claude Code.
|
|
634
|
+
The `/v1/messages` endpoint implements the Anthropic Messages gateway shape used by Claude Code. The current request shape was reproduced with Claude Code `2.1.220`; streaming, real Codex OAuth chat, request-level GPT model routing, adaptive thinking, `--effort max`, and Fast Mode remain covered.
|
|
612
635
|
|
|
613
636
|
Start the proxy first. `CODEX_AS_API_MODEL` is the fallback used when Claude Code sends a built-in Anthropic model name:
|
|
614
637
|
|
|
615
638
|
```bash
|
|
616
|
-
CODEX_AS_API_MODEL=gpt-5.6-terra
|
|
639
|
+
CODEX_AS_API_MODEL=gpt-5.6-terra \
|
|
640
|
+
CODEX_AS_API_RESPONSES_LITE=off \
|
|
641
|
+
codex-as-api
|
|
617
642
|
```
|
|
618
643
|
|
|
644
|
+
`CODEX_AS_API_RESPONSES_LITE=off` is required for Claude Code hosted WebSearch on GPT-5.6. Official Codex Responses Lite uses a client-side standalone `web.run` tool, while this gateway receives Anthropic's hosted `web_search` declaration and has no standalone executor; classic Responses preserves that hosted tool. WebFetch does not use a hosted Responses tool, but still needs the disabled-thinking precedence fix when process-level effort is enabled.
|
|
645
|
+
|
|
619
646
|
To keep the built-in Fable, Opus, Sonnet, and Haiku rows and append one GPT row, launch the GPT-routed Claude Code process with these variables:
|
|
620
647
|
|
|
621
648
|
```bash
|
|
@@ -628,7 +655,14 @@ CLAUDE_CODE_ATTRIBUTION_HEADER=0 \
|
|
|
628
655
|
claude
|
|
629
656
|
```
|
|
630
657
|
|
|
631
|
-
Run `/model` and select **GPT-5.6 Sol**. The custom entry is appended to the built-in rows rather than replacing them. Claude Code `2.1.
|
|
658
|
+
Run `/model` and select **GPT-5.6 Sol**. The custom entry is appended to the built-in rows rather than replacing them. Claude Code `2.1.220` recognizes this GPT model ID without a custom capability declaration: `/effort low|medium|high|xhigh|max`, the picker effort control, and `claude --effort ...` are translated from Claude Code's `output_config.effort` to the Codex reasoning effort. Claude Code Fast Mode's `speed: "fast"` is translated to the Codex `priority` service tier.
|
|
659
|
+
|
|
660
|
+
Claude Code sends `x-claude-code-session-id` for gateway request grouping. This
|
|
661
|
+
proxy hashes the exact header value into a stable `prompt_cache_key`; it does
|
|
662
|
+
not turn the header into Codex `session_id` or `thread_id` metadata. A
|
|
663
|
+
top-level `prompt_cache_key` is supported as a proxy extension and takes
|
|
664
|
+
precedence. Normal Messages requests remain stateless, so callers must send
|
|
665
|
+
full message history.
|
|
632
666
|
|
|
633
667
|
If managed settings define an `availableModels` allowlist, that list must include the exact `ANTHROPIC_CUSTOM_MODEL_OPTION` value, such as `gpt-5.6-sol`; otherwise Claude Code hides or rejects the custom row.
|
|
634
668
|
|
|
@@ -686,7 +720,7 @@ The provider handles:
|
|
|
686
720
|
## Release & package publishing
|
|
687
721
|
|
|
688
722
|
- Bump versions in `pyproject.toml`, `src/codex_as_api/__init__.py`, `src/codex_as_api/server.py`, `ts/package.json`, `ts/package-lock.json`, `rust/Cargo.toml`, and `rust/Cargo.lock`.
|
|
689
|
-
- Publish a GitHub Release such as `v0.6.
|
|
723
|
+
- Publish a GitHub Release such as `v0.6.4` from the matching commit.
|
|
690
724
|
- The manually-dispatched `Publish npm packages` workflow builds/tests the TypeScript package, runs `npm pack --dry-run`, publishes `codex-as-api` to npmjs when `NPM_TOKEN` is configured, and publishes `@eunho-j/codex-as-api` to GitHub Packages with `GITHUB_TOKEN`.
|
|
691
725
|
|
|
692
726
|
Publishing to npmjs requires an authenticated npm session (`npm login` beforehand; `npm whoami` should succeed). From the repository root, the publish itself is one command:
|
|
@@ -729,6 +763,27 @@ npm test
|
|
|
729
763
|
|
|
730
764
|
## Release Notes
|
|
731
765
|
|
|
766
|
+
### v0.6.4
|
|
767
|
+
|
|
768
|
+
- Remove process-global generated Codex session/thread identities and require
|
|
769
|
+
explicit session identity when Codex metadata mode is enabled.
|
|
770
|
+
- Resolve Chat cache affinity as explicit `prompt_cache_key`, then
|
|
771
|
+
`client_metadata.session_id`, then omission.
|
|
772
|
+
- Derive Claude Code cache affinity from `x-claude-code-session-id` without
|
|
773
|
+
fabricating Codex metadata; keep normal Anthropic Messages stateless.
|
|
774
|
+
- Validate and strip Anthropic `cache_control` compatibility hints without
|
|
775
|
+
claiming unavailable breakpoint or TTL semantics.
|
|
776
|
+
- Update current compatibility evidence to Codex `0.145.0`, Codex `main` at
|
|
777
|
+
`bd2de422aa287b97b06ca6425a10935bcf1b3731`, and Claude Code `2.1.220`.
|
|
778
|
+
|
|
779
|
+
### v0.6.3
|
|
780
|
+
|
|
781
|
+
- Accept Claude Code auxiliary requests that combine ambient `output_config.effort` with call-level `thinking.disabled`.
|
|
782
|
+
- Give explicit disabled thinking precedence and send Codex reasoning effort `none` instead of returning HTTP 400.
|
|
783
|
+
- Document and test `CODEX_AS_API_RESPONSES_LITE=off` for Claude Code hosted WebSearch on GPT-5.6; WebFetch needs no Responses Lite override.
|
|
784
|
+
- Preserve fail-loudly validation for invalid effort values and unsupported `output_config` fields.
|
|
785
|
+
- Add Python, TypeScript, and Rust adapter regressions, streamed `/v1/messages` coverage, and a `/count_tokens` regression for the WebSearch/WebFetch request shape.
|
|
786
|
+
|
|
732
787
|
### v0.6.2
|
|
733
788
|
|
|
734
789
|
- Fix `/v1/messages/count_tokens` overcounting that could trigger Claude Code autocompaction on every turn.
|
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
+
## v0.6.4
|
|
4
|
+
|
|
5
|
+
### Codex identity and cache affinity
|
|
6
|
+
|
|
7
|
+
- Remove process-global generated `session_id` and `thread_id` values from
|
|
8
|
+
Python, TypeScript, and Rust. Codex metadata mode now requires an explicit
|
|
9
|
+
non-empty `client_metadata.session_id`, defaults a root `thread_id` to that
|
|
10
|
+
session, preserves an explicit child thread, and refreshes only turn-scoped
|
|
11
|
+
identity on each request.
|
|
12
|
+
- Resolve Chat `prompt_cache_key` as explicit value, then non-empty
|
|
13
|
+
`client_metadata.session_id`, then omission. This matches Codex 0.145.0 and
|
|
14
|
+
current `main`, where the official default is Responses metadata
|
|
15
|
+
`session_id`, not `thread_id`.
|
|
16
|
+
- Retain bounded process-local Chat `previous_response_id` history replay over
|
|
17
|
+
private HTTP. The ID remains local and is never forwarded upstream.
|
|
18
|
+
|
|
19
|
+
### Claude Code session and cache compatibility
|
|
20
|
+
|
|
21
|
+
- Read `x-claude-code-session-id` on `/v1/messages` and derive a stable,
|
|
22
|
+
privacy-safe SHA-256 `prompt_cache_key`; an explicit proxy extension
|
|
23
|
+
`prompt_cache_key` takes precedence.
|
|
24
|
+
- Keep normal Anthropic Messages stateless: reject non-null
|
|
25
|
+
`previous_response_id`, disable ambient Codex metadata, avoid fabricated
|
|
26
|
+
Claude thread IDs, and remove Python's nonstandard Anthropic `response_id`.
|
|
27
|
+
- Validate Anthropic `cache_control` hints at request, system, message, content,
|
|
28
|
+
and tool locations. Accept only `type: "ephemeral"` with optional TTL `5m` or
|
|
29
|
+
`1h`, then strip the hint because the private Codex transport cannot preserve
|
|
30
|
+
Anthropic cache breakpoints or TTL behavior.
|
|
31
|
+
|
|
32
|
+
### Validation
|
|
33
|
+
|
|
34
|
+
- Python: 515 tests, mypy, and changed-file Ruff checks.
|
|
35
|
+
- TypeScript: 261 tests and production build.
|
|
36
|
+
- Rust: 253 tests and rustfmt.
|
|
37
|
+
- Re-audited `@openai/codex` 0.145.0 plus `main` at
|
|
38
|
+
`bd2de422aa287b97b06ca6425a10935bcf1b3731`, and reproduced the Claude Code
|
|
39
|
+
2.1.220 request shape.
|
|
40
|
+
|
|
41
|
+
## v0.6.3
|
|
42
|
+
|
|
43
|
+
### Claude Code WebSearch/WebFetch auxiliary calls
|
|
44
|
+
|
|
45
|
+
- Fix HTTP 400 responses when a Claude Code session with ambient effort sends a WebSearch/WebFetch auxiliary request containing both `output_config.effort` and call-level `thinking: {"type":"disabled"}`.
|
|
46
|
+
- Give explicit disabled thinking precedence over valid ambient effort and forward Codex reasoning effort `none` across Python, TypeScript, and Rust.
|
|
47
|
+
- Require and document `CODEX_AS_API_RESPONSES_LITE=off` for Claude Code hosted WebSearch on GPT-5.6 because official Responses Lite relies on a standalone `web.run` executor; WebFetch does not require this override.
|
|
48
|
+
- Continue rejecting empty, non-string, or unsupported effort values and unsupported `output_config` fields rather than silently discarding malformed requests.
|
|
49
|
+
|
|
50
|
+
### Validation
|
|
51
|
+
|
|
52
|
+
- Adapter tests cover every valid Claude Code effort value paired with disabled thinking while retaining invalid-value failures.
|
|
53
|
+
- Streamed `/v1/messages` tests across all three runtimes and a local `/count_tokens` test reproduce the Claude Code 2.1.209 request shape and prove provider-backed requests reach the classic Codex wire with reasoning effort `none`.
|
|
54
|
+
- A real GPT-5.6 Sol Codex OAuth WebSearch completed with HTTP 200 and structured `server_tool_use`, `web_search_tool_result`, and terminal SSE events.
|
|
55
|
+
|
|
3
56
|
## v0.6.2
|
|
4
57
|
|
|
5
58
|
### Claude Code count_tokens autocompact fix
|
|
@@ -9,7 +62,7 @@
|
|
|
9
62
|
- Count tool calls, tool-result identifiers, reasoning content, and normalized tool schemas once while excluding model IDs, output limits, stream flags, metadata, and other non-model request controls.
|
|
10
63
|
- Keep the existing image estimate separate so URL and inline base64 images are counted once without tokenizing the base64 payload as text.
|
|
11
64
|
- Keep token counting local and OAuth-free. No `tiktoken` package dependency or first-run encoding download is introduced.
|
|
12
|
-
- Record the upstream synchronization point as `tiktoken` 0.13.0 commit `08a5f3b2c987ada4fc5aa1f16c643c203fa8acaa`, checked on 2026-07-14, with the official rank-file SHA-256 verified
|
|
65
|
+
- Record the upstream synchronization point as `tiktoken` 0.13.0 commit `08a5f3b2c987ada4fc5aa1f16c643c203fa8acaa`, checked on 2026-07-14, with the official rank-file SHA-256 verified during release validation.
|
|
13
66
|
|
|
14
67
|
### Validation
|
|
15
68
|
|
|
@@ -341,13 +341,19 @@ def _convert_reasoning_effort(thinking: dict[str, Any] | None, output_config: ob
|
|
|
341
341
|
raise ValueError("output_config.task_budget is not supported by the Codex OAuth backend")
|
|
342
342
|
raw_effort = output_config.get("effort")
|
|
343
343
|
if raw_effort is not None:
|
|
344
|
-
if raw_effort not in {
|
|
344
|
+
if not isinstance(raw_effort, str) or raw_effort not in {
|
|
345
|
+
"low",
|
|
346
|
+
"medium",
|
|
347
|
+
"high",
|
|
348
|
+
"xhigh",
|
|
349
|
+
"max",
|
|
350
|
+
}:
|
|
345
351
|
raise ValueError("output_config.effort must be one of: low, medium, high, xhigh, max")
|
|
346
352
|
output_effort = raw_effort
|
|
347
353
|
|
|
348
354
|
thinking_effort = _convert_thinking(thinking)
|
|
349
|
-
if thinking_effort == "none"
|
|
350
|
-
|
|
355
|
+
if thinking_effort == "none":
|
|
356
|
+
return "none"
|
|
351
357
|
return output_effort or thinking_effort
|
|
352
358
|
|
|
353
359
|
|
|
@@ -23,8 +23,6 @@ _PROJECT_ROOT = pathlib.Path(__file__).resolve().parents[2]
|
|
|
23
23
|
_CAPABILITIES_PATH = _PROJECT_ROOT / "config" / "model-capabilities.json"
|
|
24
24
|
_PACKAGE_CAPABILITIES_PATH = pathlib.Path(__file__).resolve().with_name("model-capabilities.json")
|
|
25
25
|
_INSTALLATION_NAMESPACE = uuid.UUID("d2c81270-8f15-5e8d-a5c4-4cdbf2c21fd0")
|
|
26
|
-
_SESSION_ID = str(uuid.uuid4())
|
|
27
|
-
_THREAD_ID = str(uuid.uuid4())
|
|
28
26
|
_WINDOW_ID = str(uuid.uuid4())
|
|
29
27
|
|
|
30
28
|
ResponsesLiteMode = Literal["off", "on", "auto"]
|
|
@@ -157,14 +155,23 @@ def build_codex_client_metadata(
|
|
|
157
155
|
existing: Mapping[str, str] | None,
|
|
158
156
|
) -> dict[str, str]:
|
|
159
157
|
metadata = dict(existing or {})
|
|
158
|
+
session_id = metadata.get(SESSION_ID_KEY)
|
|
159
|
+
if not isinstance(session_id, str) or not session_id.strip():
|
|
160
|
+
raise ValueError("codex_metadata requires a non-empty client_metadata.session_id")
|
|
161
|
+
thread_id = metadata.get(THREAD_ID_KEY)
|
|
162
|
+
if thread_id is None:
|
|
163
|
+
thread_id = session_id
|
|
164
|
+
elif not isinstance(thread_id, str) or not thread_id.strip():
|
|
165
|
+
raise ValueError("client_metadata.thread_id must be a non-empty string when provided")
|
|
166
|
+
|
|
160
167
|
auth_path = pathlib.Path(auth_json_path or "~/.codex/auth.json").expanduser()
|
|
161
168
|
absolute_path = os.path.abspath(os.fspath(auth_path))
|
|
162
169
|
installation_id = str(uuid.uuid5(_INSTALLATION_NAMESPACE, f"codex-as-api:{absolute_path}"))
|
|
163
170
|
turn_id = str(uuid.uuid4())
|
|
164
171
|
turn_metadata = {
|
|
165
172
|
"installation_id": installation_id,
|
|
166
|
-
"session_id":
|
|
167
|
-
"thread_id":
|
|
173
|
+
"session_id": session_id,
|
|
174
|
+
"thread_id": thread_id,
|
|
168
175
|
"turn_id": turn_id,
|
|
169
176
|
"window_id": _WINDOW_ID,
|
|
170
177
|
"source": "codex-as-api",
|
|
@@ -172,8 +179,8 @@ def build_codex_client_metadata(
|
|
|
172
179
|
metadata.update(
|
|
173
180
|
{
|
|
174
181
|
INSTALLATION_ID_KEY: installation_id,
|
|
175
|
-
SESSION_ID_KEY:
|
|
176
|
-
THREAD_ID_KEY:
|
|
182
|
+
SESSION_ID_KEY: session_id,
|
|
183
|
+
THREAD_ID_KEY: thread_id,
|
|
177
184
|
TURN_ID_KEY: turn_id,
|
|
178
185
|
WINDOW_ID_KEY: _WINDOW_ID,
|
|
179
186
|
TURN_METADATA_KEY: json.dumps(turn_metadata, separators=(",", ":"), sort_keys=True),
|
|
@@ -27,6 +27,7 @@ from .model_capabilities import (
|
|
|
27
27
|
LITE_HEADER_NAME,
|
|
28
28
|
LITE_HEADER_VALUE,
|
|
29
29
|
RESPONSES_LITE_ENV,
|
|
30
|
+
SESSION_ID_KEY,
|
|
30
31
|
apply_model_capability_fields,
|
|
31
32
|
build_codex_client_metadata,
|
|
32
33
|
capability_for_model,
|
|
@@ -753,18 +754,27 @@ class ChatGPTOAuthProvider:
|
|
|
753
754
|
}
|
|
754
755
|
if any(tool.get("type") == "web_search" for tool in payload["tools"]):
|
|
755
756
|
payload["include"] = ["web_search_call.action.sources"]
|
|
756
|
-
if
|
|
757
|
+
metadata = dict(client_metadata) if client_metadata is not None else None
|
|
758
|
+
if resolve_codex_metadata_enabled(codex_metadata):
|
|
759
|
+
try:
|
|
760
|
+
metadata = build_codex_client_metadata(
|
|
761
|
+
auth_json_path=self.auth_json_path,
|
|
762
|
+
existing=metadata,
|
|
763
|
+
)
|
|
764
|
+
except ValueError as exc:
|
|
765
|
+
raise ChatGPTOAuthInvalidRequestError(str(exc)) from exc
|
|
766
|
+
effective_prompt_cache_key = prompt_cache_key
|
|
767
|
+
if effective_prompt_cache_key is None and metadata is not None:
|
|
768
|
+
session_id = metadata.get(SESSION_ID_KEY)
|
|
769
|
+
if isinstance(session_id, str) and session_id.strip():
|
|
770
|
+
effective_prompt_cache_key = session_id
|
|
771
|
+
if effective_prompt_cache_key is not None:
|
|
757
772
|
payload["prompt_cache_key"] = _validate_non_empty_string(
|
|
758
|
-
|
|
773
|
+
effective_prompt_cache_key,
|
|
759
774
|
"prompt_cache_key",
|
|
760
775
|
)
|
|
761
|
-
if
|
|
762
|
-
payload["client_metadata"] =
|
|
763
|
-
if resolve_codex_metadata_enabled(codex_metadata):
|
|
764
|
-
payload["client_metadata"] = build_codex_client_metadata(
|
|
765
|
-
auth_json_path=self.auth_json_path,
|
|
766
|
-
existing=payload.get("client_metadata") if isinstance(payload.get("client_metadata"), dict) else None,
|
|
767
|
-
)
|
|
776
|
+
if metadata is not None:
|
|
777
|
+
payload["client_metadata"] = metadata
|
|
768
778
|
_finalize_responses_payload(
|
|
769
779
|
payload,
|
|
770
780
|
model=request_model,
|