Home / Function/ cancel() — anthropic-sdk-python Function Reference

cancel() — anthropic-sdk-python Function Reference

Architecture documentation for the cancel() function in batches.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  7617cf4d_d8ef_9bfe_f368_cc6430fb1cf6["cancel()"]
  2a025d5d_3057_7bf3_fea3_d693a30b85ec["Batches"]
  7617cf4d_d8ef_9bfe_f368_cc6430fb1cf6 -->|defined in| 2a025d5d_3057_7bf3_fea3_d693a30b85ec
  d15edac0_68bf_d4a3_0a9e_92d2987b73cf["cancel()"]
  d15edac0_68bf_d4a3_0a9e_92d2987b73cf -->|calls| 7617cf4d_d8ef_9bfe_f368_cc6430fb1cf6
  d15edac0_68bf_d4a3_0a9e_92d2987b73cf["cancel()"]
  7617cf4d_d8ef_9bfe_f368_cc6430fb1cf6 -->|calls| d15edac0_68bf_d4a3_0a9e_92d2987b73cf
  style 7617cf4d_d8ef_9bfe_f368_cc6430fb1cf6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/resources/messages/batches.py lines 231–276

    def cancel(
        self,
        message_batch_id: str,
        *,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> MessageBatch:
        """Batches may be canceled any time before processing ends.

        Once cancellation is
        initiated, the batch enters a `canceling` state, at which time the system may
        complete any in-progress, non-interruptible requests before finalizing
        cancellation.

        The number of canceled requests is specified in `request_counts`. To determine
        which requests were canceled, check the individual results within the batch.
        Note that cancellation may not result in any canceled requests if they were
        non-interruptible.

        Learn more about the Message Batches API in our
        [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

        Args:
          message_batch_id: ID of the Message Batch.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not message_batch_id:
            raise ValueError(f"Expected a non-empty value for `message_batch_id` but received {message_batch_id!r}")
        return self._post(
            f"/v1/messages/batches/{message_batch_id}/cancel",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=MessageBatch,
        )

Subdomains

Calls

Called By

Frequently Asked Questions

What does cancel() do?
cancel() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/resources/messages/batches.py.
Where is cancel() defined?
cancel() is defined in src/anthropic/resources/messages/batches.py at line 231.
What does cancel() call?
cancel() calls 1 function(s): cancel.
What calls cancel()?
cancel() is called by 1 function(s): cancel.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free