You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 41f1d17
Browse filesBrowse the repository at this point in the historyBrowse files
* feat: dynamically refresh Anthropic model list (#46)
* feat: dynamically refresh Anthropic model list
* fix: harden /v1/models cache and resolve default model live
- Lock + double-check refresh path so concurrent requests at TTL
expiry don't stampede the Anthropic Models API.
- Use a short MODEL_LIST_ERROR_TTL_SECONDS (default 60s) for the
fallback cache so transient outages don't suppress live discovery
for a full hour.
- Populate `created` (unix timestamp) on both live and fallback
/v1/models entries to match OpenAI's model object schema.
- Resolve DEFAULT_MODEL at startup by picking the latest Sonnet from
the live Models API; honor explicit DEFAULT_MODEL env override.
* docs: clarify ANTHROPIC_API_KEY is optional for live model discovery
- README: expand env vars table with ANTHROPIC_API_KEY (optional),
DEFAULT_MODEL, FAST_MODEL, CLAUDE_MODELS_OVERRIDE, and the model
list cache/timeout knobs. Rewrite the Supported Models section to
explain the live-vs-static behavior and refresh the catalog around
Claude 4.6 family. Bump model examples to claude-sonnet-4-6.
- .env.example: add a Model Discovery (optional) block documenting
ANTHROPIC_API_KEY, CLAUDE_MODELS_OVERRIDE, and the cache TTLs;
comment out DEFAULT_MODEL so live resolution drives it by default.
- main.py: log a single explicit info line at startup when live
discovery is disabled (no ANTHROPIC_API_KEY) so operators see
whether the dynamic path activated.
- tests: cover the new disabled-path log and update the env-key gate
in the existing resolve_default_model test.
* chore(v2.9.6): SDK 0.1.81 bump, urllib3/python-multipart sec fixes, SDK-drift workflow auto-PR
- claude-agent-sdk 0.1.68 -> 0.1.81 (13 patch releases since v2.9.5).
- python-multipart ^0.0.26 -> ^0.0.27 (GHSA-pp6c-gr5w-3c5g, supersedes Dependabot PR #16).
- urllib3 security floor >=2.6.3 -> >=2.7.0 (GHSA-qccp-gfcp-xxvc, GHSA-mf9v-mfxr-j63j).
- check-sdk-version.yml opens a draft chore/sdk-bump-<latest> PR on drift instead
of only writing to the run summary. Permissions widened to contents: write +
pull-requests: write; idempotent by head branch; fallback summary still fires.
Lockfile regenerated locally with Poetry 2.3.4. Full suite at 664 passed, 31 skipped
(+14 from upstream test_dynamic_models.py picked up in the prior cherry-pick).
* docs(readme): bump to v2.9.6, document new model-discovery env vars, tighten supported-models intro
- Version 2.9.3 -> 2.9.6 in header and docker pin example
- Test count 650 -> 664 in Status and Testing sections
- Add 2.9.6 highlight bullet covering SDK 0.1.81, urllib3/python-multipart sec
fixes, upstream PR #46 dynamic-models sync, and check-sdk-version auto-PR
- Add ANTHROPIC_MODELS_URL, ANTHROPIC_VERSION, ANTHROPIC_BETA/ANTHROPIC_BETA_HEADER
rows to the env var table (advanced overrides for the new live-discovery path)
- Tighten the Supported Models intro paragraph (was 3 dense sentences)
---------
Co-authored-by: Richard A <richardatk01@gmail.com>
--body "Automated bump opened by the \`Check claude-agent-sdk version\` workflow.
135
+
136
+
Bumps the SDK pin in \`pyproject.toml\` from \`$PINNED\` to \`$LATEST\` and regenerates \`poetry.lock\`. Scope is deliberately limited to the pin + lock so the human reviewer owns the release coordination.
- [ ] Bump version in \`pyproject.toml\` \`[tool.poetry] version\` and \`src/__init__.py\`
146
+
- [ ] Add a new \`## [x.y.z]\` section to \`CHANGELOG.md\` describing this bump
147
+
- [ ] Confirm the \`[otel]\` extra is still present on the pin (the SDK unconditionally imports \`opentelemetry.propagate\`)
148
+
- [ ] Push an empty commit (\`git commit --allow-empty\`) so the test matrix fires: PRs opened with the default \`GITHUB_TOKEN\` do not trigger downstream \`pull_request\` workflow runs by design
149
+
- [ ] Confirm all CI checks pass
150
+
151
+
Mark the PR ready for review once the items above are in place."
152
+
153
+
- name: Write drift summary
154
+
if: steps.compare.outputs.up_to_date == 'false'
155
+
env:
156
+
PINNED: ${{ steps.compare.outputs.pinned }}
157
+
LATEST: ${{ steps.compare.outputs.latest }}
158
+
BRANCH: ${{ steps.existing.outputs.branch }}
159
+
PR_EXISTS: ${{ steps.existing.outputs.exists }}
65
160
run: |
66
161
set -euo pipefail
67
162
{
@@ -72,9 +167,15 @@ jobs:
72
167
echo "| Pinned | \`$PINNED\` |"
73
168
echo "| Latest on PyPI | \`$LATEST\` |"
74
169
echo
170
+
if [ "$PR_EXISTS" = "true" ]; then
171
+
echo "An open PR for branch \`$BRANCH\` already exists; no new PR was opened."
echo "Review the release notes, run \`poetry lock\` after bumping the pin, and verify the full test suite before merging. The SDK unconditionally imports \`opentelemetry.propagate\`, so keep the \`[otel]\` extra on the pin."
180
+
echo "The SDK unconditionally imports \`opentelemetry.propagate\`, so keep the \`[otel]\` extra on the pin."
Copy file name to clipboardExpand all lines: README.md
+35-7Lines changed: 35 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,20 @@ OpenAI API-compatible wrapper for Claude Code. Drop it in front of any OpenAI cl
4
4
5
5
## Version
6
6
7
-
**Current:** 2.9.3
7
+
**Current:** 2.9.6
8
8
9
9
Highlights of recent releases (full history in [CHANGELOG.md](./CHANGELOG.md)):
10
10
11
-
-**2.9.x** - CodeQL hardening: sanitised error responses (no more `str(e)` to clients), `filter_content` rewrite against polynomial ReDoS, `/v1/debug/request` gated behind `DEBUG_MODE`/`VERBOSE`, workflow permissions pinned. Image trimmed to 775 MB (`poetry install --only main`, `.dockerignore`). `claude-agent-sdk` pinned to 0.1.65 with the `[otel]` extra.
11
+
-**2.9.6** - `claude-agent-sdk` 0.1.68 -> 0.1.81. urllib3 floor raised to 2.7.0 and `python-multipart` to 0.0.27 to close three HIGH Dependabot alerts. Pulled in upstream `RichardAtCT#46` so `/v1/models` returns Anthropic's live catalogue when `ANTHROPIC_API_KEY` is set (cached, with a short error TTL so transient outages do not stick for an hour). `check-sdk-version.yml` now opens a draft bump PR on drift instead of writing only to the job summary.
12
+
-**2.9.x** (earlier) - CodeQL hardening: sanitised error responses (no more `str(e)` to clients), `filter_content` rewrite against polynomial ReDoS, `/v1/debug/request` gated behind `DEBUG_MODE`/`VERBOSE`, workflow permissions pinned. Image trimmed via `poetry install --only main` and a real `.dockerignore`.
12
13
-**2.8.x** - Security dep bumps, breaker defaults loosened, CLI stderr capture, structured-log state unmasked.
-**2.6.0** - OpenAI function calling simulation (`tools` / `tool_choice`), JSON schema support in `response_format`, real-time streaming fence stripping, CPU watchdog.
15
16
-**2.5.x** - Landing-page redesign, model catalogue from the open-sourced Claude Code source, 41 tools tracked, retry + model fallback, cost tracking, `X-Claude-Effort` / `X-Claude-Thinking` headers.
16
17
17
18
## Status
18
19
19
-
Production ready. **650 tests passing (31 skipped)**. Streaming works. Sessions work. JSON mode works. Function calling works. Tools are off by default for speed - pass `enable_tools: true` to turn them on. Auth supports API key, Bedrock, Vertex AI, and CLI.
20
+
Production ready. **664 tests passing (31 skipped)**. Streaming works. Sessions work. JSON mode works. Function calling works. Tools are off by default for speed - pass `enable_tools: true` to turn them on. Auth supports API key, Bedrock, Vertex AI, and CLI.
20
21
21
22
## Quick Start
22
23
@@ -127,7 +128,7 @@ docker run -d -p 8000:8000 \
127
128
docker run -d -p 8000:8000 \
128
129
-v ~/.claude:/root/.claude \
129
130
--name claude-wrapper \
130
-
ttlequals0/claude-code-openai-wrapper:2.9.3
131
+
ttlequals0/claude-code-openai-wrapper:2.9.6
131
132
132
133
# Or build locally (prod stage is the default target)
| `API_KEY` | Require this key on every request; prompts at startup if unset | interactive prompt |
177
-
| `ANTHROPIC_API_KEY` | Direct API key (for `api_key` auth) | - |
178
+
| `ANTHROPIC_API_KEY` | Direct API key (for `api_key` auth). Optional — also unlocks live `/v1/models` discovery and dynamic latest-Sonnet default. | - |
| `DEFAULT_MODEL` | Default model id when request omits one | `claude-sonnet-4-6` |
183
+
| `DEFAULT_MODEL` | Default model id when request omits one. When unset and `ANTHROPIC_API_KEY` is configured, the wrapper resolves the latest Sonnet at startup; otherwise falls back to `claude-sonnet-4-6`. | auto |
184
+
| `FAST_MODEL` | Speed/cost-optimized model alias used internally. | `claude-haiku-4-5-20251001` |
185
+
| `CLAUDE_MODELS_OVERRIDE` | Comma-separated model IDs to advertise via `/v1/models`. Takes precedence over both live and static lists. | - |
186
+
| `MODEL_LIST_CACHE_TTL_SECONDS` | Cache TTL for live `/v1/models` results. | `3600` |
187
+
| `MODEL_LIST_ERROR_TTL_SECONDS` | Short cache TTL applied when the live fetch fails so transient outages don't suppress live discovery for the full hour. | `60` |
188
+
| `MODEL_LIST_REQUEST_TIMEOUT_SECONDS` | HTTP timeout for the live model fetch (seconds). | `5` |
189
+
| `ANTHROPIC_MODELS_URL` | Override the live models endpoint. Point at a proxy or staging URL during testing. | `https://api.anthropic.com/v1/models` |
190
+
| `ANTHROPIC_VERSION` | `anthropic-version` header sent to the Models API. | `2023-06-01` |
191
+
| `ANTHROPIC_BETA` / `ANTHROPIC_BETA_HEADER` | Optional `anthropic-beta` header forwarded to the Models API for beta-gated features. | - |
{"role": "user", "content": "Write a Python hello world script"}
227
+
],
228
+
"stream": true
229
+
}'
230
+
209
231
```
210
232
211
233
### OpenAI Python SDK
@@ -266,6 +288,8 @@ Claude-specific options via HTTP headers:
266
288
267
289
Model IDs, context windows, and pricing are sourced from the Anthropic models docs (`platform.claude.com/docs/en/about-claude/models/overview`) and mirrored in `src/constants.py`.
268
290
291
+
With `ANTHROPIC_API_KEY` set, `/v1/models` returns Anthropic's live catalogue (cached for `MODEL_LIST_CACHE_TTL_SECONDS`, default 1 hour) and the wrapper picks the latest Sonnet as `DEFAULT_MODEL` at startup. Without it (Bedrock, Vertex, or Claude CLI auth), the static list below is served and `claude-sonnet-4-6` is the fallback. `CLAUDE_MODELS_OVERRIDE=a,b,c` pins the list regardless of auth.
292
+
269
293
### Latest
270
294
| Model | Context | Max Output | Input $/MTok | Output $/MTok |
0 commit comments