How to Use Per-Session API Keys
Override your account-level API key for specific sessions.
When to Use This
- • Different providers: Use OpenAI for one session, Anthropic for another
- • Cost management: Separate keys for personal vs work projects
- • Team collaboration: Share a session with a team key
- • Testing: Try new models without affecting account default
How It Works
filepath supports a 3-tier key resolution:
- Session key (if set) Highest priority
- User account key (your default)
- Global env key (for e2e tests only)
If you set a per-session key, all agents in that session use it instead of your account key.
Setting a Session Key
During Session Creation
- Click New Session
- Fill in name and repo (optional)
- Expand Advanced Options
- Paste your API key
- Click Create
After Session Creation
- Open the session
- Click Session Settings (gear icon)
- Go to Provider API Key tab
- Toggle "Use different key for this session"
- Paste the new key
- Click Save
The change applies immediately to:
- Existing agents (next message they receive)
- New agents spawned in this session
Removing a Session Key
- Go to Session Settings / Provider API Key
- Click Remove Session Key
- Confirm
Agents will revert to using your account-level key.
Encryption & Security
Session keys are:
- Encrypted with AES-GCM (same as account keys)
- Never logged or exposed in UI
- Only decrypted when spawning containers
- Isolated to that session only
Even filepath admins cannot see your keys.
Use Cases
Different Models
Session A: OpenAI GPT-4 for analysis tasks
Session B: Claude for creative writing
Team Projects
- Personal account key: your individual work
- Session key: shared team key for group project
Client Work
- Account key: internal projects
- Session A key: Client A's OpenAI key
- Session B key: Client B's Anthropic key
Monitoring Usage
filepath tracks usage per-session:
- Go to Session Settings
- View Usage Stats
- See: tokens used, API calls, estimated cost
Troubleshooting
"Invalid API key" error
Check the key is valid with the provider directly
"No API key configured for this session"
Either add a session key or ensure account key is set
Session key not being used
Changes apply to NEW messages. Existing in-flight agents may still use old key.
Best Practices
- • Use account key by default — Simpler, applies everywhere
- • Session keys for exceptions — Different providers, team sharing
- • Rotate regularly — Both account and session keys
- • Monitor costs — Track which sessions are expensive
- • Delete unused keys — Remove session keys when session is deleted