Library for connecting with Azure's OpenAI API from Salesforce Apex or Flow
- Register an Azure account and request access to OpenAI api (requires a form at time of publishing).
- Create a new Azure OpenAI instance
- Create a new Deployment for GPT-4 or other "Chat" model
- Grab API keys
- Install sf metadata
sf project deploy start --source-dir force-app/main/default -o <username>
- (Optional) Deploy the examples:
- Assign user to Permission Set:
sf org assign permset --name AzureOAI
- Setup Named Credential
- Update the Named Credential URL to match your deployment endpoint
- Update the External Credential Principal with your API Key
![Named_Credentials___Salesforce](https://private-user-images.githubusercontent.com/5217568/309409626-ac8ea4c8-2fb8-44ff-ae4e-7f593b6a6a25.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNjM2ODIsIm5iZiI6MTczOTA2MzM4MiwicGF0aCI6Ii81MjE3NTY4LzMwOTQwOTYyNi1hYzhlYTRjOC0yZmI4LTQ0ZmYtYWU0ZS03ZjU5M2I2YTZhMjUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDlUMDEwOTQyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODBmMTRjZjg3YWY1NTBhNzA5ZTQ2OThiYWYwOTdlOGNlZTkyZjQ5NWVjNmY2YzEzOTZlYzBlNzFlYzFmMzIxYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ltwWr72UhrcGwHSxLi8cQgQc-knrh93zMWxNVhPYtEw)
Note: For Usage, deploy example flow (sf project deploy start --source-dir force-app/main/examples -o <username>
) or see apex code in scripts