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

results() — anthropic-sdk-python Function Reference

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

Function python AnthropicClient AsyncAPI calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  d5e9ac6c_f683_9e1a_0642_8431b65dab96["results()"]
  2a025d5d_3057_7bf3_fea3_d693a30b85ec["Batches"]
  d5e9ac6c_f683_9e1a_0642_8431b65dab96 -->|defined in| 2a025d5d_3057_7bf3_fea3_d693a30b85ec
  93278600_427e_5359_fec5_e7c0f20d5529["results()"]
  93278600_427e_5359_fec5_e7c0f20d5529 -->|calls| d5e9ac6c_f683_9e1a_0642_8431b65dab96
  8215ec2b_8430_7898_ef69_d6b26e8479e1["retrieve()"]
  d5e9ac6c_f683_9e1a_0642_8431b65dab96 -->|calls| 8215ec2b_8430_7898_ef69_d6b26e8479e1
  93278600_427e_5359_fec5_e7c0f20d5529["results()"]
  d5e9ac6c_f683_9e1a_0642_8431b65dab96 -->|calls| 93278600_427e_5359_fec5_e7c0f20d5529
  style d5e9ac6c_f683_9e1a_0642_8431b65dab96 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/resources/messages/batches.py lines 278–327

    def results(
        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,
    ) -> JSONLDecoder[MessageBatchIndividualResponse]:
        """
        Streams the results of a Message Batch as a `.jsonl` file.

        Each line in the file is a JSON object containing the result of a single request
        in the Message Batch. Results are not guaranteed to be in the same order as
        requests. Use the `custom_id` field to match results to requests.

        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}")

        batch = self.retrieve(message_batch_id=message_batch_id)
        if not batch.results_url:
            raise AnthropicError(
                f"No `results_url` for the given batch; Has it finished processing? {batch.processing_status}"
            )

        extra_headers = {"Accept": "application/binary", **(extra_headers or {})}
        return self._get(
            batch.results_url,
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=JSONLDecoder[MessageBatchIndividualResponse],
            stream=True,
        )

Subdomains

Called By

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free