Generate chat (conversation with context)

POST {{_baseUrl}}/models/:modelName/chat-generations

Generate a response based on a list of messages representing a chat conversation.

Request Body

{"messages"=>[{"role"=>"user", "content"=>"Can I use the Salesforce REST API to retrieve a record?"}, {"role"=>"assistant", "content"=>"Yes, you can use the Salesforce REST API to retrieve a record. The REST API provides a simple and efficient way to interact with Salesforce data using standard HTTP methods like GET, POST, PUT, and DELETE. To retrieve a record, you can use the GET method on the specific record's endpoint URL. Here's an example of how to retrieve a record using the REST API:\n\n1. Authenticate and obtain an access token.\n2. Construct the endpoint URL for the specific record you want to retrieve. The URL should follow the format: `https://instance.salesforce.com/services/data/vXX.X/sobjects/Object_Name/Record_Id`.\n   - Replace `instance` with your Salesforce instance (e.g., `na1`).\n   - Replace `XX.X` with the Salesforce API version you are using (e.g., `v52.0`).\n   - Replace `Object_Name` with the API name of the object you want to retrieve a record from (e.g., `Account`).\n   - Replace `Record_Id` with the ID of the specific record you want to retrieve.\n3. Make a GET request to the constructed endpoint URL, including the access token in the request headers.\n4. Parse the response to retrieve the record details.\n\nNote that you need to have the necessary permissions and access rights to retrieve records using the REST API."}, {"role"=>"user", "content"=>"Nice, show me an example with \"my-developer-edition\" as the domain, 61.0 as the API version and \"Contact\" as the object."}], "localization"=>{"defaultLocale"=>"en_US", "inputLocales"=>[{"locale"=>"en_US", "probability"=>0.8}], "expectedLocales"=>["en_US"]}}

HEADERS

KeyDatatypeRequiredDescription
x-sfdc-app-contextstring(Required) This value is reserved for future use. For now, specify EinsteinGPT.
x-client-feature-idstring(Required) This value is reserved for future use. For now, specify ai-platform-models-connected-app.
Content-Typestring

RESPONSES

status: OK

{"id":"chatcmpl-9r4GYuN1prQNl5Li2loPwlpgb6oUq","generationDetails":{"generations":[{"id":"f4b18aba-953a-4880-9c10-3ecc7aee5a6f","role":"assistant","content":"Certainly! Here's an example of how you can retrieve a record using the Salesforce REST API with the provided details:\n\n1. Authenticate and obtain an access token.\n2. Construct the endpoint URL for the specific record you want to retrieve. Assuming you want to retrieve a Contact record with the ID \"003XXXXXXXXXXXXXXX\", the URL would be: `https://my-developer-edition.salesforce.com/services/data/v61.0/sobjects/Contact/003XXXXXXXXXXXXXXX`.\n3. Make a GET request to the constructed endpoint URL, including the access token in the request headers.\n4. Parse the response to retrieve the record details.\n\nRemember to replace \"my-developer-edition\" with your actual Salesforce domain, \"61.0\" with the desired API version, and \"003XXXXXXXXXXXXXXX\" with the ID of the Contact record you want to retrieve.\n\nHere's an example using Python and the `requests` library:\n\n```python\nimport requests\n\n# Replace with your Salesforce access token\naccess_token = \"YOUR_ACCESS_TOKEN\"\n\n# Construct the endpoint URL\nendpoint_url = \"https://my-developer-edition.salesforce.com/services/data/v61.0/sobjects/Contact/003XXXXXXXXXXXXXXX\"\n\n# Make a GET request with the access token in the headers\nheaders = {\n    \"Authorization\": f\"Bearer {access_token}\",\n    \"Content-Type\": \"application/json\"\n}\nresponse = requests.get(endpoint_url, headers=headers)\n\n# Parse the response to retrieve the record details\nif response.status_code == 200:\n    contact_record = response.json()\n    print(contact_record)\nelse:\n    print(f\"Error: {response.status_code} - {response.text}\")\n```\n\nMake sure to replace \"YOUR_ACCESS_TOKEN\" with your actual Salesforce access token.","timestamp":1722434821784,"parameters":{"finish_reason":"stop","index":0,"logprobs":null},"contentQuality":{"scanToxicity":{"isDetected":false,"categories":[{"categoryName":"identity","score":0.0002},{"categoryName":"hate","score":0},{"categoryName":"profanity","score":0},{"categoryName":"violence","score":0},{"categoryName":"sexual","score":0.0005},{"categoryName":"physical","score":0}]}}}],"parameters":{"created":1722434810,"usage":{"completion_tokens":358,"prompt_tokens":333,"total_tokens":691},"model":"gpt-35-turbo","system_fingerprint":null,"object":"chat.completion"}}}