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 providers, use the Open Responses API or 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.
Tip
Genie Code (Agent mode) can do this for you. Try this example prompt:
Query the databricks-claude-sonnet-4-5 model using the Anthropic Messages API with Bearer token auth and the workspace's anthropic base URL. Send a user message and print the response text.
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
Important
Anthropic Claude 3.7 Sonnet will be retired on April 12, 2026. See Deprecated and retired models for the recommended replacement model and guidance for how to migrate during deprecation.
databricks-claude-opus-5databricks-claude-sonnet-5databricks-claude-opus-4-8databricks-claude-opus-4-7databricks-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-4
External models
- Anthropic model provider
- Bedrock Anthropic model provider
Supported input types
Anthropic Claude models on Azure Databricks accept text and image inputs. See Query vision models for image format and size requirements. For per-model input types, see Databricks-hosted foundation models available in Foundation Model APIs.