Introduction
Following up on the exciting announcement about Anthropic’s state-of-the-art models becoming available to Azure Databricks customers, this post provides a detailed, step-by-step guide on how you can start using Claude 3.7 Sonnet model directly within your Azure Databricks environment using Model Serving.
We’ll walk through deploying the necessary Azure Databricks workspace, finding the Claude 3.7 model endpoint, testing it in the Playground, and getting the code snippets needed to integrate it into your applications.
Prerequisites:
- An active Azure subscription.
Step 1: Deploy a Premium Azure Databricks Workspace
First, you need an Azure Databricks workspace. Importantly, to use the Foundation Model APIs like Claude 3.7, you need a workspace on the Premium pricing tier located in a region that supports Model Serving.
- Check Region Availability: Before creating the workspace, verify that your desired Azure region supports Model Serving. You can find the latest list here: Azure Databricks Feature Region Support – Model Serving. Note that Pay-as-you-go model serving regions may differ slightly, check the documentation for specifics.
- Create Workspace: Navigate to the Azure portal to create a new Azure Databricks service: Create Azure Databricks Service.
- Configuration:
- Deploy: Review your settings and click “Create”. Provisioning may take a few minutes.
Step 2: Launch Workspace and Navigate to Model Serving
Once your Azure Databricks workspace is successfully provisioned:
- Go to the resource in the Azure portal.
- Click “Launch Workspace”.
- Inside Azure Databricks workspace, on the left sidebar under “Machine Learning”, click on “Serving”.
Step 3: Explore Claude 3.7 Sonnet in the Playground
The Serving page lists available endpoints, including pre-provisioned foundation models.
-
Locate the
databricks-claude-3-7-sonnet
endpoint in the list. (See image above) -
Click the “Use” button associated with the
databricks-claude-3-7-sonnet
model. This will take you directly to the AI Playground. -
Test in Playground: The Playground provides an intuitive chat interface. You can type prompts directly into the chat box and interact with Claude 3.7 Sonnet to understand its capabilities and response style.
-
Get Code Examples: To integrate the model into your applications, click the “Show code examples” button located in the top-left area of the Playground interface.
This will reveal code snippets for making requests using
curl
and Python.
Step 4: Generate a Personal Access Token (PAT)
To authenticate your API requests from your code or REST client, you need a Databricks Personal Access Token (PAT).
- In the top-right corner of your Databricks workspace, click on your username/email address.
- Select “Settings” from the dropdown menu.
- Navigate to the “Developer” tab.
- Next to “Access tokens”, click the “Manage” button.
- Click “Generate new token”.
- Optionally, add a comment (e.g., “Claude API Access”) and set a lifetime for the token.
- Click “Generate”. Important: Copy the displayed token immediately and store it securely. You will not be able to see it again.
- Use this generated token as the value for
DATABRICKS_TOKEN
in thecurl
or Python code examples provided in Step 3.
Step 5: Test with an API Call
Now you can use the code examples from the Playground along with your PAT to interact with the model programmatically. Substitute $DATABRICKS_TOKEN
with the PAT you just generated.
Here’s an example of what a curl
request might look like (adapt the prompt as needed):
Bash
curl --request POST \
--url https://<your-workspace-instance>.azuredatabricks.net/serving-endpoints/databricks-claude-3-7-sonnet/invocations \
--header 'Authorization: Basic <Your_Base64_Encoded_token:PAT_String>' \
--header 'Content-Type: application/json' \
--data '{"messages":[{"role":"user","content":"How is Azure Databricks Billed?"}]}'
You can run this from your terminal or adapt the Python snippet for use in your application.
Conclusion
Azure Databricks makes accessing powerful foundation models like Anthropic’s Claude 3.7 Sonnet incredibly straightforward. By leveraging the built-in Model Serving capabilities and the AI Playground, you can quickly go from deploying your workspace to testing and integrating cutting-edge AI into your workflows. This seamless integration empowers data scientists and developers to build sophisticated AI applications directly on their data platform. Start exploring Claude 3.7 on Azure Databricks today!
0 comments
Be the first to start the discussion.