Skip to content

docs: direct api key - #4208

Merged
Pratham-Mishra04 merged 1 commit into
devfrom
06-09-docs_direct_api_key
Jun 9, 2026
Merged

docs: direct api key#4208
Pratham-Mishra04 merged 1 commit into
devfrom
06-09-docs_direct_api_key

Conversation

@TejasGhatte

@TejasGhatte TejasGhatte commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Documents the new allow_direct_keys gateway configuration option and the BifrostContextKeyDirectKey context key, which together allow callers to supply a raw provider API key directly to Bifrost, bypassing the registered key pool. This is intended for multi-tenant setups where each caller manages their own provider credentials.

Changes

  • Added allow_direct_keys boolean field to the client config and schema reference tables, defaulting to false
  • Added a new Direct API Key section to request-options.mdx covering gateway usage (via x-bf-direct-key: true + a raw key in Authorization, x-api-key, or x-goog-api-key) and Go SDK usage (via BifrostContextKeyDirectKey)
  • Added x-bf-direct-key to the security denylist so it cannot be forwarded to providers via x-bf-eh-* extra headers
  • Added BifrostContextKeyDirectKey to the Go SDK context keys reference and quickstart guide, including a warning that it bypasses governance, weighted selection, and key rotation/fallback
  • Documented the double-gate requirement on the gateway: both allow_direct_keys must be enabled server-side and the caller must send x-bf-direct-key: true; virtual keys in those headers are not treated as direct keys

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

  1. Verify the allow_direct_keys entry appears correctly in the client config and schema reference pages.
  2. Confirm the Direct API Key section renders in request-options.mdx with the cURL and Go SDK tabs.
  3. Confirm x-bf-direct-key appears in the security denylist section.
  4. Confirm BifrostContextKeyDirectKey appears in the Go SDK context keys table and quickstart guide.

Breaking changes

  • Yes
  • No

Security considerations

allow_direct_keys is off by default and requires explicit opt-in by the server admin. When enabled, raw provider secrets are passed by callers and used directly — bypassing all of Bifrost's key governance, rate limiting, and rotation. The x-bf-direct-key header is added to the security denylist to prevent it from being forwarded to upstream providers via the extra-headers mechanism. Operators should enable this only when callers are trusted to manage their own provider credentials.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

Summary by CodeRabbit

  • Documentation
    • Added "Direct API Key" request option allowing callers (when enabled) to supply a raw provider API key alongside the x-bf-direct-key header to bypass the managed key pool.
    • Documented new client.allow_direct_keys configuration to enable this behavior.
    • Updated request-option references and Go SDK context-key docs; added warning that direct keys bypass governance/rotation/selection and updated denylist handling so direct-key headers aren’t forwarded.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


tejas ghatte seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds docs for a direct API key bypass: a new client.allow_direct_keys config flag, a BifrostContextKeyDirectKey / x-bf-direct-key request option with gateway gating rules and denylist change, and Go SDK usage examples and reference entries.

Changes

Direct API Key Bypass Feature Documentation

Layer / File(s) Summary
Configuration field documentation
docs/deployment-guides/config-json/client.mdx, docs/deployment-guides/config-json/schema-reference.mdx
Adds client.allow_direct_keys boolean field (default false) to deployment guides and schema reference, documenting bypass of the registered key pool via x-bf-direct-key: true plus a raw provider key header.
Request options and security documentation
docs/providers/request-options.mdx
Adds BifrostContextKeyDirectKey / x-bf-direct-key to the request-options table and inserts a “Direct API Key” section covering double-gating (allow_direct_keys + x-bf-direct-key: true + raw-key header in Authorization/x-api-key/x-goog-api-key), non-treatment of virtual-key-prefixed values, Go SDK usage note, warning about bypassing governance, and extends the security denylist to never forward x-bf-direct-key to providers via x-bf-eh-*.
Go SDK context key documentation
docs/quickstart/go-sdk/context-keys.mdx
Adds a “Direct Key” section with a Go example showing BifrostContextKeyDirectKey set to a schemas.Key, a warning about bypassing key-pool behaviors, and a Context Keys Reference entry for BifrostContextKeyDirectKey (type schemas.Key, Set).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • maximhq/bifrost#3817: Implements the underlying direct API key bypass logic in request-context extraction and key-selection that this PR documents.
  • maximhq/bifrost#3883: Adds the allow_direct_keys schema/column changes related to this documentation update.

Suggested reviewers

  • akshaydeo
  • danpiths
  • roroghost17

Poem

🐰 I nibble at docs with a curious hop,
I note the new flag and the header on top.
Direct keys let secrets slip through,
But read the warnings — the rabbits told you! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs: direct api key' is concise and clearly summarizes the main change—documenting a new direct API key feature—matching the pull request's documentation objectives.
Description check ✅ Passed The description is comprehensive and follows the template structure, covering summary, changes, type of change, affected areas, testing steps, breaking changes, security considerations, and a mostly-complete checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 06-09-docs_direct_api_key

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@TejasGhatte
TejasGhatte marked this pull request as ready for review June 9, 2026 11:58
@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Documentation-only change that accurately reflects the existing gateway implementation; no code logic is modified.

All documented behavior — the double-gate requirement, virtual-key exclusion, three accepted key headers, and security denylist entry — was verified against transports/bifrost-http/lib/ctx.go. The schema description is now in sync with the implementation. No new executable code paths are introduced.

No files require special attention.

Important Files Changed

Filename Overview
transports/config.schema.json Schema description for allow_direct_keys updated to enumerate all three accepted key headers (Authorization, x-api-key, x-goog-api-key), resolving the previously noted out-of-sync description.
docs/providers/request-options.mdx New "Direct API Key" section and table row added; content accurately reflects the double-gate requirement, virtual-key exclusion, three accepted key headers, and security denylist entry — all verified against ctx.go.
docs/quickstart/go-sdk/context-keys.mdx New "Direct Key" section added with SDK code example and warning block; correctly notes the gateway allow_direct_keys flag only gates the HTTP path and is not required for the Go SDK.
docs/deployment-guides/config-json/client.mdx Added allow_direct_keys row to the config table with accurate default, type, and link to the request-options reference.
docs/deployment-guides/config-json/schema-reference.mdx Added allow_direct_keys row to the schema reference table; consistent with client.mdx and the updated schema JSON description.

Reviews (2): Last reviewed commit: "docs: direct api key" | Re-trigger Greptile

Comment thread docs/providers/request-options.mdx
Comment thread docs/deployment-guides/config-json/client.mdx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/providers/request-options.mdx`:
- Around line 174-185: Add an explicit guardrail paragraph to the direct-key
section: instruct operators to never log or forward raw provider credentials
(Authorization: Bearer <key>, x-api-key, x-goog-api-key) and to exclude those
headers from any logging or header-forwarding configuration (e.g.,
logging_headers), and recommend tight header filtering when allowing
allow_direct_keys or when callers set x-bf-direct-key or
BifrostContextKeyDirectKey (schemas.Key) to prevent secret exposure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 171f5371-77a6-455c-a7dd-5ee0dfeb0c13

📥 Commits

Reviewing files that changed from the base of the PR and between 23a767c and 241d20b.

📒 Files selected for processing (4)
  • docs/deployment-guides/config-json/client.mdx
  • docs/deployment-guides/config-json/schema-reference.mdx
  • docs/providers/request-options.mdx
  • docs/quickstart/go-sdk/context-keys.mdx

Comment thread docs/providers/request-options.mdx
@TejasGhatte
TejasGhatte force-pushed the 06-09-docs_direct_api_key branch from 241d20b to d109742 Compare June 9, 2026 12:16

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/deployment-guides/config-json/schema-reference.mdx`:
- Line 65: Update the schema row for the boolean field allow_direct_keys to
explicitly list accepted header sources for the raw provider key:
"Authorization: Bearer <key>", "x-api-key", and "x-goog-api-key"; modify the
description text for allow_direct_keys to read something like: Let callers
bypass the key pool with x-bf-direct-key: true plus a raw provider key supplied
via Authorization: Bearer <key>, x-api-key, or x-goog-api-key so it matches the
client config guide and schema contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 003d4940-8a55-4c3f-9131-5ab377644bf8

📥 Commits

Reviewing files that changed from the base of the PR and between 241d20b and d109742.

📒 Files selected for processing (5)
  • docs/deployment-guides/config-json/client.mdx
  • docs/deployment-guides/config-json/schema-reference.mdx
  • docs/providers/request-options.mdx
  • docs/quickstart/go-sdk/context-keys.mdx
  • transports/config.schema.json

Comment thread docs/deployment-guides/config-json/schema-reference.mdx

Pratham-Mishra04 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Merge activity

  • Jun 9, 1:55 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 9, 1:56 PM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@Pratham-Mishra04
Pratham-Mishra04 merged commit f48e5ea into dev Jun 9, 2026
15 of 16 checks passed
@Pratham-Mishra04
Pratham-Mishra04 deleted the 06-09-docs_direct_api_key branch June 9, 2026 13:56
@coderabbitai coderabbitai Bot mentioned this pull request Jun 9, 2026
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants