Enterprise Deployment Basics
9 examples to get you started with Enterprise Deployment - 6 basic and 3 intermediate.
Search across all documentation pages
9 examples to get you started with Enterprise Deployment - 6 basic and 3 intermediate.
pip install anthropic for the direct API, pip install "anthropic[bedrock]" for Amazon Bedrock, pip install "anthropic[vertex]" for Google Cloud Vertex AI.gcloud auth application-default login.claude-sonnet-5 is available on every platform you provision; confirm model access before running them.The simplest possible path: an API key and the official SDK, no cloud account required.
import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY from the environment
response = client.messages.create(
model="claude-sonnet-5",
max_tokens=256,
messages=[{"role": "user", "content": "List three benefits of infrastructure as code."}],
)
print(response.content[0].text)anthropic.Anthropic() with no arguments reads ANTHROPIC_API_KEY from the environment automatically.messages.create call shape, just through a different client class.Related: Choosing Between Direct API, Bedrock, and Vertex AI for Claude - the decision this page assumes you've already made.
Point the SDK at Amazon Bedrock instead of Anthropic's own endpoint, using AWS credentials instead of an API key.
from anthropic import AnthropicBedrock
client = AnthropicBedrock(
aws_region="us-east-1",
)AnthropicBedrock resolves AWS credentials the same way any AWS SDK does: environment variables, a shared credentials file, or an assumed IAM role.aws_region is required - Bedrock has no default region fallback, and the model you requested access to must be available in that region.Once the client is constructed, the request shape is identical to the direct API, aside from the model ID prefix.
from anthropic import AnthropicBedrock
client = AnthropicBedrock(aws_region="us-east-1")
response = client.messages.create(
model="anthropic.claude-sonnet-5",
max_tokens=256,
messages=[{"role": "user", "content": "List three benefits of infrastructure as code."}],
)
print(response.content[0].text)anthropic. prefix - passing the bare claude-sonnet-5 ID from the direct API here returns a 404.403 at this point almost always means the IAM role lacks the Bedrock invoke permission, or model access was never requested in the console for this model in this region.messages.create is the same method with the same parameters as the direct-API client - only the client class and model ID string differ.Point the SDK at Google Cloud Vertex AI, authenticating with a GCP project and Application Default Credentials instead of an API key.
from anthropic import AnthropicVertex
client = AnthropicVertex(
project_id="my-gcp-project",
region="us-east5",
)project_id and region are both required constructor arguments - there is no default project or region.gcloud auth application-default login locally or a service account attached to the runtime in production.region can be a specific region, a multi-region value, or "global" depending on the model and latency needs.Vertex AI model IDs for current-generation Claude models are unprefixed, unlike Bedrock's anthropic. prefix.
from anthropic import AnthropicVertex
client = AnthropicVertex(project_id="my-gcp-project", region="us-east5")
response = client.messages.create(
model="claude-sonnet-5",
max_tokens=256,
messages=[{"role": "user", "content": "List three benefits of infrastructure as code."}],
)
print(response.content[0].text)403 here usually means the service account is missing the Vertex AI User IAM role, or the project has not enabled the Vertex AI API.429 or quota error means the project's request or token quota for this model needs to be raised in the Google Cloud console.Related: Running Claude on Google Cloud Vertex AI: Quotas and Service Accounts - the full service account and quota setup.
Wrap the call so a misconfigured IAM role or service account produces a clear message instead of a raw stack trace.
import anthropic
from anthropic import AnthropicBedrock
client = AnthropicBedrock(aws_region="us-east-1")
try:
response = client.messages.create(
model="anthropic.claude-sonnet-5",
max_tokens=256,
messages=[{"role": "user", "content": "Ping."}],
)
print(response.content[0].text)
except anthropic.PermissionDeniedError:
print("IAM role lacks Bedrock invoke permission, or model access was not requested.")
except anthropic.NotFoundError:
print("Model ID or region is wrong - check the anthropic. prefix and region availability.")PermissionDeniedError and NotFoundError are the same typed exception classes across every client - direct API, Bedrock, and Vertex AI all raise them the same way.except Exception, lets you show a platform-appropriate remediation message instead of a generic failure.Some Bedrock models require an inference profile ID instead of a plain model ID for capacity or latency reasons.
from anthropic import AnthropicBedrock
client = AnthropicBedrock(aws_region="us-east-1")
response = client.messages.create(
model="us.anthropic.claude-sonnet-5", # cross-region inference profile ID
max_tokens=256,
messages=[{"role": "user", "content": "Summarize this quarter's cloud spend trend."}],
)
print(response.content[0].text)us.) routes a single logical request across multiple AWS regions for capacity headroom.Vertex AI lets you pin inference to a specific region, a multi-region value, or route globally for best availability.
from anthropic import AnthropicVertex
# Pin to a specific region for data residency or latency reasons.
regional_client = AnthropicVertex(project_id="my-gcp-project", region="europe-west1")
# Or use "global" for Anthropic to route to the best available region.
global_client = AnthropicVertex(project_id="my-gcp-project", region="global")europe-west1) is the right choice when data residency or latency requirements pin where inference must run.region="global" is recommended by default when you have no residency constraint, since it gives Anthropic room to route around regional capacity limits.Related: Data Residency and Region-Pinning Checklist for Regulated Workloads - when a specific region is a compliance requirement, not just a preference.
A minimal wrapper that picks the right client class at startup, so application code never has to know which platform is live in a given environment.
import os
import anthropic
from anthropic import AnthropicBedrock, AnthropicVertex
def get_client() -> anthropic.Anthropic:
platform = os.environ.get("CLAUDE_PLATFORM", "direct")
if platform == "bedrock":
return AnthropicBedrock(aws_region=os.environ["AWS_REGION"])
if platform == "vertex":
return AnthropicVertex(
project_id=os.environ["GCP_PROJECT_ID"],
region=os.environ.get("GCP_REGION", "global"),
)
return anthropic.Anthropic()
client = get_client()
response = client.messages.create(
model="claude-sonnet-5",
max_tokens=256,
messages=[{"role": "user", "content": "What changed between staging and prod?"}],
)
print(response.content[0].text)messages.create interface, so switching platforms is a matter of swapping which client get_client() returns.CLAUDE_PLATFORM as an environment variable lets you run the same code against the direct API in local development and against Bedrock or Vertex AI in a deployed environment without a code change.Related: Building a Self-Hosted Gateway for Routing, Caching, and Fallback - the next step once a simple environment switch isn't enough.
Stack versions: Written against the Claude model lineup current as of ~June 2026 - Claude Fable 5, Claude Opus 4.8, Claude Sonnet 5 (the default), and Claude Haiku 4.5 - and the official
anthropicPython SDK (latest 0.x release). Model names, pricing, and SDK versions move quickly - verify current specifics at platform.claude.com/docs before relying on them.
Reviewed by Chris St. John·Last updated Jul 18, 2026