Skip to content

feat: Introduce custom-host provider with configurable base URL and API key support.#1513

Open
Jaiaggarwaaaaal wants to merge 2 commits intoPortkey-AI:mainfrom
Jaiaggarwaaaaal:feat/proxy-passthrough
Open

feat: Introduce custom-host provider with configurable base URL and API key support.#1513
Jaiaggarwaaaaal wants to merge 2 commits intoPortkey-AI:mainfrom
Jaiaggarwaaaaal:feat/proxy-passthrough

Conversation

@Jaiaggarwaaaaal
Copy link

@Jaiaggarwaaaaal Jaiaggarwaaaaal commented Jan 29, 2026

feat: Introduce custom-host provider for arbitrary proxy support

Description:
This PR introduces a new custom-host provider to the Gateway. This feature allows users to proxy requests to any configurable base URL, enabling integration with LLM providers or services that are not natively supported by the Gateway. It supports dynamic configuration of the target endpoint and API key authentication.

Detailed changes:

  • New Provider: Added custom-host provider implementation in src/providers/custom-host/.
  • Registration: Registered the new provider in src/providers/index.ts.
  • Type Definitions: Updated src/types/requestBody.ts to include custom-host configuration types.
  • Global Config: Updated src/globals.ts to support the new provider constant.

Tests Run/Test cases added:

  • Verified request forwarding to a custom HTTP endpoint.
  • Verified correct propagation of Authorization headers/API keys.
  • Tested error handling for unreachable hosts.

Type of Change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
Screenshot 2026-01-29 at 5 49 14 PM
Screenshot 2026-01-29 at 5 50 29 PM
curl --location 'http://localhost:8788/v1/v2/vectordb/collections/list' \
--header 'x-portkey-custom-host: https://httpbin.org/anything' \
--header 'Authorization: Bearer test' \
--header 'x-portkey-provider: openai' \
--header 'Content-Type: application/json' \
--data '{"test": "payload"}'
curl --location 'http://localhost:8788/v1/chat/completions' \
--header 'x-portkey-custom-host: https://httpbin.org/anything' \
--header 'Authorization: Bearer test' \
--header 'x-portkey-provider: openai' \
--header 'Content-Type: application/json' \
--data '{"model": "gpt-4o", "messages": [{"role": "user", "content": "hi"}]}'
curl --location 'http://localhost:8788/v1/upload' \
--header 'x-portkey-custom-host: https://httpbin.org/anything' \
--header 'x-portkey-provider: openai' \
-F 'file=@/Users/jaiaggarwal/gateway/package.json' \
-F 'purpose=fine-tune'

@@ -0,0 +1,30 @@
import { VALID_PROVIDERS } from './src/globals';
Copy link
Member

Choose a reason for hiding this comment

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

is this a test file?
you might've commited it by mistake

Copy link
Member

@narengogi narengogi Jan 29, 2026

Choose a reason for hiding this comment

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

i see that there is no request body in your requests

can you test the behaviour with one of the unified routes like /v1/chat/completions and any arbitrary route like v1/my/custom/route ?

and can you try with different payloads like json and multipart-formdata?

…improve provider validation and error handling.
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