Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

Prepare Your Org to Access the Models API

Learning Objectives

After completing this unit, you’ll be able to:

  • Set up your Salesforce DX environment.
  • Sign up for an AI Playground.
  • Authorize your AI Playground in Visual Studio Code.
  • Create a Salesforce DX Project.

The Next Step for DreamHouse Realty

After planning her first AI project with DreamHouse Realty, Maria needs to set up her org and environment so that she can begin building her dashboard. The Models API is accessible from any org with Einstein Generative AI and Data Cloud enabled.

Sign Up for a Trial Org with Einstein Generative AI

To complete this project, you need a special, limited-time custom playground that contains Einstein AI and Data Cloud.

  1. If you haven't already, click the checkbox: I can receive a password email at the beginning of the unit.
  2. Click Create Playground.
  3. Follow the prompts.
  4. Make note of your org's expiration date and complete this badge before then.
Note

This custom playground is designed to work with the challenges in this badge and may not work for other badges. Always check that you’re using the AI Playground or special org that we recommend.

Also note that when you create a custom playground, store your username and password somewhere safe. These credentials are required when connecting your Visual Studio Code environment.

If you haven’t already, launch your AI playground.

  1. Click the gear icon (“”) and click Setup. The Setup page opens in a new tab.
  2. In the Quick Find search box, type Einstein Setup.
  3. Click Einstein Setup to open the Einstein Setup page.

Einstein Setup.

  1. Turn on Einstein On/Off Toggle to use generative AI features across your Salesforce Org.

Install the Salesforce Command Line Interface (CLI)

Use the Salesforce CLI to control the full application life cycle of your Salesforce apps. With it you can easily create environments for development and testing, synchronize source code between your orgs and version control system (VCS), and execute tests.

See the Salesforce CLI Setup Guide for complete installation instructions.

  1. Install the CLI from Salesforce CLI.
  2. Confirm the CLI is properly installed and on the latest version by running the following command from the command line.
sf update

You should see output like Updating CLI…

Install Salesforce Extensions for Visual Studio Code

Visual Studio Code is the go-to code editor for Salesforce developers. It's free, open-source, and available for Windows, Linux, and macOS. This editor has easy-to-install extensions for syntax highlighting, code completion, and more.

If you don’t already have them, follow the instructions to install Visual Studio Code and the recommended Salesforce Extension Pack.

  1. Download and install the latest version of Visual Studio Code for your operating system. If you already have Visual Studio Code installed, there’s no need to reinstall it.
  2. Launch Visual Studio Code.
  3. On the left toolbar, click the Extensions icon(Visual Studio Code's Extension ).
  4. Search for Salesforce Extension Pack and click Install.

Create a Project

  1. In Visual Studio Code, open the Command Palette by pressing Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS).
  2. Type SFDX.
  3. Select SFDX: Create Project.
  4. Press Enter to accept the standard option.
  5. Enter ModelsAPILWC as the project name.
  6. Press Enter.
  7. Select a folder to store the project.
  8. Click Create Project. You should see something like this as your base setup.

The ModelsAPILWC project in VS Code with sub-folders that include .husky and .sfdx

Connect Your Visual Studio Code Environment

Before you can create a Lightning web component, you must connect your AI Playground to your VS Code environment.

Note

Dev Org Required

To access the Models API outside of this module, you need a functional dev environment with Data Cloud and Einstein Generative AI enabled.

Authorize Your AI Playground

In VS Code, authorize your custom Playground.

  1. In Visual Studio Code, open the Command Palette by pressing Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS).
  2. Type SFDX.
  3. Select SFDX: Authorize an Org.
  4. Press Enter to accept the Project Default login URL option.
  5. Press Enter to accept the default alias. This opens the Salesforce login in a separate browser window.
  6. Log in using your AI Playground credentials.
  7. If prompted to allow access, click Allow.
  8. After you authenticate in the browser, the CLI remembers your credentials. The success message should look like this:

Terminal message that reads, “sfdx force:auth:web:login --alias gs0Org --setdefaultusername Successfully authorized [USERNAME

You’re now ready to complete the challenge and move on to the next unit. Note that this challenge only checks if Einstein is enabled in Setup, but all of the previous steps are required to start building the dashboard in the next unit.

Resources

Comparta sus comentarios sobre Trailhead en la Ayuda de Salesforce.

Nos encantaría conocer su experiencia con Trailhead. Ahora puede acceder al nuevo formulario de comentarios cuando quiera desde el sitio de la Ayuda de Salesforce.

Más información Continuar para compartir comentarios