feat(batch): name api_key_cap_reached and expose failure_detail on runs stopped by an API key credit cap - #27
Merged
Conversation
…old apart from an empty account, so the SDK now knows api_key_cap_reached and exposes failure_detail Syncs docs/openapi.yaml from the Batch API spec and regenerates the models: FailureReason gains api_key_cap_reached, Run gains failure_detail, and the WebhookEvent / WebhookEventType schemas are modelled. BatchAPIError exposes the problem detail, and the README documents the 402 api_key_cap_reached code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r failure_detail note Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…terminal, so wait_for_run polled until its timeout
Add `failed` to TERMINAL_RUN_STATUSES so the default waiters return the
failed run with failure_reason/failure_detail. A status named in
failure_statuses now takes precedence over the targets, so
failure_statuses={"failed"} still raises WaiterError. Rerun docs now
list failed as a valid prior state, matching the spec. Regenerated the
reference doc, which also picks up earlier docstring drift on this
branch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lr2QdqhUNrX6q4DRLGeTMY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A Batch run that stops because its API key reached a credit cap reports
failure_reason: "api_key_cap_reached"and a human-readablefailure_detail(which cap, and when it resets). Since #25 the SDK no longer crashes on that value, but it parses it as unknown and dropsfailure_detail, so callers can't tell a capped key from an empty account or show when to retry.What
FailureReason.API_KEY_CAP_REACHED.Run.failure_detail(optional, at most 500 characters).WebhookEvent/WebhookEventTypecarryfailure_reasonandfailure_detailforrun.failed.BatchAPIError.detail, and README/docstring notes on the 402api_key_cap_reachedproblem code.docs/openapi.yamlsynced with the Batch API spec; models regenerated (CI drift check passes).Verification
make test: 173 passed.make check(ruff, format, ty): clean. Regenerating the models leaves no diff.failure_detailround-trips, and a 402 surfaces its code and detail.No version bump (the release sets it).
🤖 Generated with Claude Code