Skip to content

Commit 41f1d17

Browse files
fix(v2.9.6): SDK 0.1.81, urllib3/python-multipart sec fixes, dynamic models from upstream, SDK-drift auto-PR (#17)
* 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>
1 parent fe32380 commit 41f1d17

12 files changed

Lines changed: 743 additions & 68 deletions

‎.env.example‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,36 @@ MAX_TIMEOUT=600000
2525
CORS_ORIGINS=["*"]
2626

2727
# Model Configuration
28-
# Default Claude model to use when none specified in request
29-
DEFAULT_MODEL=claude-sonnet-4-6
28+
# Default Claude model to use when none specified in request.
29+
# When unset AND ANTHROPIC_API_KEY is configured, the wrapper resolves the
30+
# latest Sonnet from Anthropic's live Models API at startup. Otherwise it
31+
# falls back to claude-sonnet-4-6.
32+
# DEFAULT_MODEL=claude-sonnet-4-6
33+
34+
# Speed/cost-optimized model alias.
35+
# FAST_MODEL=claude-haiku-4-5-20251001
36+
37+
# Model Discovery (optional)
38+
# ANTHROPIC_API_KEY unlocks two best-effort enhancements:
39+
# 1. /v1/models returns Anthropic's live model list (cached for 1 hour)
40+
# 2. DEFAULT_MODEL resolves to the latest Sonnet at startup
41+
# It is NOT required to run the wrapper - Bedrock, Vertex, and Claude CLI
42+
# subscription auth all work without it; /v1/models then returns the static
43+
# fallback list.
44+
# ANTHROPIC_API_KEY=sk-ant-...
45+
46+
# Pin the advertised model list. Takes precedence over both live and static.
47+
# CLAUDE_MODELS_OVERRIDE=claude-sonnet-4-6,claude-opus-4-6
48+
49+
# Cache TTL for live /v1/models results (seconds).
50+
# MODEL_LIST_CACHE_TTL_SECONDS=3600
51+
52+
# Short cache TTL when the live fetch fails so transient outages don't
53+
# suppress live discovery for the full hour.
54+
# MODEL_LIST_ERROR_TTL_SECONDS=60
55+
56+
# HTTP timeout for the live model fetch.
57+
# MODEL_LIST_REQUEST_TIMEOUT_SECONDS=5
3058

3159
# Rate Limiting Configuration
3260
RATE_LIMIT_ENABLED=true

‎.github/workflows/check-sdk-version.yml‎

Lines changed: 115 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,39 @@ name: Check claude-agent-sdk version
22

33
# Belt-and-suspenders on top of Dependabot: every Monday, fetch the
44
# latest claude-agent-sdk release from PyPI and compare to the pin in
5-
# pyproject.toml. If we are behind, emit a warning annotation and
6-
# write the drift to the run's job summary. Also runnable manually.
5+
# pyproject.toml. If we are behind, open a draft PR with the pin bump
6+
# and regenerated poetry.lock so a human reviewer just adds the version
7+
# bump + CHANGELOG entry before merging. Also runnable manually.
78
#
8-
# Issues are disabled on this repo, so we surface drift via the
9-
# Actions run page rather than the Issues tab. Dependabot already
10-
# opens PRs for SDK bumps; this workflow's job is just to make sure
11-
# the drift doesn't go unnoticed if Dependabot misses it.
9+
# Idempotent: skips PR creation when an open PR for that head branch
10+
# already exists. Job summary fallback runs unconditionally on drift
11+
# so the run page always carries the version delta even if PR creation
12+
# can't run (existing PR, branch conflict, etc.).
1213
#
13-
# Only event sources are schedule + workflow_dispatch; no user-
14-
# controlled event payload is interpolated into run blocks.
14+
# Workflow injection notes: schedule + workflow_dispatch are the only
15+
# event sources, so no user-controlled event payload is involved. The
16+
# values flowing into run blocks (pinned, latest, branch) are derived
17+
# from pyproject.toml and pypi.org JSON, and are passed via env: so
18+
# they never reach the shell via ${{ }} expression interpolation.
1519

1620
on:
1721
schedule:
1822
- cron: "0 14 * * 1" # Mondays 14:00 UTC
1923
workflow_dispatch:
2024

2125
permissions:
22-
contents: read
26+
contents: write
27+
pull-requests: write
2328

2429
jobs:
2530
check:
2631
runs-on: ubuntu-latest
27-
timeout-minutes: 5
32+
timeout-minutes: 10
2833
steps:
2934
- uses: actions/checkout@v4
3035

3136
- name: Compare pinned SDK vs latest PyPI release
3237
id: compare
33-
env:
34-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3538
run: |
3639
set -euo pipefail
3740
@@ -57,11 +60,103 @@ jobs:
5760
echo "::warning::claude-agent-sdk pin ($pinned) is behind latest PyPI release ($latest)."
5861
fi
5962
60-
- name: Write drift summary when behind
63+
- name: Set up Python
64+
if: steps.compare.outputs.up_to_date == 'false'
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: "3.12"
68+
69+
- name: Install Poetry
70+
if: steps.compare.outputs.up_to_date == 'false'
71+
run: pipx install poetry==2.3.4
72+
73+
- name: Check for existing bump PR
74+
id: existing
6175
if: steps.compare.outputs.up_to_date == 'false'
6276
env:
77+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
LATEST: ${{ steps.compare.outputs.latest }}
79+
run: |
80+
set -euo pipefail
81+
branch="chore/sdk-bump-${LATEST}"
82+
echo "branch=$branch" >> "$GITHUB_OUTPUT"
83+
if [ -n "$(gh pr list --state open --head "$branch" --json number --jq '.[0].number')" ]; then
84+
echo "exists=true" >> "$GITHUB_OUTPUT"
85+
echo "An open PR already exists for $branch; skipping create step."
86+
else
87+
echo "exists=false" >> "$GITHUB_OUTPUT"
88+
fi
89+
90+
- name: Bump pin, regenerate lock, and open draft PR
91+
if: steps.compare.outputs.up_to_date == 'false' && steps.existing.outputs.exists == 'false'
92+
env:
93+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6394
PINNED: ${{ steps.compare.outputs.pinned }}
6495
LATEST: ${{ steps.compare.outputs.latest }}
96+
BRANCH: ${{ steps.existing.outputs.branch }}
97+
run: |
98+
set -euo pipefail
99+
100+
git config user.name "github-actions[bot]"
101+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
102+
git checkout -b "$BRANCH"
103+
104+
python3 - <<'PY'
105+
import os, pathlib, re
106+
latest = os.environ["LATEST"]
107+
path = pathlib.Path("pyproject.toml")
108+
text = path.read_text()
109+
# Prefer the table form first (which carries the [otel] extras).
110+
table_pat = re.compile(
111+
r'(claude-agent-sdk\s*=\s*\{[^}]*version\s*=\s*")[^"]+(")'
112+
)
113+
new_text, n = table_pat.subn(r'\g<1>' + latest + r'\g<2>', text, count=1)
114+
if n == 0:
115+
# Fall back to the plain-string form.
116+
string_pat = re.compile(r'(claude-agent-sdk\s*=\s*")[^"]+(")')
117+
new_text, n = string_pat.subn(r'\g<1>' + latest + r'\g<2>', text, count=1)
118+
if n == 0:
119+
raise SystemExit("Failed to update claude-agent-sdk pin in pyproject.toml")
120+
path.write_text(new_text)
121+
PY
122+
123+
poetry lock --no-interaction
124+
125+
git add pyproject.toml poetry.lock
126+
git commit -m "chore(deps): bump claude-agent-sdk $PINNED -> $LATEST"
127+
git push origin "$BRANCH"
128+
129+
gh pr create \
130+
--draft \
131+
--base main \
132+
--head "$BRANCH" \
133+
--title "chore(deps): bump claude-agent-sdk $PINNED -> $LATEST" \
134+
--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.
137+
138+
References:
139+
- Release notes: https://github.com/anthropics/claude-agent-sdk-python/releases/tag/v$LATEST
140+
- Full changelog: https://github.com/anthropics/claude-agent-sdk-python/compare/v$PINNED...v$LATEST
141+
- PyPI: https://pypi.org/project/claude-agent-sdk/$LATEST/
142+
143+
Reviewer checklist before merging:
144+
145+
- [ ] 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 }}
65160
run: |
66161
set -euo pipefail
67162
{
@@ -72,9 +167,15 @@ jobs:
72167
echo "| Pinned | \`$PINNED\` |"
73168
echo "| Latest on PyPI | \`$LATEST\` |"
74169
echo
170+
if [ "$PR_EXISTS" = "true" ]; then
171+
echo "An open PR for branch \`$BRANCH\` already exists; no new PR was opened."
172+
else
173+
echo "Opened draft PR on branch \`$BRANCH\`."
174+
fi
175+
echo
75176
echo "Release notes: https://github.com/anthropics/claude-agent-sdk-python/releases/tag/v$LATEST"
76177
echo "Full changelog: https://github.com/anthropics/claude-agent-sdk-python/compare/v$PINNED...v$LATEST"
77178
echo "PyPI: https://pypi.org/project/claude-agent-sdk/$LATEST/"
78179
echo
79-
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."
80181
} >> "$GITHUB_STEP_SUMMARY"

‎CHANGELOG.md‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,59 @@ All notable changes to the Claude Code OpenAI Wrapper project will be documented
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.9.6] - 2026-05-11
9+
10+
### Changed
11+
12+
- `claude-agent-sdk`: 0.1.68 -> 0.1.81. Thirteen patch releases since
13+
the v2.9.5 cut. Pin keeps the `[otel]` extra (the SDK still imports
14+
`opentelemetry.propagate` unconditionally).
15+
- Sync upstream `RichardAtCT/claude-code-openai-wrapper#46`: dynamic
16+
Anthropic Models API integration for `/v1/models`. When
17+
`ANTHROPIC_API_KEY` is set the endpoint returns Anthropic's live
18+
model list (cached `MODEL_LIST_CACHE_TTL_SECONDS`, default 3600s)
19+
and the wrapper resolves the latest Sonnet as `DEFAULT_MODEL` at
20+
startup. When the key is absent (Bedrock, Vertex, Claude CLI
21+
subscription auth) the existing static catalog is served and
22+
`DEFAULT_MODEL_FALLBACK=claude-sonnet-4-6` is used.
23+
`CLAUDE_MODELS_OVERRIDE` pins the advertised list regardless of
24+
auth. Concurrent cache refreshes are serialized via an async lock +
25+
double-check pattern; failed fetches use a short
26+
`MODEL_LIST_ERROR_TTL_SECONDS` (default 60s) to keep transient
27+
outages from suppressing live discovery for a full hour. The
28+
pre-existing `model_service` (used by `/v1/models/refresh` and
29+
`/v1/models/status`) is left in place alongside the new in-line
30+
cache.
31+
32+
### Security
33+
34+
- `python-multipart`: ^0.0.26 -> ^0.0.27 (closes Dependabot alert #8,
35+
`GHSA-pp6c-gr5w-3c5g` Denial of Service via unbounded multipart
36+
part headers). Supersedes Dependabot PR #16, which was opened with
37+
a Poetry 2.2.1 lockfile that would have introduced cosmetic
38+
regressions in the lock header and constraint formatting.
39+
- `urllib3` security floor: >=2.6.3 -> >=2.7.0 (closes Dependabot
40+
alerts #9 `GHSA-mf9v-mfxr-j63j` decompression-bomb safeguard
41+
bypass and #10 `GHSA-qccp-gfcp-xxvc` proxy redirect header leak).
42+
43+
### CI
44+
45+
- `check-sdk-version.yml`: when drift is detected the workflow now
46+
opens a draft `chore/sdk-bump-<latest>` PR with the pin bump and
47+
regenerated `poetry.lock` instead of only writing to the run
48+
summary. The Monday cron pre-stages the upgrade; a human reviewer
49+
bumps the project version, adds a CHANGELOG entry, and merges. The
50+
existing `::warning::` annotation and `$GITHUB_STEP_SUMMARY` block
51+
still fire as a fallback when PR creation can't run (existing
52+
open PR for that pin, branch conflict, etc.). Idempotent by head
53+
branch name. Permissions widened to `contents: write` and
54+
`pull-requests: write`.
55+
56+
### Tests
57+
58+
Full suite at 664 passed, 31 skipped (+14 from the upstream
59+
`test_dynamic_models.py` suite added by PR #46).
60+
861
## [2.9.5] - 2026-04-27
962

1063
### Changed

‎README.md‎

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ OpenAI API-compatible wrapper for Claude Code. Drop it in front of any OpenAI cl
44

55
## Version
66

7-
**Current:** 2.9.3
7+
**Current:** 2.9.6
88

99
Highlights of recent releases (full history in [CHANGELOG.md](./CHANGELOG.md)):
1010

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`.
1213
- **2.8.x** - Security dep bumps, breaker defaults loosened, CLI stderr capture, structured-log state unmasked.
1314
- **2.7.0** - Added `claude-opus-4-7`; retired `claude-3-*` family; corrected context-window and max-output metadata.
1415
- **2.6.0** - OpenAI function calling simulation (`tools` / `tool_choice`), JSON schema support in `response_format`, real-time streaming fence stripping, CPU watchdog.
1516
- **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.
1617

1718
## Status
1819

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.
2021

2122
## Quick Start
2223

@@ -127,7 +128,7 @@ docker run -d -p 8000:8000 \
127128
docker run -d -p 8000:8000 \
128129
-v ~/.claude:/root/.claude \
129130
--name claude-wrapper \
130-
ttlequals0/claude-code-openai-wrapper:2.9.3
131+
ttlequals0/claude-code-openai-wrapper:2.9.6
131132

132133
# Or build locally (prod stage is the default target)
133134
docker build --platform linux/amd64 -t claude-wrapper:local .
@@ -174,12 +175,20 @@ Listed in roughly the order you will reach for them.
174175
| `CLAUDE_CWD` | Working directory Claude Code runs in | isolated temp dir |
175176
| `CLAUDE_AUTH_METHOD` | `cli`, `api_key`, `bedrock`, `vertex` | auto-detect |
176177
| `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. | - |
178179
| `CLAUDE_CODE_USE_BEDROCK` | Enable AWS Bedrock backend | `false` |
179180
| `AWS_REGION` / `AWS_DEFAULT_REGION` / `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` | Bedrock credentials | - |
180181
| `CLAUDE_CODE_USE_VERTEX` | Enable Google Vertex AI backend | `false` |
181182
| `ANTHROPIC_VERTEX_PROJECT_ID` / `CLOUD_ML_REGION` / `GOOGLE_APPLICATION_CREDENTIALS` | Vertex credentials | - |
182-
| `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. | - |
183192
| `DEBUG_MODE` | Enable debug logging and unlock `/v1/debug/request` | `false` |
184193
| `VERBOSE` | Same unlock effect on `/v1/debug/request` | `false` |
185194
| `CORS_ORIGINS` | Allowed CORS origins (JSON array) | `["*"]` |
@@ -206,6 +215,19 @@ curl -X POST http://localhost:8000/v1/chat/completions \
206215
{"role": "user", "content": "What is 2 + 2?"}
207216
]
208217
}'
218+
219+
# With API key protection (when enabled)
220+
curl -X POST http://localhost:8000/v1/chat/completions \
221+
-H "Content-Type: application/json" \
222+
-H "Authorization: Bearer your-generated-api-key" \
223+
-d '{
224+
"model": "claude-sonnet-4-6",
225+
"messages": [
226+
{"role": "user", "content": "Write a Python hello world script"}
227+
],
228+
"stream": true
229+
}'
230+
209231
```
210232

211233
### OpenAI Python SDK
@@ -266,6 +288,8 @@ Claude-specific options via HTTP headers:
266288

267289
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`.
268290

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+
269293
### Latest
270294
| Model | Context | Max Output | Input $/MTok | Output $/MTok |
271295
|-------|---------|-----------|-------------|--------------|
@@ -287,6 +311,8 @@ Model IDs, context windows, and pricing are sourced from the Anthropic models do
287311
| `claude-sonnet-4-20250514` | 200K | 64K | $3 | $15 | `claude-sonnet-4-6` |
288312
| `claude-opus-4-20250514` | 200K | 32K | $15 | $75 | `claude-opus-4-7` |
289313

314+
**Note:** Claude 3.x models are not supported by the Claude Agent SDK.
315+
290316
## Session Continuity
291317

292318
Pass a `session_id` to keep conversation context across requests:
@@ -313,6 +339,8 @@ Sessions expire after 1 hour of inactivity. Management endpoints:
313339
- `DELETE /v1/sessions/{id}` - delete session
314340
- `GET /v1/sessions/stats` - session statistics
315341

342+
See `examples/session_continuity.py` for Python and curl examples.
343+
316344
## API Endpoints
317345

318346
### Core API
@@ -423,7 +451,7 @@ With `json_object` mode, the wrapper adds system prompt instructions for JSON ou
423451
## Testing
424452

425453
```bash
426-
# Run the full test suite (650 tests, ~3 s on a laptop)
454+
# Run the full test suite (664 tests, ~3 s on a laptop)
427455
poetry run pytest tests/
428456
429457
# Quick endpoint test (server must be running)

0 commit comments

Comments
 (0)