platform-models-api-configure
Original:🇺🇸 English
Translated
1 scripts
Configure (or troubleshoot) an AI coding agent or CLI to route through the Salesforce Models API using a signed OrgJWT. Use this skill when pointing an agent at the Salesforce model endpoint (api.salesforce.com/ai/gpt/v1), setting up OrgJWT / Bedrock-mode auth, wiring the agent's settings, API-key helper, and credentials file for the Salesforce endpoint, or fixing Models API 401 / 404 / "model not available" errors. DO NOT TRIGGER when the user needs to create or configure the Salesforce Connected App itself (use integration-connectivity-connected-app-configure) or set up Named Credentials / callout auth (use integration-connectivity-generate).
3installs
Sourceforcedotcom/sf-skills
Added on
NPX Install
npx skill4agent add forcedotcom/sf-skills platform-models-api-configureTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Salesforce Models API setup for an AI coding agent
The Salesforce Models API () is
authenticated with a signed OrgJWT (obtained via with
the scope — see ; no proxy). That auth and the
base URL are the same for any agent. How each agent then talks to the
endpoint is agent-specific: Anthropic clients (Claude Code and the Claude
Agent SDK) route through Bedrock mode (the env vars in Step 3), whereas
other agents (e.g. Codex) use their own client config against the same endpoint
and token — Bedrock mode does not apply to them.
https://api.salesforce.com/ai/gpt/v1client_credentialssfap_apiscripts/get-orgjwt.shThe steps below are the Claude Code / Claude Agent SDK reference
implementation (Bedrock mode + a JSON settings file + an API-key helper). For
a non-Bedrock agent, reuse the OrgJWT auth (Step 1) and the base URL, and apply
the equivalent client settings in that agent's own config location instead of
the Bedrock env vars.
Bundled scripts are in . Path placeholders below: = the
absolute path to this skill's own directory (the folder containing this
; resolve it from the skill path in context). = the absolute
path to the user's project root. Always emit fully resolved absolute paths —
the API-key helper runs from an undefined working directory, so relative paths
break it.
scripts/<SKILL>SKILL.md<ABS>Prerequisite
A connected app in the org with the OAuth scope and the
client_credentials flow enabled (consumer key/secret + a run-as user).
Setup steps: https://developer.salesforce.com/docs/ai/agentforce/guide/access-models-api-with-rest.html
+ installed.
sfap_apicurljqInputs to collect
- — org My Domain, e.g.
SF_INSTANCE_URLhttps://acme.my.salesforce.com - ,
SF_CLIENT_ID— connected-app consumer key/secretSF_CLIENT_SECRET - Models API base URL:
https://api.salesforce.com/ai/gpt/v1 - Model: a fully qualified name, e.g.
sfdc_ai__…(full list: https://developer.salesforce.com/docs/ai/agentforce/guide/supported-models.html)sfdc_ai__DefaultBedrockAnthropicClaude46Sonnet - Scope: project (, default) or user (
<cwd>/.claude/settings.json) — reference-agent settings paths~/.claude/settings.json - Headers — =
<FEAT>(defaultx-client-feature-id),ai-platform-models-connected-app=<APP>(defaultx-sfdc-app-context). Used in the Step 2 verify curl and inEinsteinGPT.ANTHROPIC_CUSTOM_HEADERS
Steps (reference implementation)
Concrete values for a JSON-settings + API-key-helper agent. Reuse the OrgJWT
auth, verify curl, and base URL verbatim for any agent; adapt the settings-file
location and env-var wiring to the target agent.
- Write (chmod 600), gitignore it:
<project>/.claude/.orgjwt.enviniSF_INSTANCE_URL="..." SF_CLIENT_ID="..." SF_CLIENT_SECRET="..." - Verify — must return before writing settings:
200bashTOKEN=$(bash <SKILL>/scripts/get-orgjwt.sh <ABS>/.claude/.orgjwt.env) curl -s -o /dev/null -w '%{http_code}\n' \ <MODELS_API_URL>/model/<MODEL>/invoke-with-response-stream \ -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \ -H 'x-client-feature-id: <FEAT>' -H 'x-sfdc-app-context: <APP>' \ --data '{"anthropic_version":"bedrock-2023-05-31","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}' - Write (merge into existing; keep other keys):
.claude/settings.jsonUse absolute paths injson{ "apiKeyHelper": "bash <SKILL>/scripts/get-orgjwt.sh <ABS>/.claude/.orgjwt.env", "model": "<MODEL>", "env": { "ANTHROPIC_AUTH_TOKEN": "", "CLAUDE_CODE_USE_BEDROCK": "1", "CLAUDE_CODE_SKIP_BEDROCK_AUTH": "1", "ANTHROPIC_BEDROCK_BASE_URL": "<MODELS_API_URL>", "ANTHROPIC_SMALL_FAST_MODEL": "<MODEL>", "ANTHROPIC_DEFAULT_MODEL": "<MODEL>", "ANTHROPIC_CUSTOM_HEADERS": "x-client-feature-id: <FEAT>\nx-sfdc-app-context: <APP>" } }. (apiKeyHelper/<FEAT>defaults are in "Inputs to collect" above.)<APP> - Tell the admin to fully restart the agent (for the reference agent) — settings and the API-key helper load at startup only.
claude
Capturing as a runbook (when asked to document, not apply)
If the user wants the setup written up for review instead of applied to their
machine (e.g. "save it as a Markdown runbook"), write all of the above into
the requested file (e.g. ), in order and self-contained:
the exact contents, the + gitignore note, the
verification curl (with the "must be before writing settings" note), the
full block with every key from Step 3, and the final
"fully restart " step. Don't omit any of the nine keys.
models-api-setup-runbook.md.orgjwt.envchmod 600200settings.jsonclaudesettings.jsonVerify before finishing
- created,
.claude/.orgjwt.env, and gitignoredchmod 600 - Verification curl returned HTTP before
200was writtensettings.json - set to
ANTHROPIC_AUTH_TOKENin""settings.json - set to
CLAUDE_CODE_USE_BEDROCK"1" - set to
CLAUDE_CODE_SKIP_BEDROCK_AUTH"1" - is exactly
ANTHROPIC_BEDROCK_BASE_URL(no trailing slash/path)https://api.salesforce.com/ai/gpt/v1 - ,
model, andANTHROPIC_DEFAULT_MODELall use the fully qualifiedANTHROPIC_SMALL_FAST_MODELaliassfdc_ai__… - contains
ANTHROPIC_CUSTOM_HEADERSandx-client-feature-idx-sfdc-app-context - uses absolute paths (
apiKeyHelper)bash <SKILL>/scripts/get-orgjwt.sh <ABS>/.claude/.orgjwt.env - User told to fully restart
claude
Must be exact (each prevents a specific failure)
- — clears any global token that would otherwise outrank
"ANTHROPIC_AUTH_TOKEN": ""(precedence:apiKeyHelper>ANTHROPIC_AUTH_TOKENANTHROPIC_API_KEY). Without it → wrong/old bearer → 401/404.apiKeyHelper - — activates the Bedrock API client; without it Claude Code uses the standard Anthropic API protocol and ignores
CLAUDE_CODE_USE_BEDROCK=1entirely, so every call bypasses the Models API.ANTHROPIC_BEDROCK_BASE_URL - — else Claude Code overwrites
CLAUDE_CODE_SKIP_BEDROCK_AUTH=1with AWS SigV4 and the OrgJWT never lands.Authorization - must be invoked as
apiKeyHelper(avoids exit-126).bash <path> <credsfile> - Model must be a fully qualified name (see supported models).
sfdc_ai__… - Auth is the OrgJWT from (a signed JWT, 2 dots, scope
client_credentials) — NOTsfap_api(unsigned session token → 404).sf org displayCLI has no client_credentials command; the helper callssf./services/oauth2/token - Only routes; no tenant-id header needed.
ANTHROPIC_BEDROCK_BASE_URL
Diagnose
| Error | Meaning | Check first |
|---|---|---|
| Token is not a valid OrgJWT | Connected App |
| Token valid but model/env/org not routable | Fully qualified |
| Non-alias model id | Replace with a fully qualified |