i2-api
Skill4 starsChanged 2 months agoBSD-2-ClauseView on GitHub
Use this skill to work with the AmSC i2 LLM API at api.i2-core.american-science-cloud.org, including API key validation, model discovery and selection, chat completions, embeddings, cost/spend tracking, Claude Code configuration, and LangChain integration. Trigger this skill when the task mentions i2 API, AmSC LLM, model selection, chat completions, embeddings, API spend, Claude Code setup with i2, or LangChain with i2.
- Reads credentials
- Installs packages
In this repository29 other files it gives its agents.
- skills/academy/agents.mdAGENTS.md
- academySkill
- amsc-data-movement-apiSkill
- amsc-python-clientSkill
- globus-computeSkill
- iri-apiSkill
- skill-explorerSkill
- croissant-validatorSkill
- datacard-generatorSkill
- hdmf-schema-builderSkill
- skill-creatorSkill
- well-convertSkill
- card-eval-updaterSkill
- agentic-vulnerabilities-scanSkill
- ai-fingerprintSkill
- battleprintSkill
- fingerprintingSkill
- uncertainty-quantificationSkill
- uq-metrics-evaluatorSkill
- skill-searchSkill
- auroraSkill
- frontierSkill
- pbsSkill
- perlmutterSkill
- slurmSkill
- literature-searchSkill
- multi-agent-systemsSkill
- gkeyllSkill
- gs2Skill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 7 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Use scripted workflows. Prefer the bundled scripts over hand-written curl commands.
- Very specific: line 25
Ensure Python >= 3.10 with the requests package installed:
- Distinctive: line 31
IMPORTANT: Never hardcode API keys in source code.
- Very specific: line 52
Use scripts/key_manager.py for key validation and spend tracking.
- Distinctive: line 54
Check if key is set and valid:
- Distinctive: line 59
Check budget and current spend:
- Very specific: line 100
Use scripts/select_model.py to find the optimal model for your requirements.
- Very specific: line 216
After a call, the true cost is in the x-litellm-response-cost response header
- Very specific: line 217
Use --json with i2_api_call.py subcommands to see full response headers
- Distinctive: line 218
Use smaller/cheaper models (haiku, gpt-oss-20b) for routine tasks.
- Distinctive: line 230
After sourcing, verify the variables are set:
- Distinctive: line 297
Always wrap inference calls in retry logic for production use:
- Distinctive: line 317
If you use Netskope or similar VPN software, register the CA certificate bundle:
- Very specific: line 332
Use --timeout to increase the request timeout:
- Very specific: line 342
Use --max-retries for automatic retry with exponential backoff:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AmSC i2 API
Use scripted workflows. Prefer the bundled scripts over hand-written curl commands.
Prerequisites
- Go to
https://api.i2-core.american-science-cloud.org/ - Log in with your AmSC Google credentials
- Click "API Key Manager" in the upper right corner
- Generate a key
- Set the environment variable:
export AMSC_I2_API_KEY=<your-key>- Ensure Python >= 3.10 with the
requestspackage installed:
python3 -m pip install requestsIMPORTANT: Never hardcode API keys in source code. Always use environment variables.
Quick Start
- Validate your key:
python3 scripts/key_manager.py status- List available models:
python3 scripts/i2_api_call.py list-models- Send a chat message:
python3 scripts/i2_api_call.py chat --model claude-sonnet --message "Hello, world"Key Management
Use scripts/key_manager.py for key validation and spend tracking.
- Check if key is set and valid:
python3 scripts/key_manager.py status- Check budget and current spend:
python3 scripts/key_manager.py spend- Machine-readable output:
python3 scripts/key_manager.py status --json
python3 scripts/key_manager.py spend --jsonNotes:
- Key is read from
AMSC_I2_API_KEYenvironment variable - Allow up to 5 seconds after an API call for spend logs to update
Model Discovery and Selection
Inspect Available Models
- List all model IDs grouped by mode:
python3 scripts/i2_api_call.py list-models- Get detailed metadata for all models:
python3 scripts/i2_api_call.py model-info- Get metadata for a specific model:
python3 scripts/i2_api_call.py model-info --model claude-sonnet- Extract a specific property across all models:
python3 scripts/i2_api_call.py model-info --property supports_prompt_cachingSelect the Best Model
Use scripts/select_model.py to find the optimal model for your requirements.
CLI filter mode -- specify requirements as flags:
python3 scripts/select_model.py \
--mode chat \
--vision required \
--reasoning high \
--tools required \
--min-context 100000 \
--caching preferred \
--optimize costNatural language mode -- describe requirements as text:
python3 scripts/select_model.py \
--describe "I need a model for coding tasks with function calling, \
at least 128K context, and prompt caching. Cost is important."Interactive interview mode -- answer prompts:
python3 scripts/select_model.py --interviewAvailable filter flags:
| Flag | Values | Description |
--mode | chat, embedding | Model type |
--vision | required, preferred, not-needed | Image input support |
--reasoning | high, standard, not-needed | Extended reasoning mode |
--tools | required, preferred, not-needed | Function/tool calling |
--min-context | integer | Minimum context window (tokens) |
--min-output | integer | Minimum max output (tokens) |
--caching | required, preferred, not-needed | Prompt caching support |
--json-mode | required, preferred, not-needed | JSON output mode |
--optimize | cost, capability, balanced | Optimization target |
--top | integer | Number of results to show (default: 3) |
--json | flag | Machine-readable output |
Chat Completions
Basic chat call:
python3 scripts/i2_api_call.py chat \
--model claude-sonnet \
--message "Explain quantum entanglement in one paragraph"With a system prompt:
python3 scripts/i2_api_call.py chat \
--model claude-sonnet \
--system "You are a concise technical writer." \
--message "Explain quantum entanglement"Streaming response:
python3 scripts/i2_api_call.py chat \
--model claude-sonnet \
--message "Write a short story" \
--streamWith token limit:
python3 scripts/i2_api_call.py chat \
--model claude-haiku \
--message "Summarize this text" \
--max-tokens 256With retry on transient failures:
python3 scripts/i2_api_call.py chat \
--model claude-sonnet \
--message "Hello" \
--max-retries 3Embeddings
Generate an embedding:
python3 scripts/i2_api_call.py embed \
--model cohere-embed-english-v3 \
--input "The quick brown fox jumps over the lazy dog"Raw JSON output:
python3 scripts/i2_api_call.py embed \
--model cohere-embed-v4 \
--input "Sample text" \
--jsonCost Management
Estimate cost before a call:
python3 scripts/i2_api_call.py cost-estimate \
--model claude-sonnet \
--input-tokens 1000 \
--output-tokens 500Check current spend:
python3 scripts/key_manager.py spendNotes:
- After a call, the true cost is in the
x-litellm-response-costresponse header - Use
--jsonwithi2_api_call.pysubcommands to see full response headers - Use smaller/cheaper models (haiku, gpt-oss-20b) for routine tasks; escalate to larger models only when needed
Claude Code Setup
Source the env var template to configure Claude Code with i2 as the backend:
source references/claude-code-env.shOr add the contents of references/claude-code-env.sh to your shell profile (~/.zshrc or ~/.bashrc).
After sourcing, verify the variables are set:
env | grep ANTHROPICThen start Claude Code normally:
cd my-project
claudeSee references/claude-code-env.sh for all configurable variables and their descriptions.
LangChain Integration
The i2 API is OpenAI-compatible. Use langchain-openai with the i2 base URL.
Chat Model
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="claude-sonnet",
base_url="https://api.i2-core.american-science-cloud.org/v1",
api_key=os.environ["AMSC_I2_API_KEY"],
)
response = llm.invoke("Explain quantum entanglement")
print(response.content)Embeddings
import os
from langchain_openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(
model="cohere-embed-english-v3",
base_url="https://api.i2-core.american-science-cloud.org/v1",
api_key=os.environ["AMSC_I2_API_KEY"],
)
vector = embeddings.embed_query("Sample text")Streaming
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="claude-sonnet",
base_url="https://api.i2-core.american-science-cloud.org/v1",
api_key=os.environ["AMSC_I2_API_KEY"],
streaming=True,
)
for chunk in llm.stream("Write a short story"):
print(chunk.content, end="", flush=True)Retry Handling
Always wrap inference calls in retry logic for production use:
import os
import time
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="claude-sonnet",
base_url="https://api.i2-core.american-science-cloud.org/v1",
api_key=os.environ["AMSC_I2_API_KEY"],
max_retries=3,
timeout=600,
)Network Issues
SSL Certificate Errors
If you use Netskope or similar VPN software, register the CA certificate bundle:
# Python
export REQUESTS_CA_BUNDLE=/path/to/ca-cert.pem
export SSL_CERT_FILE=/path/to/ca-cert.pem
# Node.js
export NODE_EXTRA_CA_CERTS=/path/to/ca-cert.pemContact your IT support to obtain the CA certificate bundle.
Timeout Errors
Use --timeout to increase the request timeout:
python3 scripts/i2_api_call.py chat \
--model claude-opus \
--message "Write a detailed analysis" \
--timeout 600Transient Network Errors
Use --max-retries for automatic retry with exponential backoff:
python3 scripts/i2_api_call.py chat \
--model claude-sonnet \
--message "Hello" \
--max-retries 5Retry sleep follows min(1 * 2^attempt, 30) seconds between attempts.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

