Harvard Data Science Initiative Harvard Faculty of Arts and Sciences

Generative AI for Scholarship

Harvard Data Science Initiative (HDSI) & Faculty of Arts and Sciences (FAS)

Setting Up Anthropic API Access for Harvard Users

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.

Cost Management is Critical

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.

Prerequisites

Important: Setting up API access through Harvard's system requires the authority to set up billing on a Harvard 33-digit budget code. This authority normally vests with a project PI or unit administrator.

Understanding Harvard's API Access Structure

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.

Step 1: Set Up a HUIT Billing Number

If you don't already have an appropriate HUIT billing number for API services, you'll need to request one.

  1. Go to the HUIT Billing Portal: https://billing.huit.harvard.edu/portal/allusers/newcustomer
  2. Fill out the form to request a new billing number
  3. Associate it with your Harvard 33-digit budget/account number
  4. Under "HUIT Services" at the bottom, list: AI API keys
  5. Submit the form and wait for approval

Note: 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.

Step 2: Register Your App (User) in the HUIT API Portal

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."

Recommended Naming Convention

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":

Registration Process

This will only take a couple of minutes.

  1. Go to the HUIT API Portal: https://portal.apis.huit.harvard.edu/register-an-app
  2. Sign in using the button in the top right of the web page
  3. Click on your login name in the top right to reveal the developer dropdown, and select "Apps", then click "+New App"
  4. Fill in the App name (could be the name of your use case, or project name/team member name). In the description field, include the HUIT customer number (B#####) for your project.
  5. Scroll down and click "Request" or "Enable" next to the GenAI APIs you'd like access to (such as "AI Services - AWS Bedrock API", for Anthropic/Claude models)
  6. Click "Save" in the lower right corner. If you provided your HUIT customer number as noted in step 4, you will receive an email within minutes indicating your access request has been approved.

Important Configuration Details

When filling out the App registration form:

Step 3: Configure Your Environment

Once you have your API key from the HUIT portal, you need to configure your shell environment to use Harvard's API endpoint.

Required Environment Variables

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:

Automatic Configuration

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:

  1. Open your ~/.zshrc file in a text editor:
    nano ~/.zshrc
  2. Add these lines at the end of the file (with your actual API key):
    # 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
  3. Save and exit the editor (Ctrl+X, then Y, then Enter in nano)
  4. Reload your configuration:
    source ~/.zshrc

Security: Protect Your API Key

Your API key is like a password — never share it with anyone.

Checking Your API Usage and Remaining Quota

PIs 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"
}
Note: The 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).

Support and Resources