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

build() — anthropic-sdk-python Function Reference

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

Function python AnthropicClient AsyncAPI calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  0ea38c39_d71d_a0c9_d116_abfa98f7d429["build()"]
  3912cc3f_b0e8_a732_b8e2_613b018b830d["_models.py"]
  0ea38c39_d71d_a0c9_d116_abfa98f7d429 -->|defined in| 3912cc3f_b0e8_a732_b8e2_613b018b830d
  581be520_0d1b_4636_66cb_735f8146e861["build()"]
  581be520_0d1b_4636_66cb_735f8146e861 -->|calls| 0ea38c39_d71d_a0c9_d116_abfa98f7d429
  581be520_0d1b_4636_66cb_735f8146e861["build()"]
  0ea38c39_d71d_a0c9_d116_abfa98f7d429 -->|calls| 581be520_0d1b_4636_66cb_735f8146e861
  1f1fa4b5_5943_136f_2cef_23465a8f7aee["construct_type()"]
  0ea38c39_d71d_a0c9_d116_abfa98f7d429 -->|calls| 1f1fa4b5_5943_136f_2cef_23465a8f7aee
  style 0ea38c39_d71d_a0c9_d116_abfa98f7d429 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/_models.py lines 466–486

def build(
    base_model_cls: Callable[P, _BaseModelT],
    *args: P.args,
    **kwargs: P.kwargs,
) -> _BaseModelT:
    """Construct a BaseModel class without validation.

    This is useful for cases where you need to instantiate a `BaseModel`
    from an API response as this provides type-safe params which isn't supported
    by helpers like `construct_type()`.

    ```py
    build(MyModel, my_field_a="foo", my_field_b=123)
    ```
    """
    if args:
        raise TypeError(
            "Received positional arguments which are not supported; Keyword arguments must be used instead",
        )

    return cast(_BaseModelT, construct_type(type_=base_model_cls, value=kwargs))

Subdomains

Called By

Frequently Asked Questions

What does build() do?
build() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_models.py.
Where is build() defined?
build() is defined in src/anthropic/_models.py at line 466.
What does build() call?
build() calls 2 function(s): build, construct_type.
What calls build()?
build() is called by 1 function(s): build.

Analyze Your Own Codebase

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

Try Supermodel Free