feat: add API key selection by ID with priority over name selection#1941
feat: add API key selection by ID with priority over name selection#1941Pratham-Mishra04 wants to merge 1 commit intomainfrom
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis change introduces a new API key selection mechanism using Changes
Sequence DiagramsequenceDiagram
participant Client
participant Transport as HTTP Transport<br/>(bifrost-http)
participant Core as Core Logic<br/>(bifrost)
participant KeyStore as Key Store
Client->>Transport: Request with x-bf-api-key-id<br/>or x-bf-api-key header
Transport->>Transport: Parse headers into context
Transport->>Core: ResolveAPIKey(ctx)
Core->>Core: Check if APIKeyID present?
alt APIKeyID Present
Core->>KeyStore: Find key by ID
KeyStore-->>Core: Return key or error
else APIKeyID Not Present
Core->>Core: Check if APIKeyName present?
alt APIKeyName Present
Core->>KeyStore: Find key by name
KeyStore-->>Core: Return key or error
else Neither Present
Core-->>Core: Return error
end
end
Core-->>Client: Return API key or error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
43c4afc to
12b2519
Compare

Summary
Adds support for explicit API key selection by ID through a new
BifrostContextKeyAPIKeyIDcontext key andx-bf-api-key-idheader. When both key ID and key name are provided, the ID takes priority over name-based selection.Changes
BifrostContextKeyAPIKeyIDconstant for key selection by IDselectKeyFromProviderForModelto prioritize ID over namex-bf-api-key-idheader support in HTTP transport layerType of change
Affected areas
How to test
Test key selection by ID:
Test with Go SDK:
Run standard tests:
Screenshots/Recordings
N/A - Backend API enhancement
Breaking changes
This is an additive feature that maintains backward compatibility with existing key name selection.
Related issues
N/A
Security considerations
The new key ID selection follows the same security model as existing key name selection. Key IDs are resolved server-side against configured provider keys, maintaining the same access control and validation patterns.
Checklist
docs/contributing/README.mdand followed the guidelines