Anthropic
The Anthropic integration allows content running on Posit Connect to access the Anthropic API using a shared API key. When content is associated with an Anthropic integration, Connect sets the ANTHROPIC_API_KEY environment variable, which is automatically detected by the official Anthropic SDKs.
This integration is useful when you want to:
- Share a single Anthropic API key across multiple pieces of content.
- Centrally manage and rotate API keys without redeploying content.
- Audit which content is using Anthropic.
Configuring an Anthropic integration in Posit Connect involves two main steps, each performed by different administrators.
- Step 1: An Anthropic administrator creates an API key.
- Step 2: A Posit Connect administrator creates an integration within Connect.
Step 1: Anthropic administrator
Obtain an Anthropic API key
The Anthropic administrator creates an API key in the Anthropic Console.
Anthropic API keys should be treated as sensitive credentials. Consider creating a dedicated API key for use with Connect so it can be rotated or revoked independently.
Step 2: Posit Connect administrator
Create integration in Posit Connect
Using the information from the Anthropic administrator, the Posit Connect administrator creates an integration through the dashboard’s System > Integrations settings. Once the OAuth integration has been created in Connect, it is available for use by all publishers.
Alternatively, the example below shows how to create an Anthropic integration using curl and the Connect Server API.
Replace connect.example.org with the address of the Connect server.
Terminal
curl -H "Authorization: Key ${CONNECT_API_KEY}" \
-XPOST https://connect.example.org/__api__/v1/oauth/integrations \
--data '{
"template": "anthropic",
"name": "Anthropic",
"description": "A helpful description for publishers to use when choosing an integration for their content.",
"config": {
"api_key": "<anthropic-api-key>"
}
}'
# 200 OK
# {"guid": "<integration-guid>", ... }Next steps
Once the integration is configured, publishers can use it in their content. Most Anthropic client libraries detect the ANTHROPIC_API_KEY environment variable by default:
from anthropic import Anthropic
# The client automatically uses the ANTHROPIC_API_KEY environment variable
client = Anthropic()
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}]
)library(ellmer)
chat <- chat_anthropic()
chat$chat("Tell me three jokes about statisticians")Local development
When developing locally, set the ANTHROPIC_API_KEY environment variable in your development environment, or use a .env file. The content will use your local API key during development and the Connect-managed key when deployed.
