Loading...
Loading...
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).
npx skill4agent add forcedotcom/afv-library platform-models-api-configurehttps://api.salesforce.com/ai/gpt/v1client_credentialssfap_apiscripts/get-orgjwt.shscripts/<SKILL>SKILL.md<ABS>sfap_apicurljqSF_INSTANCE_URLhttps://acme.my.salesforce.comSF_CLIENT_IDSF_CLIENT_SECREThttps://api.salesforce.com/ai/gpt/v1sfdc_ai__…sfdc_ai__DefaultBedrockAnthropicClaude46Sonnet<cwd>/.claude/settings.json~/.claude/settings.json<FEAT>x-client-feature-idai-platform-models-connected-app<APP>x-sfdc-app-contextEinsteinGPTANTHROPIC_CUSTOM_HEADERS<project>/.claude/.orgjwt.envSF_INSTANCE_URL="..."
SF_CLIENT_ID="..."
SF_CLIENT_SECRET="..."200TOKEN=$(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"}]}'.claude/settings.json{
"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>claudemodels-api-setup-runbook.md.orgjwt.envchmod 600200settings.jsonclaudesettings.json.claude/.orgjwt.envchmod 600200settings.jsonANTHROPIC_AUTH_TOKEN""settings.jsonCLAUDE_CODE_USE_BEDROCK"1"CLAUDE_CODE_SKIP_BEDROCK_AUTH"1"ANTHROPIC_BEDROCK_BASE_URLhttps://api.salesforce.com/ai/gpt/v1modelANTHROPIC_DEFAULT_MODELANTHROPIC_SMALL_FAST_MODELsfdc_ai__…ANTHROPIC_CUSTOM_HEADERSx-client-feature-idx-sfdc-app-contextapiKeyHelperbash <SKILL>/scripts/get-orgjwt.sh <ABS>/.claude/.orgjwt.envclaude"ANTHROPIC_AUTH_TOKEN": ""apiKeyHelperANTHROPIC_AUTH_TOKENANTHROPIC_API_KEY). Without it → wrong/old bearer → 401/404.apiKeyHelper
CLAUDE_CODE_USE_BEDROCK=1ANTHROPIC_BEDROCK_BASE_URLCLAUDE_CODE_SKIP_BEDROCK_AUTH=1AuthorizationapiKeyHelperbash <path> <credsfile>sfdc_ai__…client_credentialssfap_apisf org displaysf/services/oauth2/tokenANTHROPIC_BEDROCK_BASE_URL| 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 |