Use Cloud SDK Extras

Su Suriya Ravichandran Updated 10 Nov 2026
5 min read ·Lesson 169 of 200

What the Cloud Clients Add

The cloud clients share the Messages API with the direct client, and most application code runs on any of them unchanged. Each one also adds things that are specific to its platform: a way to pick where a model is served, a way to supply the platform's identity, a way to route traffic through the platform's network, and sometimes an option that exists only on that cloud. These additions are the extras. They are useful, but each one ties the code to a platform, so they should be used deliberately and kept in the adapter layer from Lesson 166.

This lesson covers the most common extras, shows how a geographic choice maps onto a Bedrock model identifier, explains how to supply a custom network client, and gives guidance on keeping the platform-specific parts contained so that the rest of the application stays portable.


Routing Within a Platform

Several platforms let a request be served from more than one place, and the choice of place is an extra setting. On Vertex AI, the region setting selects the global endpoint, a multi-region group, or a single region (Lesson 162). On Bedrock, a model can be reached through a cross-region inference profile, identified by a geographic prefix in the model name. The prefix lets Bedrock route the request among the regions in that geography, which improves availability and capacity.

The prefix must match the geography, and not every model is available with every prefix. The mapping below expresses the common rule for choosing it from the region, and it is a starting point to be confirmed against the model's availability in the platform's documentation:

"""cloud_extras.py: pick the geographic inference prefix for a Bedrock model from its region."""

PREFIX_BY_REGION_GROUP = {"us-": "us", "eu-": "eu", "ap-": "apac"}


def bedrock_model_id(base_model: str, region: str) -> str:
    for start, prefix in PREFIX_BY_REGION_GROUP.items():
        if region.startswith(start):
            return f"{prefix}.{base_model}"
    raise ValueError(f"no inference prefix is known for region {region}")


if __name__ == "__main__":
    base = "anthropic.claude-sonnet-4-5-20250929-v1:0"
    for region in ["us-east-1", "eu-west-1", "ap-south-1", "sa-east-1"]:
        try:
            print(f"{region}: {bedrock_model_id(base, region)}")
        except ValueError as error:
            print(f"{region}: error: {error}")

Output:

us-east-1: us.anthropic.claude-sonnet-4-5-20250929-v1:0
eu-west-1: eu.anthropic.claude-sonnet-4-5-20250929-v1:0
ap-south-1: apac.anthropic.claude-sonnet-4-5-20250929-v1:0
sa-east-1: error: no inference prefix is known for region sa-east-1

How It Works

  1. The region decides the geography. Regions beginning with us-, eu-, and ap- map to the US, EU, and Asia-Pacific prefixes, and the function attaches the matching prefix to the base model identifier.
  2. The base identifier is unchanged. The prefix is added in front of it, so the model's version suffix is preserved exactly.
  3. An unknown region raises an error rather than guessing. A guessed prefix could route data to a geography the organization did not choose, which is a compliance problem, not only a technical one.
  4. The table is a rule to be confirmed. Whether a particular model is available under a given prefix is a property of the platform, and the code cannot know it. The function only encodes the naming rule.

Supplying Identity

Each cloud client accepts the platform's identity in its own way, and the default chain (Lesson 164) is correct for most deployments. The extras appear when the default is not enough: a named profile for a machine with several accounts, a specific role to assume for one service, or a credential object created by the platform's library and passed to the client. The principle is that the identity is passed as an object created by the platform's tools, never as a string copied from a file into code.


Custom Network Clients

The SDK builds on a standard HTTP library, and it accepts a custom client for the network layer. A custom client is the way to set a proxy, add certificates for an internal network, or change connection pooling. It is the advanced form of the timeout settings from Lesson 144, and it affects every request the client makes. The configuration belongs in the factory from Lesson 167, so that every client in the application receives the same network behavior.

A custom network client is a powerful setting, and a mistake in it affects all traffic. Proxy and certificate settings should be tested against the actual network path, and changes should be rolled out the same way as code changes.


Keeping the Extras Contained

Every extra ties the code to a platform. The discipline that keeps an application portable is to confine extras to the factory and the adapter layer, and to keep the rest of the code platform-neutral. A function that takes a client and a model name works everywhere. A function that builds a Bedrock-specific identifier belongs in the adapter, where it is the only place that knows about the platform.

The test for whether an extra belongs in the core is simple: if removing it would require changes to business logic, the extra has leaked. Keeping the boundary clean costs little at the start and saves a great deal when a platform changes.


Summary

The cloud clients add platform-specific extras: routing options such as cross-region inference profiles, identity options beyond the default chain, and custom network clients for proxies and certificates. The geographic prefix for a Bedrock model follows from its region, and an unknown region should raise an error rather than guess, since the choice has compliance consequences. Extras belong in the factory and adapter layer, where they can be tested and where they keep the rest of the application portable. The final lesson of the section covers deploying an application that uses these clients.

0 Comments

Reviewed before they appear

No comments yet.

Anthropic SDK Using Python
Anthropic SDK Intro Claude API Intro SDK Requirements Install Anthropic SDK Upgrade the SDK Create an API Key Set API Keys Use Environment Variables Import Anthropic Create a Client Send Your First Message Choose a Claude Model Set Max Tokens Read a Response Print Response Text Understand Message Blocks Use System Prompts Send User Messages Set Temperature Handle Stop Reasons Messages API Intro Create Messages Use Message Roles Send Conversation History Continue a Conversation Build a Chat Loop Reset Chat History Use Multiple Turns Inspect Message IDs Read Usage Data Write Clear Prompts Set a System Prompt Add Context to Prompts Use Prompt Templates Add Examples to Prompts Request JSON Output Use XML Tags Control Response Length Improve Prompt Quality Avoid Prompt Injection Read Text Blocks Read Content Blocks Check Stop Reasons Count Input Tokens Count Output Tokens Count Tokens Before Sending Limit Output Tokens Use Stop Sequences Read Request IDs Parse API Responses Streaming Intro Stream Text Output Use Stream Events Use Stream Helpers Get Final Messages Stream Async Responses Handle Stream Errors Build a Live Chat Stream Long Responses Close Streams Safely Build a Chatbot Keep Chat History Manage Chat Sessions Add Chat Memory Build a CLI Chatbot Build a Web Chatbot Use Flask with Claude Use FastAPI with Claude Return JSON from an API Add Chat Error Messages Async SDK Intro Create an Async Client Send Async Messages Use asyncio Run Parallel Requests Stream Async Text Handle Async Errors Set Async Timeouts Close Async Clients Choose Sync or Async Tool Use Intro Define a Tool Create Tool Schemas Send Tools to Claude Read Tool Calls Run Python Tools Return Tool Results Continue After Tool Use Control Tool Choice Handle Tool Errors Use the beta_tool Decorator Create a Tool Runner Add Tool Docstrings Validate Tool Inputs Use Multiple Tools Limit Tool Calls Log Tool Activity Build a Weather Tool Build a Search Tool Build a Calculator Tool Structured Output Intro Request JSON Data Validate JSON Output Use Pydantic Models Handle Invalid JSON Extract Fields from Text Generate Typed Data Use Image URLs Send Base64 Images Read PDFs with Claude Use Output Schemas Build Data Extraction Test Structured Responses Send Image Inputs Upload Files Use File IDs Process Text Files Summarize Documents Extract Table Data Handle File Errors Read Cache Usage Reduce Repeated Input Costs Debug Cache Misses Prompt Caching Intro Enable Prompt Caching Cache System Prompts Cache Long Context Test Cache Performance Use Cache Breakpoints Cache Best Practices Message Batches Intro Create a Message Batch Set Batch IDs Check Batch Status List Message Batches Get Batch Results Process Batch Outputs Handle Failed Batch Items Use Batches for Bulk Tasks Compare Batches and Requests Handle API Errors Handle Rate Limits Retry Failed Requests Set Request Timeouts Handle Network Errors Use Exponential Backoff Build Reliable API Calls Use Extended Thinking Log API Errors Track Request IDs Paginate API Results Set Thinking Budgets Read Thinking Blocks Use Tool Search Use Web Search Tools Use Computer Tools Use Citations Use Token Counting Read Raw Responses Set Custom Headers Use Claude on AWS Bedrock Use Claude on Vertex AI Use Claude on Microsoft Foundry Configure Cloud Credentials Choose a Cloud Provider Compare API Integrations Configure Provider Clients Handle Cloud Errors Use Cloud SDK Extras Deploy Cloud Apps Protect API Keys Use a .env File Ignore Secrets in Git Validate User Input Reduce Prompt Injection Limit Tool Permissions Avoid Unsafe Tool Calls Sanitize Tool Results Set Usage Limits Review Security Logs Test SDK Functions Mock API Responses Test Error Handling Test Streaming Code Measure Token Usage Track API Costs Configure Logging Deploy with Docker Deploy a FastAPI App Monitor Production Apps Build a Claude Chatbot Build a Text Summarizer Build a Code Explainer Build a JSON Extractor Build a PDF Assistant Build a Streaming Chat App Build a Tool-Calling Agent Build a Batch Processor Build a Research Assistant Build a Claude API Dashboard
Ask about this post
AI Ask about this post

Ask questions about Use Cloud SDK Extras and get answers drawn from it.

Signed-in readers only.