Skip to content

feat(batch): name api_key_cap_reached and expose failure_detail on runs stopped by an API key credit cap - #27

Merged
AnderRV merged 3 commits into
mainfrom
feat/batch-api-key-cap-reached
Oct 2, 2026
Merged

AnderRV merged 3 commits into
mainfrom
feat/batch-api-key-cap-reached

Conversation

@AnderRV

@AnderRV AnderRV commented Oct 1, 2026

Copy link
Copy Markdown
Member

Why

A Batch run that stops because its API key reached a credit cap reports failure_reason: "api_key_cap_reached" and a human-readable failure_detail (which cap, and when it resets). Since #25 the SDK no longer crashes on that value, but it parses it as unknown and drops failure_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).
  • Generated WebhookEvent / WebhookEventType carry failure_reason and failure_detail for run.failed.
  • BatchAPIError.detail, and README/docstring notes on the 402 api_key_cap_reached problem code.
  • docs/openapi.yaml synced 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.
  • New tests: a capped run parses, failure_detail round-trips, and a 402 surfaces its code and detail.

No version bump (the release sets it).

🤖 Generated with Claude Code

AnderRV and others added 3 commits October 1, 2026 12:16
…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
@AnderRV AnderRV self-assigned this Oct 2, 2026
@AnderRV
AnderRV marked this pull request as ready for review October 2, 2026 06:59
@AnderRV
AnderRV merged commit 5147edf into main Oct 2, 2026
1 check passed
@AnderRV
AnderRV deleted the feat/batch-api-key-cap-reached branch October 2, 2026 07:00
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