Generate text and chat completions using the Salesforce Einstein Models API (einstein/platform)

domain: developer.salesforce.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Salesforce Bulk API 2.0 limits — the full failure-mode walkthrough related to developer.salesforce.com, checked against official docs, with linked verified routes.

Steps

  1. Enable Einstein generative AI in Salesforce Setup and ensure your org has access to at least one foundation model via Model Builder.
  2. Obtain a Salesforce OAuth access token scoped to your org; the Models API is available at the api.salesforce.com gateway and accepts standard Salesforce bearer tokens.
  3. For single-turn text generation, POST https://api.salesforce.com/einstein/platform/v1/models/<modelName>/generations with body {"prompt": "<your prompt>", "parameters": {"maxTokens": 512, "temperature": 0.7}}.
  4. For multi-turn chat, POST https://api.salesforce.com/einstein/platform/v1/models/<modelName>/chat-generations with body {"messages": [{"role": "system", "content": "<system prompt>"}, {"role": "user", "content": "<user message>"}]}.
  5. Parse the JSON response; for generations the generated text is in generatedTexts[0].text, and for chat-generations it is in generations[0].content.
  6. List available models and their capabilities by calling GET https://api.salesforce.com/einstein/platform/v1/models to discover valid <modelName> values for your org.

Known gotchas

Related routes

Use Salesforce Einstein / Agentforce APIs to invoke a prompt template and retrieve a model-generated response from Apex
developer.salesforce.com · 6 steps · unrated
Invoke an Einstein Prediction Builder model score from Apex using the ConnectApi.EinsteinAI methods to enrich a lead record at save time
salesforce.com · 5 steps · unrated
Integrate an external application with a Salesforce Einstein Bot using the Einstein Bots Runtime API
developer.salesforce.com · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans