upload() — anthropic-sdk-python Function Reference
Architecture documentation for the upload() function in files.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD b6e7caed_07d6_372f_f216_e5a44b9dd309["upload()"] e4e596a3_8f28_361a_1681_29f79feb432d["AsyncFiles"] b6e7caed_07d6_372f_f216_e5a44b9dd309 -->|defined in| e4e596a3_8f28_361a_1681_29f79feb432d 3dbef1a4_a354_5bb8_2fe0_82cae8d90ec8["upload()"] 3dbef1a4_a354_5bb8_2fe0_82cae8d90ec8 -->|calls| b6e7caed_07d6_372f_f216_e5a44b9dd309 3dbef1a4_a354_5bb8_2fe0_82cae8d90ec8["upload()"] b6e7caed_07d6_372f_f216_e5a44b9dd309 -->|calls| 3dbef1a4_a354_5bb8_2fe0_82cae8d90ec8 style b6e7caed_07d6_372f_f216_e5a44b9dd309 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/resources/beta/files.py lines 569–622
async def upload(
self,
*,
file: FileTypes,
betas: List[AnthropicBetaParam] | Omit = omit,
# 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,
) -> FileMetadata:
"""
Upload File
Args:
file: The file to upload
betas: Optional header to specify the beta version(s) you want to use.
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
"""
extra_headers = {
**strip_not_given(
{
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["files-api-2025-04-14"]))
if is_given(betas)
else not_given
}
),
**(extra_headers or {}),
}
extra_headers = {"anthropic-beta": "files-api-2025-04-14", **(extra_headers or {})}
body = deepcopy_minimal({"file": file})
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers["Content-Type"] = "multipart/form-data"
return await self._post(
"/v1/files?beta=true",
body=await async_maybe_transform(body, file_upload_params.FileUploadParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=FileMetadata,
)
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does upload() do?
upload() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/resources/beta/files.py.
Where is upload() defined?
upload() is defined in src/anthropic/resources/beta/files.py at line 569.
What does upload() call?
upload() calls 1 function(s): upload.
What calls upload()?
upload() is called by 1 function(s): upload.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free