Skip to main content

Pi

Pi is a terminal coding agent. It connects to MAG as a custom provider that you define in models.json.

warning

Coding agents make many model calls with long contexts. Usage can be expensive and counts against the allocation of your project. Frontier models cost more per token. To reduce cost, use a smaller model for routine tasks and set a lower context limit. Check your spend on the MAG Dashboard.

1. Set the PAT variable​

Make sure the environment variable AMSC_TOKEN contains your PAT. See Step 4.

2. Add the provider​

Add this to the file ~/.pi/agent/models.json:

{
"providers": {
"amsc-mag": {
"baseUrl": "https://mag.genesis.americansciencecloud.org/v1",
"api": "openai-completions",
"apiKey": "$AMSC_TOKEN",
"compat": { "supportsDeveloperRole": false },
"models": [
{
"id": "claude-sonnet",
"name": "Claude Sonnet",
"reasoning": true,
"contextWindow": 200000,
"maxTokens": 64000
},
{
"id": "gpt-6-luna",
"name": "GPT-6 Luna",
"reasoning": true,
"contextWindow": 272000,
"maxTokens": 32000
}
]
}
}
}

The value $AMSC_TOKEN reads the PAT from the variable. Do not write the PAT in this file.

  • contextWindow and maxTokens are the limits that Pi uses for the model. Prices are higher for long contexts, so use a lower contextWindow to reduce cost. See Model Recommendations.
  • supportsDeveloperRole: false makes Pi send a system message. Claude models need this setting.

3. Select a model​

Start Pi in your project directory:

cd my-project
pi --provider amsc-mag --model claude-sonnet

To select a model in a session, use the /model command. To add a model, add an entry to models. The id is the MAG model name. To find model names, see Using the MAG Dashboard.