This guide will help you set up access to Anthropic's Claude API through Harvard's HUIT system after the workshop sessions. This provides secure, compliant access to Claude AI services with usage charged to your research accounts.
The PI is responsible for all costs incurred through API usage. API usage can consume budget quickly if not properly controlled.
It is essential to set upper limit caps on monthly spending. This is your primary defense against unexpected budget overruns. Always establish monthly spending caps when registering your API access.
/cost command in
Claude Code to track your API consumption and adjust accordingly.Harvard provides access to Anthropic's Claude API through the HUIT (Harvard University Information Technology) system. This ensures:
Key principle: You'll need one HUIT billing number for each research account that has an associated "effort" from the standpoint of grant compliance. There should be a 1:1 correspondence between project-specific efforts and the accounting structure.
If you don't already have an appropriate HUIT billing number for API services, you'll need to request one.
AI API keysNote: If your research group already has a HUIT billing number set up for AI services, you can skip this step and proceed to Step 2.
Once you have an appropriate HUIT billing number, you need to connect it to API keys and individual users through the HUIT API Portal.
Terminology note: Although the system talks about registering an "App," for our purposes this should be considered as "registering a user."
We recommend creating one App per research group member for each project to which they bill time. This ensures proper effort tracking and grant compliance.
Example:
A postdoc named Jane Smith has her salary (and effort) split 50-50 between an NIH grant and faculty research funds. She should create two "Apps":
Smith_NIH— for work charged to the NIH grantSmith_FAS— for work charged to faculty research funds
This will only take a couple of minutes.
B#####) for your project.When filling out the App registration form:
Jane Smith - NIH Grant R01-XYZ123 - Monthly limit $200Once you have your API key from the HUIT portal, you need to configure your shell environment to use Harvard's API endpoint.
Set these environment variables in your Terminal session:
export ANTHROPIC_BEDROCK_BASE_URL=https://apis.huit.harvard.edu/ais-bedrock-llm/v2
export ANTHROPIC_API_KEY=YourKeyHere
export ANTHROPIC_SMALL_FAST_MODEL=us.anthropic.claude-opus-4-5-20251101-v1:0
export CLAUDE_CODE_SKIP_BEDROCK_AUTH=1
export CLAUDE_CODE_USE_BEDROCK=1
Important: Replace YourKeyHere with the
actual API key you received from the HUIT API Portal.
What these variables do:
ANTHROPIC_BEDROCK_BASE_URL — Points to Harvard's secure API endpointANTHROPIC_API_KEY — Your personal API key from HUITANTHROPIC_SMALL_FAST_MODEL — Model for quick background operationsCLAUDE_CODE_SKIP_BEDROCK_AUTH — Skips additional Bedrock authentication (Harvard handles this)CLAUDE_CODE_USE_BEDROCK — Enables Bedrock mode for Harvard's infrastructure
To avoid setting these variables manually each time you open Terminal, add them
to your ~/.zshrc file, which runs automatically when a shell session
is initiated:
~/.zshrc file in a text editor:
nano ~/.zshrc
# Harvard HUIT Anthropic API Configuration
export ANTHROPIC_BEDROCK_BASE_URL=https://apis.huit.harvard.edu/ais-bedrock-llm/v2
export ANTHROPIC_API_KEY=YourKeyHere
export ANTHROPIC_SMALL_FAST_MODEL=us.anthropic.claude-opus-4-5-20251101-v1:0
export CLAUDE_CODE_SKIP_BEDROCK_AUTH=1
export CLAUDE_CODE_USE_BEDROCK=1
source ~/.zshrc
Your API key is like a password — never share it with anyone.
chmod 600 ~/.zshrc to restrict accessPIs can set an upper limit to monthly API key costs during registration. This is your primary defense against unexpected budget overruns.
You can check your current spending and remaining quota at any time by running
this command in Terminal. Copy and paste it directly — it will automatically
use the ANTHROPIC_API_KEY from your environment:
curl --location 'https://go.apis.huit.harvard.edu/ais-bedrock-llm/apigee/quota' \
--header "Authorization: Bearer $ANTHROPIC_API_KEY"
You should see a JSON response like this:
{
"apigee_app_id": "64834f44-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"quota": {
"limit": "1000.0",
"limit_unit": "USD",
"interval": "1",
"unit": "month"
},
"remaining_limit": "826.19"
}
apigee_app_id in the response is Harvard's
internal account identifier for your registration — it is not your API key.
Your API key is never echoed back in the response. The fields that matter are
limit (your monthly spending cap in USD) and remaining_limit
(how much of that budget remains for the current month).