
Salesforce Models API Configuration
OfficialFreeEasily configure AI agents for Salesforce Models API.
Free · Opens the source repo
What Salesforce Models API Configuration does
The Salesforce Models API Configuration skill simplifies the setup process for AI coding agents to interact with the Salesforce Models API. This skill is particularly useful for developers and designers who need to authenticate their agents using a signed OrgJWT and configure the necessary settings to route requests through the API. By following a structured approach, users can avoid common pitfalls such as 401 or 404 errors when accessing the API.
This skill provides a reference implementation specifically for Claude Code and the Claude Agent SDK, leveraging Bedrock mode for seamless integration. Users will find step-by-step instructions on how to set up their environment, including writing configuration files, verifying API access, and managing authentication tokens. The bundled script, get-orgjwt.sh, is designed to facilitate the retrieval of the OrgJWT, ensuring that the authentication process is straightforward and efficient.
In addition to the setup instructions, the skill also outlines the prerequisites needed, such as having a connected app with the appropriate OAuth scope. This ensures that users are fully prepared before diving into the configuration process. The skill is tailored for those who are already familiar with Salesforce and AI agent development, providing them with the tools necessary to enhance their projects with AI capabilities.
Overall, this skill is an essential resource for developers looking to integrate AI functionalities into their Salesforce applications, providing clarity and guidance throughout the configuration process.
When to use it
Use this skill when setting up or troubleshooting AI agents that need to connect to the Salesforce Models API.
When not to use it
This skill is not suitable for creating or configuring the Salesforce Connected App itself or for setting up Named Credentials.
What you can build with it
Setting Up Claude Code
Use this skill to configure Claude Code to authenticate and connect to the Salesforce Models API.
Troubleshooting API Errors
If you encounter 401 or 404 errors, this skill provides guidance on resolving authentication issues.
Creating a Runbook
Document the setup process for future reference by capturing all steps in a Markdown runbook.
How to install Salesforce Models API Configuration
View source1. Install with the skills CLI
npx skills add forcedotcom/sf-skills/platform-models-api-configure --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by forcedotcomSalesforce Models API setup for an AI coding agent
The Salesforce Models API (https://api.salesforce.com/ai/gpt/v1) is
authenticated with a signed OrgJWT (obtained via client_credentials with
the sfap_api scope — see scripts/get-orgjwt.sh; 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.
The 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 scripts/. Path placeholders below: <SKILL> = the
absolute path to this skill's own directory (the folder containing this
SKILL.md; resolve it from the skill path in context). <ABS> = 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.
Prerequisite
A connected app in the org with the sfap_api 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
curl + jq installed.
Inputs to collect
SF_INSTANCE_URL— org My Domain, e.g.https://acme.my.salesforce.comSF_CLIENT_ID,SF_CLIENT_SECRET— connected-app consumer key/secret- Models API base URL:
https://api.salesforce.com/ai/gpt/v1 - Model: a fully qualified
sfdc_ai__…name, e.g.sfdc_ai__DefaultBedrockAnthropicClaude46Sonnet(full list: https://developer.salesforce.com/docs/ai/agentforce/guide/supported-models.html) - Scope: project (
<cwd>/.claude/settings.json, default) or user (~/.claude/settings.json) — reference-agent settings paths - Headers —
<FEAT>=x-client-feature-id(defaultai-platform-models-connected-app),<APP>=x-sfdc-app-context(defaultEinsteinGPT). Used in the Step 2 verify curl and inANTHROPIC_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
<project>/.claude/.orgjwt.env(chmod 600), gitignore it:SF_INSTANCE_URL="..." SF_CLIENT_ID="..." SF_CLIENT_SECRET="..." - Verify — must return
200before writing settings:TOKEN=$(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
.claude/settings.json(merge into existing; keep other keys):
Use absolute paths in{ "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>/<APP>defaults are in "Inputs to collect" above.) - Tell the admin to fully restart the agent (
claudefor the reference agent) — settings and the API-key helper load at startup only.
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. models-api-setup-runbook.md), in order and self-contained:
the exact .orgjwt.env contents, the chmod 600 + gitignore note, the
verification curl (with the "must be 200 before writing settings" note), the
full settings.json block with every key from Step 3, and the final
"fully restart claude" step. Don't omit any of the nine settings.json keys.
Verify before finishing
-
.claude/.orgjwt.envcreated,chmod 600, and gitignored - Verification curl returned HTTP
200beforesettings.jsonwas written -
ANTHROPIC_AUTH_TOKENset to""insettings.json -
CLAUDE_CODE_USE_BEDROCKset to"1" -
CLAUDE_CODE_SKIP_BEDROCK_AUTHset to"1" -
ANTHROPIC_BEDROCK_BASE_URLis exactlyhttps://api.salesforce.com/ai/gpt/v1(no trailing slash/path) -
model,ANTHROPIC_DEFAULT_MODEL, andANTHROPIC_SMALL_FAST_MODELall use the fully qualifiedsfdc_ai__…alias -
ANTHROPIC_CUSTOM_HEADERScontainsx-client-feature-idandx-sfdc-app-context -
apiKeyHelperuses absolute paths (bash <SKILL>/scripts/get-orgjwt.sh <ABS>/.claude/.orgjwt.env) - User told to fully restart
claude
Must be exact (each prevents a specific failure)
"ANTHROPIC_AUTH_TOKEN": ""— clears any global token that would otherwise outrankapiKeyHelper(precedence:ANTHROPIC_AUTH_TOKEN>ANTHROPIC_API_KEYapiKeyHelper). Without it → wrong/old bearer → 401/404.CLAUDE_CODE_USE_BEDROCK=1— activates the Bedrock API client; without it Claude Code uses the standard Anthropic API protocol and ignoresANTHROPIC_BEDROCK_BASE_URLentirely, so every call bypasses the Models API.CLAUDE_CODE_SKIP_BEDROCK_AUTH=1— else Claude Code overwritesAuthorizationwith AWS SigV4 and the OrgJWT never lands.apiKeyHelpermust be invoked asbash <path> <credsfile>(avoids exit-126).- Model must be a fully qualified
sfdc_ai__…name (see supported models). - Auth is the OrgJWT from
client_credentials(a signed JWT, 2 dots, scopesfap_api) — NOTsf org display(unsigned session token → 404).sfCLI has no client_credentials command; the helper calls/services/oauth2/token. - Only
ANTHROPIC_BEDROCK_BASE_URLroutes; no tenant-id header needed.
Diagnose
| Error | Meaning | Check first |
|---|---|---|
401 | Token is not a valid OrgJWT | Connected App sfap_api scope, client_credentials flow enabled, consumer key/secret in .orgjwt.env; ANTHROPIC_AUTH_TOKEN not cleared to "" |
404 | Token valid but model/env/org not routable | Fully qualified sfdc_ai__… model alias, ANTHROPIC_BEDROCK_BASE_URL exactly https://api.salesforce.com/ai/gpt/v1, org entitled for the Models API, ANTHROPIC_AUTH_TOKEN cleared |
model not available | Non-alias model id | Replace with a fully qualified sfdc_ai__… alias (see supported models) |
Frequently asked questions about Salesforce Models API Configuration
Similar skills
WinMD API Search
Easily find and explore Windows desktop APIs.
WebMCPify
Transform any web app into an agent-ready platform.
Phoenix Tracing
Instrument LLM applications with OpenInference tracing.
Foundry Hosted Agent CopilotKit
Guidance for developing agentic web apps on Azure.
Power Automate Foundation
Connect AI agents to Power Automate seamlessly.
Power Automate Flow Builder
Efficiently build and deploy Power Automate flows programmatically.
