Skip to main content
Salesforce lets you bring your own model (BYOLLM) to Agentforce through the LLM Open Connector. The connector speaks a subset of the OpenAI Chat Completions API, so the AI Gateway’s /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

  1. Go to Model Catalog → Add Provider.
  2. Select your provider (OpenAI, Anthropic, Bedrock, etc.), enter its credentials, and set a slug like openai-prod.
  3. Go to API Keys → Create new key → Save.
The model ID you give Salesforce is @<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

  1. In Salesforce, open Einstein Studio (in the Data Cloud app) and go to Model Builder.
  2. Click Add Foundation Model, then choose to connect your own LLM with the LLM Open Connector.
  3. Fill in the connection:
  1. 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

  1. Select the new model in the Model Library and click New Configuration.
  2. Send a prompt in the Model Playground.
  3. Check that the request appears in the AI Gateway logs in Strata Cloud Manager.
  4. 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 send x-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:
  1. Create the config in Configs in Strata Cloud Manager and copy its ID.
  2. 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.

Troubleshooting

Resources

Last modified on October 17, 2026