Overview
Payload injection operates in two modes:- Default: Only sets parameters if they are missing in the original request
- Override: Always overwrites parameters, even if present in the original request
config.yaml and apply to models matching specific patterns and protocols.
Configuration
Add thepayload section to your config.yaml:
Rule Structure
Model Matching
Each rule specifies which models it applies to:*matches zero or more charactersgemini-*matchesgemini-2.5-pro,gemini-3-flash, etc.gpt-*-turbomatchesgpt-3.5-turbo,gpt-4-turbo, etc.*matches all models
openai- OpenAI-compatible endpointsgemini- Google Gemini APIclaude- Anthropic Claude APIvertex- Google Vertex AI
Parameters
Parameters use dot notation to specify nested JSON paths:Default vs Override
Default Mode
Defaults only set parameters if they are missing from the original request:Override Mode
Overrides always overwrite parameters, regardless of their presence:Common Use Cases
1. Enforce Thinking Budget for Gemini
Ensure all Gemini reasoning models use a minimum thinking budget:2. Set Default Temperature Across All Models
3. Inject User Metadata for Tracking
Track all requests with organizational metadata:4. Enforce Context Limits
Prevent clients from requesting excessive tokens:5. Provider-Specific Configurations
Apply different defaults per provider:Advanced Patterns
Multi-Protocol Rules
Apply the same parameters to multiple protocols:Conditional Parameters by Model Tier
Different configurations for different model tiers:Nested Configuration Objects
Build complex nested configurations:Debugging
Enable Debug Logging
Setdebug: true in config.yaml to see payload injection logs:
Verify Parameters
Use the Management Dashboard to inspect outgoing requests:- Open http://localhost:18080/dashboard
- Navigate to Request Inspector
- View the Modified Payload section
Testing Payload Injection
Testing Payload Injection
Send a test request and verify the injected parameters:Check the debug logs to confirm injection occurred.
Precedence Rules
Default Rules
For default mode:- First write wins per field across all matching rules
- If a field exists in the original request, it is never overwritten
- Rules are evaluated in the order they appear in
config.yaml
Override Rules
For override mode:- Last write wins per field across all matching rules
- Fields are always overwritten, even if present in the original request
- Rules are evaluated in the order they appear in
config.yaml
Combined Example
Protocol-Specific Paths
Different protocols use different JSON structures. switchAILocal handles this automatically:Gemini API (Standard)
Parameters apply to the root payload:Gemini CLI API
Parameters are nested underrequest:
OpenAI API
Claude API
Limitations
- Array parameters are not supported for partial updates (entire array is replaced)
- Cannot delete fields, only add or overwrite
- No conditional logic within a single rule (use multiple rules instead)
- Parameters must be valid JSON types (string, number, boolean, object)
See Also
- Lua Plugins - For dynamic request transformation
- Configuration Reference - Complete config.yaml options
- Model Routing - Intelligent model selection