openclaw - ✅(Solved) Fix feat: add Portkey AI gateway provider extension [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72008Fetched 2026-04-27 05:36:09
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Assignees
Timeline (top)
labeled ×2assigned ×1closed ×1commented ×1

Add a new bundled provider extension for Portkey, an AI gateway that provides a unified OpenAI-compatible API to 250+ LLM providers with observability, caching, fallbacks, load balancing, and cost tracking.

Root Cause

Add a new bundled provider extension for Portkey, an AI gateway that provides a unified OpenAI-compatible API to 250+ LLM providers with observability, caching, fallbacks, load balancing, and cost tracking.

Fix Action

Fixed

PR fix notes

PR #71995: feat(extension): add new portkey extension

Description (problem / solution / changelog)

Summary

  • Problem: OpenClaw has no Portkey provider extension — users cannot route LLM requests through Portkey's AI gateway.
  • Why it matters: Portkey provides a unified gateway to 250+ LLM providers with observability, caching, fallbacks, and load balancing — a popular alternative to LiteLLM.
  • What changed: Added a new extensions/portkey/ bundled provider plugin with chat completions and image generation support, following the same pattern as the existing litellm extension. Added GitHub labeler entry for extensions: portkey.
  • What did NOT change (scope boundary): No core code modified. No changes to the plugin SDK, gateway, or any other extension. No docs page added (can follow separately).

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #72008
  • This PR fixes a bug or regression

Root Cause (if applicable)

N/A — new feature.

Regression Test Plan (if applicable)

N/A — new feature. Tests added:

  • extensions/portkey/onboard.test.ts — verifies config merge preserves existing baseUrl/api key
  • extensions/portkey/image-generation-provider.test.ts — 8 tests covering provider registration, auth header format (x-portkey-api-key), base URL, count/size forwarding, edit endpoint routing, missing key error, dispatcher policy
  • extensions/portkey/portkey.live.test.ts — live API test (requires PORTKEY_API_KEY)

User-visible / Behavior Changes

  • New provider portkey available in provider selection and onboarding wizard
  • New CLI flag --portkey-api-key for authentication
  • New env var PORTKEY_API_KEY for authentication
  • New image generation provider portkey registered

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? Yes — new provider plugin with API key auth
  • Secrets/tokens handling changed? No — uses existing plugin SDK auth patterns
  • New/changed network calls? Yes — calls https://api.portkey.ai/v1 for chat completions and image generation
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation: API key sent via x-portkey-api-key header (Portkey's standard auth). Key storage follows the same credential patterns as all other providers. No private-network auto-allow — Portkey is a public cloud endpoint.

Repro + Verification

Environment

  • OS: macOS (Darwin 25.2.0)
  • Runtime/container: Node 22+
  • Model/provider: Portkey gateway → Claude Opus 4.6
  • Integration/channel: N/A
  • Relevant config: PORTKEY_API_KEY env var

Steps

  1. pnpm install
  2. pnpm test extensions/portkey — run unit tests (9 tests)
  3. PORTKEY_API_KEY=<key> pnpm test:live -- extensions/portkey/portkey.live.test.ts — run live test

Expected

  • All 9 unit tests pass
  • Live test completes a chat request through Portkey and receives a valid response

Actual

  • 9/9 unit tests pass
  • 2/2 live tests pass (chat completion returned "OK" in ~4s)

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Unit tests: Test Files 2 passed (2) | Tests 9 passed (9) Live tests: Test Files 1 passed (1) | Tests 2 passed (2) | Duration 7.26s

Human Verification (required)

  • Verified scenarios: unit tests pass, live API call through Portkey succeeds, pnpm install registers the workspace package
  • Edge cases checked: missing API key throws clear error, custom baseUrl overrides work, dispatcher policy forwarding
  • What you did not verify: image generation live API call (only registration tested), docs page

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes — purely additive, no existing code changed
  • Config/env changes? Yes — new PORTKEY_API_KEY env var (optional, only used if provider is selected)
  • Migration needed? No

Risks and Mitigations

  • Risk: Portkey API changes auth header format or base URL in the future.
    • Mitigation: allowExplicitBaseUrl: true lets users override. Auth follows standard plugin SDK patterns that are easy to update.

Changed files

  • .github/labeler.yml (modified, +5/-0)
  • extensions/portkey/api.ts (added, +8/-0)
  • extensions/portkey/image-generation-provider.test.ts (added, +231/-0)
  • extensions/portkey/image-generation-provider.ts (added, +178/-0)
  • extensions/portkey/index.ts (added, +45/-0)
  • extensions/portkey/onboard.test.ts (added, +21/-0)
  • extensions/portkey/onboard.ts (added, +55/-0)
  • extensions/portkey/openclaw.plugin.json (added, +32/-0)
  • extensions/portkey/package.json (added, +15/-0)
  • extensions/portkey/portkey.live.test.ts (added, +56/-0)
  • extensions/portkey/provider-catalog.ts (added, +10/-0)
  • extensions/portkey/tsconfig.json (added, +16/-0)
  • pnpm-lock.yaml (modified, +6/-0)
RAW_BUFFERClick to expand / collapse

Summary

Add a new bundled provider extension for Portkey, an AI gateway that provides a unified OpenAI-compatible API to 250+ LLM providers with observability, caching, fallbacks, load balancing, and cost tracking.

Motivation

Portkey is a widely used AI gateway (similar to LiteLLM and OpenRouter) that many teams use in production for routing, reliability, and observability across multiple LLM providers. OpenClaw currently has no Portkey integration, requiring users to manually configure it as a custom OpenAI-compatible endpoint.

Proposed Scope

  • New extensions/portkey/ bundled provider plugin
  • Chat completions via OpenAI-compatible API (https://api.portkey.ai/v1)
  • Image generation support (OpenAI-compatible /images/generations and /images/edits)
  • Authentication via PORTKEY_API_KEY env var / --portkey-api-key CLI flag
  • Auth header: x-portkey-api-key (Portkey's native auth)
  • Configurable base URL for self-hosted gateway users
  • Unit tests and live API tests
  • GitHub labeler entry

References

extent analysis

TL;DR

Implement a new bundled provider extension for Portkey by creating a plugin in the extensions/portkey/ directory to support chat completions and image generation via the OpenAI-compatible API.

Guidance

  • Create a new directory extensions/portkey/ to hold the Portkey plugin and add the necessary files for the plugin implementation.
  • Implement authentication using the PORTKEY_API_KEY environment variable or the --portkey-api-key CLI flag, and set the x-portkey-api-key auth header for API requests.
  • Develop unit tests and live API tests to ensure the plugin works correctly with the Portkey API.
  • Add a configurable base URL option for users with self-hosted Portkey gateways.

Example

No code example is provided as the issue does not contain sufficient technical details for a specific implementation.

Notes

The implementation details may vary depending on the existing architecture and codebase of OpenClaw, and additional research may be required to ensure compatibility with Portkey's API.

Recommendation

Apply workaround by implementing the proposed plugin and testing it thoroughly to ensure compatibility and functionality.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix feat: add Portkey AI gateway provider extension [1 pull requests, 1 comments, 2 participants]