Documentation Index
Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Available on all Portkey plans.
Creating Configs
Navigate to the ‘Configs’ page in the Portkey app and click ‘Create’ to start writing a new config.Using Configs
Configs are supported across all integrations.- Through the config parameter of the Portkey SDK client(Directly or via frameworks)
- Through the config headers in the OpenAI SDK
- Via the REST API through the
x-portkey-configheader
Applying Gateway Configs
Gateway configs allow you to unlock the gateway superpowers of Portkey. You can create a config in the UI and attach it’s config id in the OpenAI client.- NodeJS
- Python
- OpenAI NodeJS
- OpenAI Python
- cURL
Note: If you have a default configuration set in the client, but also include a configuration in a specific request, the request-specific configuration will take precedence and replace the default config for that particular request.
- NodeJS
- Python
- OpenAI NodeJS
- OpenAI Python
You can also add the config JSON as a string instead of the slug.
Setting Default Configs on API Keys
You can attach a default config directly to an API key, which means all requests made with that key will automatically use the specified config without needing to include it in each request. This is particularly useful for:- Integrations that don’t support custom headers (like Open WebUI, LibreChat, and other OpenAI-compatible interfaces)
- Enforcing organization-wide governance policies without requiring code changes
- Centralized configuration management where all applications using a specific API key share the same routing, fallbacks, and caching rules
x-portkey-config header.
To set a default config on an API key:
- Navigate to API Keys in the Portkey dashboard
- Create a new API key or edit an existing one
- In the API key settings, select a config from the Default Config dropdown
- Save the API key
If you specify a config in a request (via headers or SDK parameters), it will override the default config for that specific request. The default config only applies when no config is specified in the request itself.
Default and drop params
Each config target can shape the request body before it reaches the upstream provider with three parameter fields:| Field | Behavior |
|---|---|
default_params | Injects parameters into the request body only when not already present. Unlike override_params, this respects values set by the client. |
override_params | Always overwrites the matching field on the request body. |
drop_params | Removes parameters from the final request body using dot-notation paths. Supports nested keys and array indices (e.g., tools.0.function.name). |
default_params → override_params → drop_params. All three fields inherit through nested target configs the same way override_params does — values defined on a parent target apply to its children unless overridden.
Example
- If the client does not send
temperatureormax_tokens, the gateway injects the defaults; if the client does send them, the client’s values win. modelis always rewritten togpt-4oregardless of what the client sends.logprobsand the nestedtools[0].function.strictfield are stripped before the request is forwarded.
Passthrough targets
Passthrough targets allow config targets to defer provider resolution to the incoming request, instead of specifying a fixed provider in the config itself. This is useful when you want to define routing strategies (conditional, fallback, loadbalance) at the config level but let the caller decide which provider to use at request time.How it works
A target with"passthrough": true does not require a provider or virtual_key field. Instead, the gateway resolves the provider from the incoming request using the following sources, in priority order:
x-portkey-providerheader — If the value starts with@(e.g.,@anthropic-dev), the slug after@is used as the virtual key.- Request body
modelfield — If the model uses the@slug/model-nameformat (e.g.,@anthropic-dev/claude-sonnet-4-20250514), the slug is extracted as the virtual key and the model name is passed through to the provider.
Config schema
Set thepassthrough property to true on a target to enable passthrough resolution:
Example: Fallback with passthrough targets
Example: Load balancing with passthrough targets
When using passthrough targets, the incoming request must include provider information through one of the supported resolution methods. If the gateway cannot resolve a provider, the request will fail for that target.

