Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
The Anthropic Messages API is only compatible with Anthropic pay per token foundation models and external models. For a unified API that works across all providers, use the Chat Completions API.
The Anthropic Messages API provides native Anthropic SDK compatibility for Claude models on Azure Databricks. Use this API when you need Anthropic-specific features or are migrating existing Anthropic SDK code.
Requirements
- See Requirements.
- Install the
anthropicpackage on your compute.
Query examples
The following examples show how to query a Foundation Model API pay-per-token endpoint using the Anthropic Messages API.
Python
import anthropic
import os
DATABRICKS_TOKEN = os.environ.get('DATABRICKS_TOKEN')
client = anthropic.Anthropic(
api_key="unused",
base_url="https://example.staging.cloud.databricks.com/serving-endpoints/anthropic",
default_headers={
"Authorization": f"Bearer {DATABRICKS_TOKEN}",
},
)
message = client.messages.create(
model="databricks-claude-sonnet-4-5",
max_tokens=256,
messages=[
{"role": "user", "content": "What is a mixture of experts model?"},
],
)
print(message.content[0].text)
REST API
curl \
-u token:$DATABRICKS_TOKEN \
-X POST \
-H "Content-Type: application/json" \
-d '{
"model": "databricks-claude-sonnet-4-5",
"max_tokens": 256,
"messages": [
{
"role": "user",
"content": "What is a mixture of experts model?"
}
]
}' \
https://<workspace_host>.databricks.com/serving-endpoints/anthropic/v1/messages
Supported models
Databricks-hosted foundation models
databricks-claude-opus-4-6databricks-claude-sonnet-4-6databricks-claude-sonnet-4-5databricks-claude-haiku-4-5databricks-claude-opus-4-5databricks-claude-opus-4-1databricks-claude-sonnet-4databricks-claude-3-7-sonnet
External models
- Anthropic model provider
- Bedrock Anthropic model provider