_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 79c39c47_68fb_666e_6789_686b79b96571["_prepare_options()"] cbdd42fd_75f9_7cc6_3f3b_b8d939e4c157["_client.py"] 79c39c47_68fb_666e_6789_686b79b96571 -->|defined in| cbdd42fd_75f9_7cc6_3f3b_b8d939e4c157 edd748c3_bd8e_a7a2_8c66_e4824029d1bf["_prepare_options()"] edd748c3_bd8e_a7a2_8c66_e4824029d1bf -->|calls| 79c39c47_68fb_666e_6789_686b79b96571 87dc8d50_1d41_3e7b_956e_840605cf6288["_prepare_options()"] 87dc8d50_1d41_3e7b_956e_840605cf6288 -->|calls| 79c39c47_68fb_666e_6789_686b79b96571 edd748c3_bd8e_a7a2_8c66_e4824029d1bf["_prepare_options()"] 79c39c47_68fb_666e_6789_686b79b96571 -->|calls| edd748c3_bd8e_a7a2_8c66_e4824029d1bf style 79c39c47_68fb_666e_6789_686b79b96571 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/lib/bedrock/_client.py lines 38–67
def _prepare_options(input_options: FinalRequestOptions) -> FinalRequestOptions:
options = model_copy(input_options, deep=True)
if is_dict(options.json_data):
options.json_data.setdefault("anthropic_version", DEFAULT_VERSION)
if is_given(options.headers):
betas = options.headers.get("anthropic-beta")
if betas:
options.json_data.setdefault("anthropic_beta", betas.split(","))
if options.url in {"/v1/complete", "/v1/messages", "/v1/messages?beta=true"} and options.method == "post":
if not is_dict(options.json_data):
raise RuntimeError("Expected dictionary json_data for post /completions endpoint")
model = options.json_data.pop("model", None)
model = urllib.parse.quote(str(model), safe=":")
stream = options.json_data.pop("stream", False)
if stream:
options.url = f"/model/{model}/invoke-with-response-stream"
else:
options.url = f"/model/{model}/invoke"
if options.url.startswith("/v1/messages/batches"):
raise AnthropicError("The Batch API is not supported in Bedrock yet")
if options.url == "/v1/messages/count_tokens":
raise AnthropicError("Token counting is not supported in Bedrock yet")
return options
Domain
Subdomains
Defined In
Calls
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/bedrock/_client.py.
Where is _prepare_options() defined?
_prepare_options() is defined in src/anthropic/lib/bedrock/_client.py at line 38.
What does _prepare_options() call?
_prepare_options() calls 1 function(s): _prepare_options.
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