/v1/chat/completions endpoint works with it directly. You don’t need middleware.
With the AI Gateway in between, Salesforce can use any model in your Model Catalog, and every request shows up in the AI Gateway logs with cost, latency and token counts.
Prerequisites
- AI Gateway API key
- Provider configured in Model Catalog
- Salesforce org with Data Cloud and Einstein generative AI enabled, and permission to use Model Builder
Setup
1
Configure the AI Gateway
- Go to Model Catalog → Add Provider.
- Select your provider (OpenAI, Anthropic, Bedrock, etc.), enter its credentials, and set a slug like
openai-prod. - Go to API Keys → Create new key → Save.
@<provider-slug>/<model>, for example @openai-prod/gpt-5.2
Test the endpoint
Salesforce sends a request like this one. Run it first to confirm the key and model work:On a hybrid deployment, replace
https://aigw.portkey.ai with your gateway’s URL.3
Add the AI Gateway as a foundation model
- In Salesforce, open Einstein Studio (in the Data Cloud app) and go to Model Builder.
- Click Add Foundation Model, then choose to connect your own LLM with the LLM Open Connector.
- Fill in the connection:
- Save the connection.
Salesforce sends one auth header and nothing else, so you can’t add other
x-portkey-* headers here. To route or add fallbacks, attach a default config to the API key (see below).4
Create a configured model
- Select the new model in the Model Library and click New Configuration.
- Send a prompt in the Model Playground.
- Check that the request appears in the AI Gateway logs in Strata Cloud Manager.
- Save the configuration.
Use the model in Salesforce
Once saved, the configured model is available wherever Salesforce lets you pick a generative model:- Prompt Builder: select it as the model for a prompt template.
- Agentforce: add a prompt template that uses the model to an agent as an action.
- Models API: call it by its API name from Apex or REST. Find the API name on the configured model’s detail page.
The LLM Open Connector supports text chat only. It doesn’t send tool definitions, images or streaming requests. Use the AI Gateway model for prompt templates and Models API calls, not for features that need tool calling.
Add fallbacks and routing
Salesforce can’t sendx-portkey-config, so attach a default config to the API key you entered in Model Builder. Every request from Salesforce then uses that config.
Example: try OpenAI first, fall back to Anthropic on errors:
- Create the config in Configs in Strata Cloud Manager and copy its ID.
- Go to API Keys, edit the key Salesforce uses, and select the config.
override_params rewrites the model in each request, so the Model Name in Salesforce becomes a label. Keep it in @slug/model form anyway so the connection still works if the config is removed.
To cap spend for Salesforce traffic, set budget limits on the integration for the workspace the API key belongs to, or give Salesforce its own workspace.

