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
Enable Einstein generative AI in Salesforce Setup and ensure your org has access to at least one foundation model via Model Builder.
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.
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}}.
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>"}]}.
Parse the JSON response; for generations the generated text is in generatedTexts[0].text, and for chat-generations it is in generations[0].content.
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
Model names are not static across all orgs — use GET /einstein/platform/v1/models to enumerate what is available rather than hardcoding a model name.
All requests pass through the Einstein Trust Layer, which applies data masking and audit logging; outputs may be redacted if they match configured sensitive data patterns.
The Models API is rate-limited at the org level; high-volume generation workloads should implement exponential back-off on HTTP 429 responses and consider using Apex ConnectApi.EinsteinLLM methods for in-platform calls.
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?