Trinity now supports multiple AI runtimes, allowing you to choose between Claude Code (Anthropic) and Gemini CLI (Google) for your agents.
Cost Optimization:
- Gemini: Free tier (60 req/min, 1,000/day)
- Claude: Pay-per-use
Context Window:
- Gemini: 1 million tokens (5x larger)
- Claude: 200K tokens
Use Case Matching:
- Gemini: Data processing, monitoring, large codebases
- Claude: Complex reasoning, code quality, reliability
- Go to Google AI Studio
- Click "Create API Key"
- Copy your key
Add to your .env file:
GOOGLE_API_KEY=your-google-api-key-hereVia UI:
- Click "Create Agent"
- Enter agent name
- Select runtime: Gemini CLI
- Choose model:
gemini-2.5-pro - Click "Create"
Via API:
curl -X POST http://localhost:8000/api/agents \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "my-gemini-agent",
"runtime": "gemini-cli",
"runtime_model": "gemini-2.5-pro",
"resources": {"cpu": "2", "memory": "2g"}
}'Via Template:
# config/agent-templates/my-agent/template.yaml
name: my-gemini-agent
runtime:
type: gemini-cli
model: gemini-2.5-pro
resources:
memory: "2g" # Gemini is lighter| Feature | Claude Code | Gemini CLI | Status |
|---|---|---|---|
| Chat Interface | ✅ | ✅ | Identical |
| MCP Tools | ✅ | ✅ | Supported |
| Cost Tracking | ✅ | ✅ | Unified |
| Token Tracking | ✅ | ✅ | Unified |
| Session Continuity | ✅ | ✅ | --resume |
| Tool Restrictions | ✅ | ✅ | --allowed-tools |
| YOLO Mode | ✅ | ✅ | --yolo |
| Context Window | 200K | 1M | 5x larger |
| Pricing | Pay-per-use | Free tier | Different |
| Native Search | ❌ | ✅ | Gemini only |
Claude Code (Sonnet 4.5):
- Input: $3/M tokens
- Output: $15/M tokens
- Estimated: $5-10/day
Gemini CLI (2.5 Pro):
- Free tier: 1,000 requests/day
- Estimated: $0/day (within limits)
Trinity uses a Runtime Adapter pattern:
User Chat → Backend → Agent Container → [Runtime Adapter]
↓
┌─────────┴─────────┐
↓ ↓
ClaudeCodeRuntime GeminiRuntime
↓ ↓
claude CLI gemini CLI
Both runtimes implement the same interface:
execute(prompt, model, continue_session)configure_mcp(servers)- Return same format:
(response, execution_log, metadata)
Both Claude Code and Gemini CLI read agent instructions from CLAUDE.md.
Why keep the name CLAUDE.md?
- Backward compatibility with existing agents
- Both runtimes understand markdown instruction files
- Renaming would break existing templates
workspace/
├── CLAUDE.md # ← Both runtimes read this
├── .mcp.json # ← Claude Code only
└── ...
In your CLAUDE.md, you can write instructions that work for both:
# Agent Instructions
You are a helpful agent. [Instructions work for both Claude and Gemini]
## Tools Available
- filesystem operations
- web search
- etc.Claude Code: Uses .mcp.json file
{
"mcpServers": {
"trinity": {
"url": "http://mcp-server:8080/mcp",
"headers": {"Authorization": "Bearer KEY"}
}
}
}Gemini CLI: Uses CLI commands (Trinity handles this automatically)
gemini mcp add trinity http://mcp-server:8080/mcpTrinity translates MCP configuration to each runtime's format automatically.
You can run both Claude and Gemini agents simultaneously:
# Multi-runtime system
agents:
orchestrator:
runtime: claude-code # Complex reasoning
model: sonnet-4.5
resources: {memory: "4g"}
worker-1:
runtime: gemini-cli # Data processing
model: gemini-2.5-pro
resources: {memory: "2g"}
worker-2:
runtime: gemini-cli # Monitoring
model: gemini-2.5-pro
resources: {memory: "2g"}Cost: $2-3/day for orchestrator, $0 for workers
- Rebuild base image:
./scripts/deploy/build-base-image.sh - Gemini CLI is installed during image build
- Add to
.env:GOOGLE_API_KEY=your-key - Restart agent container
- Check
gemini mcp listinside container - Verify Trinity MCP server is accessible
- Check agent permissions
Gemini Free Tier Limits:
- 60 requests/minute
- 1,000 requests/day
- If exceeded, agent will fail with rate limit error
Workaround: Mix Claude and Gemini agents to stay within limits.
- Test: Create a test agent with
local:test-geminitemplate - Compare: Run same task on Claude and Gemini agents
- Optimize: Move simple tasks to Gemini, keep complex ones on Claude
- Monitor: Track costs via
/api/observability/metrics