Files
AIPass/src/aipass/api
AIOSAIandClaude Opus 4.6 3b45824dc6 FPLAN-0410 repo cleanup + integration test bug fixes
VERA cleanup (FPLAN-0410):
- Remove all /home/aipass hardcoded paths (portability)
- Remove internal Telegram bot code from public repo (6k+ lines)
- Remove runtime logs, .claude/settings.local.json, stale files
- Clean READMEs across all branches
- Restructure spawn handlers into proper 3-layer architecture
- Add __init__.py files for proper package imports
- Update seedgo standards for public repo context
- Add log_structure standard to seedgo

Integration test bug fixes:
- Fix double @@ display in drone introspection output
- Fix spawn registry resolving to wrong file (walk up from package root)
- Fix email sender identity always showing as @ai_mail (pass AIPASS_CALLER_CWD)
- Fix branch_detection.py relative path resolution against CWD instead of registry dir
- Add .trinity/passport.json detection for spawned agents
- Archive duplicate json_ops.py, update imports to canonical json_handler
- Update .gitignore for runtime logs and .claude/ dirs

Tested end-to-end in Docker container (aipass-test:latest):
- Spawn → register → send email → receive → reply all verified working

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 15:29:16 -08:00
..
2026-03-06 20:40:16 +00:00
2026-03-06 20:40:16 +00:00

API

Purpose: LLM API access layer with provider abstraction, key management, model routing, and usage tracking. Module: aipass.api


Overview

What I Do

  • Manage API keys for LLM providers (currently OpenRouter)
  • Route requests to LLM models with provider-level abstraction
  • Track API usage metrics and provide statistics
  • Validate credentials and test provider connectivity
  • Discover available models from configured providers

How I Work

  • Entry Point: apps/api.py -- auto-discovers and routes to modules
  • Pattern: Standard AIPass 3-tier architecture (entry point / modules / handlers)

CLI

drone @api get-key           # Retrieve API key for provider
drone @api validate          # Validate API credentials and connection
drone @api test              # Test OpenRouter connection status
drone @api models            # List available models from provider
drone @api track             # Track API usage metrics
drone @api stats             # Display API usage statistics
drone @api --help            # Full help output

Architecture

api/
├── __init__.py                    # Public API exports
├── apps/
│   ├── api.py                     # Entry point (module discovery, command routing)
│   ├── modules/
│   │   ├── api_key.py             # Key retrieval and validation logic
│   │   ├── openrouter_client.py   # OpenRouter API client
│   │   └── usage_tracker.py       # Usage metrics tracking
│   └── handlers/
│       ├── auth/
│       │   ├── env.py             # Environment variable credential loading
│       │   └── keys.py            # API key storage and retrieval
│       ├── config/
│       │   └── provider.py        # Provider configuration management
│       ├── json/
│       │   └── json_handler.py    # JSON operation logging
│       ├── openrouter/
│       │   ├── caller.py          # HTTP request execution
│       │   ├── client.py          # OpenRouter client implementation
│       │   ├── models.py          # Model discovery and listing
│       │   └── provision.py       # Provider provisioning
│       └── usage/
│           ├── aggregation.py     # Usage data aggregation
│           ├── cleanup.py         # Usage data cleanup
│           └── tracking.py        # Usage event tracking
└── README.md

Integration Points

Depends On

  • aipass.prax -- structured logging via system_logger
  • aipass.cli -- Rich console output formatting

Provides To

  • All modules -- LLM API access for any branch that needs model inference
  • System-wide API key management and credential validation