_prepare_options() — anthropic-sdk-python Function Reference
Architecture documentation for the _prepare_options() function in _client.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 7050f784_fee9_3541_5043_b4b8e9afbf3a["_prepare_options()"] 7bcf2a66_49f2_0382_7180_1ee6501f1674["_client.py"] 7050f784_fee9_3541_5043_b4b8e9afbf3a -->|defined in| 7bcf2a66_49f2_0382_7180_1ee6501f1674 57b2977f_9e9c_5e28_c40c_4a3bc9636498["_prepare_options()"] 57b2977f_9e9c_5e28_c40c_4a3bc9636498 -->|calls| 7050f784_fee9_3541_5043_b4b8e9afbf3a 4910cb96_8c10_3d2e_086c_79ddcc421a05["_prepare_options()"] 4910cb96_8c10_3d2e_086c_79ddcc421a05 -->|calls| 7050f784_fee9_3541_5043_b4b8e9afbf3a style 7050f784_fee9_3541_5043_b4b8e9afbf3a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/lib/vertex/_client.py lines 380–412
def _prepare_options(input_options: FinalRequestOptions, *, project_id: str | None, region: str) -> FinalRequestOptions:
options = model_copy(input_options, deep=True)
if is_dict(options.json_data):
options.json_data.setdefault("anthropic_version", DEFAULT_VERSION)
if options.url in {"/v1/messages", "/v1/messages?beta=true"} and options.method == "post":
if project_id is None:
raise RuntimeError(
"No project_id was given and it could not be resolved from credentials. The client should be instantiated with the `project_id` argument or the `ANTHROPIC_VERTEX_PROJECT_ID` environment variable should be set."
)
if not is_dict(options.json_data):
raise RuntimeError("Expected json data to be a dictionary for post /v1/messages")
model = options.json_data.pop("model")
stream = options.json_data.get("stream", False)
specifier = "streamRawPredict" if stream else "rawPredict"
options.url = f"/projects/{project_id}/locations/{region}/publishers/anthropic/models/{model}:{specifier}"
if options.url in {"/v1/messages/count_tokens", "/v1/messages/count_tokens?beta=true"} and options.method == "post":
if project_id is None:
raise RuntimeError(
"No project_id was given and it could not be resolved from credentials. The client should be instantiated with the `project_id` argument or the `ANTHROPIC_VERTEX_PROJECT_ID` environment variable should be set."
)
options.url = f"/projects/{project_id}/locations/{region}/publishers/anthropic/models/count-tokens:rawPredict"
if options.url.startswith("/v1/messages/batches"):
raise AnthropicError("The Batch API is not supported in the Vertex client yet")
return options
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _prepare_options() do?
_prepare_options() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/lib/vertex/_client.py.
Where is _prepare_options() defined?
_prepare_options() is defined in src/anthropic/lib/vertex/_client.py at line 380.
What calls _prepare_options()?
_prepare_options() is called by 2 function(s): _prepare_options, _prepare_options.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free