forcedotcom/sf-skills

platform-models-api-configure

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 Conn…

All-time #3544 Trending #9659 First seen Jul 10, 2026
8-week activity · all time api

Installation

$ npx skills add forcedotcom/sf-skills --skill platform-models-api-configure

Summary

  • 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).

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from forcedotcom/sf-skills · top by installs.

npx skills add forcedotcom/sf-skills

Browse all from forcedotcom/sf-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 972
License LICENSE.txt
Default branch main
Open issues 15
Status Active

Skill metadata

Parsed from SKILL.md frontmatter.

Version1.0
Declared agents claude-code
More metadata
cliTools
{"0":"tool: [\"curl\"]","semver":">=2.0.0","1":"tool: [\"jq\"]","2":"tool: [\"sf\"]"}
relatedSkills
["integration-connectivity-connected-app-configure","integration-connectivity-generate"]
version
1.0
domains
["Platform","Agentforce"]

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 8,422 B
  • docs SUMMARY.md 691 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 3,903 installs

SKILL.md

Salesforce 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 clientcredentials with the sfapapi 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 sfapapi OAuth scope and the clientcredentials 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

  • SFINSTANCEURL — org My Domain, e.g. https://acme.my.salesforce.com
  • SFCLIENTID, SFCLIENTSECRET — 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 (default ai-platform-models-connected-app),

<APP> = x-sfdc-app-context (default EinsteinGPT). Used in the Step 2 verify curl and in ANTHROPICCUSTOMHEADERS.

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.

  1. Write <project>/.claude/.orgjwt.env (chmod 600), gitignore it:

``ini SFINSTANCEURL="..." SFCLIENTID="..." SFCLIENTSECRET="..." ``

  1. Verify — must return 200 before writing settings:

``bash TOKEN=$(bash <SKILL>/scripts/get-orgjwt.sh <ABS>/.claude/.orgjwt.env) curl -s -o /dev/null -w '%{httpcode}\n' \ <MODELSAPIURL>/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 '{"anthropicversion":"bedrock-2023-05-31","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}' ``

  1. Write .claude/settings.json (merge into existing; keep other keys):

``json { "apiKeyHelper": "bash <SKILL>/scripts/get-orgjwt.sh <ABS>/.claude/.orgjwt.env", "model": "<MODEL>", "env": { "ANTHROPICAUTHTOKEN": "", "CLAUDECODEUSEBEDROCK": "1", "CLAUDECODESKIPBEDROCKAUTH": "1", "ANTHROPICBEDROCKBASEURL": "<MODELSAPIURL>", "ANTHROPICSMALLFASTMODEL": "<MODEL>", "ANTHROPICDEFAULTMODEL": "<MODEL>", "ANTHROPICCUSTOM_HEADERS": "x-client-feature-id: <FEAT>\nx-sfdc-app-context: <APP>" } } ` Use absolute paths in apiKeyHelper. (<FEAT> / <APP>` defaults are in "Inputs to collect" above.)

  1. Tell the admin to fully restart the agent (claude for 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.env created, chmod 600, and gitignored
  • Verification curl returned HTTP 200 before settings.json was written
  • ANTHROPICAUTHTOKEN set to "" in settings.json
  • CLAUDECODEUSE_BEDROCK set to "1"
  • CLAUDECODESKIPBEDROCKAUTH set to "1"
  • ANTHROPICBEDROCKBASE_URL is exactly https://api.salesforce.com/ai/gpt/v1 (no trailing slash/path)
  • model, ANTHROPICDEFAULTMODEL, and ANTHROPICSMALLFASTMODEL all use the fully qualified sfdcai__… alias
  • ANTHROPICCUSTOMHEADERS contains x-client-feature-id and x-sfdc-app-context
  • apiKeyHelper uses 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)

  • "ANTHROPICAUTHTOKEN": "" — clears any global token that would otherwise

outrank apiKeyHelper (precedence: ANTHROPICAUTHTOKEN > ANTHROPICAPIKEY > apiKeyHelper). Without it → wrong/old bearer → 401/404.

  • CLAUDECODEUSE_BEDROCK=1 — activates the Bedrock API client; without it

Claude Code uses the standard Anthropic API protocol and ignores ANTHROPICBEDROCKBASE_URL entirely, so every call bypasses the Models API.

  • CLAUDECODESKIPBEDROCKAUTH=1 — else Claude Code overwrites Authorization

with AWS SigV4 and the OrgJWT never lands.

  • apiKeyHelper must be invoked as bash <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, scope

sfapapi) — NOT sf org display (unsigned session token → 404). sf CLI has no clientcredentials command; the helper calls /services/oauth2/token.

  • Only ANTHROPICBEDROCKBASE_URL routes; no tenant-id header needed.

Diagnose

Error Meaning Check first
401 Token is not a valid OrgJWT Connected App sfapapi scope, clientcredentials flow enabled, consumer key/secret in .orgjwt.env; ANTHROPICAUTHTOKEN not cleared to ""
404 Token valid but model/env/org not routable Fully qualified sfdc_ai__… model alias, ANTHROPICBEDROCKBASEURL exactly https://api.salesforce.com/ai/gpt/v1, org entitled for the Models API, ANTHROPICAUTH_TOKEN cleared
model not available Non-alias model id Replace with a fully qualified sfdc_ai__… alias (see supported models)