agentleFS
AI-ModConAI-ModCon/genesis-skills/skills/amsc-skills/i2-api/SKILL.md

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

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
  1. Very specific:

    Use scripted workflows. Prefer the bundled scripts over hand-written curl commands.

    line 11
  2. Very specific:

    Ensure Python >= 3.10 with the requests package installed:

    line 25
  3. Distinctive:

    IMPORTANT: Never hardcode API keys in source code.

    line 31
  4. Very specific:

    Use scripts/key_manager.py for key validation and spend tracking.

    line 52
  5. Distinctive:

    Check if key is set and valid:

    line 54
  6. Distinctive:

    Check budget and current spend:

    line 59
  7. Very specific:

    Use scripts/select_model.py to find the optimal model for your requirements.

    line 100
  8. Very specific:

    After a call, the true cost is in the x-litellm-response-cost response header

    line 216
  9. Very specific:

    Use --json with i2_api_call.py subcommands to see full response headers

    line 217
  10. Distinctive:

    Use smaller/cheaper models (haiku, gpt-oss-20b) for routine tasks.

    line 218
  11. Distinctive:

    After sourcing, verify the variables are set:

    line 230
  12. Distinctive:

    Always wrap inference calls in retry logic for production use:

    line 297
  13. Distinctive:

    If you use Netskope or similar VPN software, register the CA certificate bundle:

    line 317
  14. Very specific:

    Use --timeout to increase the request timeout:

    line 332
  15. Very specific:

    Use --max-retries for automatic retry with exponential backoff:

    line 342

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

AmSC i2 API

Use scripted workflows. Prefer the bundled scripts over hand-written curl commands.

Prerequisites

  1. Go to https://api.i2-core.american-science-cloud.org/
  2. Log in with your AmSC Google credentials
  3. Click "API Key Manager" in the upper right corner
  4. Generate a key
  5. Set the environment variable:
export AMSC_I2_API_KEY=<your-key>
  1. Ensure Python >= 3.10 with the requests package installed:
python3 -m pip install requests

IMPORTANT: Never hardcode API keys in source code. Always use environment variables.

Quick Start

  1. Validate your key:
python3 scripts/key_manager.py status
  1. List available models:
python3 scripts/i2_api_call.py list-models
  1. 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 --json

Notes:

  • Key is read from AMSC_I2_API_KEY environment 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_caching

Select 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 cost

Natural 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 --interview

Available filter flags:

FlagValuesDescription
--modechat, embeddingModel type
--visionrequired, preferred, not-neededImage input support
--reasoninghigh, standard, not-neededExtended reasoning mode
--toolsrequired, preferred, not-neededFunction/tool calling
--min-contextintegerMinimum context window (tokens)
--min-outputintegerMinimum max output (tokens)
--cachingrequired, preferred, not-neededPrompt caching support
--json-moderequired, preferred, not-neededJSON output mode
--optimizecost, capability, balancedOptimization target
--topintegerNumber of results to show (default: 3)
--jsonflagMachine-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" \
  --stream

With token limit:

python3 scripts/i2_api_call.py chat \
  --model claude-haiku \
  --message "Summarize this text" \
  --max-tokens 256

With retry on transient failures:

python3 scripts/i2_api_call.py chat \
  --model claude-sonnet \
  --message "Hello" \
  --max-retries 3

Embeddings

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" \
  --json

Cost Management

Estimate cost before a call:

python3 scripts/i2_api_call.py cost-estimate \
  --model claude-sonnet \
  --input-tokens 1000 \
  --output-tokens 500

Check current spend:

python3 scripts/key_manager.py spend

Notes:

  • After a call, the true cost is in the x-litellm-response-cost response header
  • Use --json with i2_api_call.py subcommands 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.sh

Or 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 ANTHROPIC

Then start Claude Code normally:

cd my-project
claude

See 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.pem

Contact 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 600

Transient 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 5

Retry sleep follows min(1 * 2^attempt, 30) seconds between attempts.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.