Main Content

Connect MathWorks Copilot Products to Your LLM

R2026b
Since R2026b

To route your MATLAB® Copilot and Simulink® Copilot queries to your own organization-approved large language model (LLM) instead of an LLM provided by MathWorks®, use the Bring Your Own Key feature in MATLAB Connector™. When you enable this feature, you can use MathWorks copilot products while complying with your organization's data privacy and security policies. This topic explains how to install and configure the Bring Your Own Key feature, and how to manage the connection to your LLM provider using MATLAB Connector.

Installation and Configuration Requirements

To install and configure the Bring Your Own Key feature, knowledge of IT concepts is recommended. Work with your IT staff to meet the following requirements:

  • You must have R2026b or a later release of MATLAB or Simulink installed.

  • You must have a MathWorks Account linked to your organization email and a license for each MathWorks copilot product you want to use.

  • Your organization must have an account with one of the following LLM providers:

    • OpenAI®

    • Microsoft® Azure®

Connect to Your LLM Provider

To connect MATLAB Copilot and Simulink Copilot to your LLM provider, follow the steps in the next sections to accomplish these tasks:

  • Configure the LLM you are using so you can obtain the required API key.

  • Install MathWorks documentation locally to improve query responses (optional but highly recommended).

  • Install MATLAB Connector, which contains the Bring Your Own Key setup software.

  • Connect MathWorks copilot products to your LLM provider by specifying your provider's API key and other required information.

Configure LLM to Get Key

Configure your LLM so that you can obtain the required API key. The configuration instructions vary by LLM provider.

OpenAI.  If OpenAI is your LLM provider, follow these steps to configure the LLM so you can obtain the API key.

  1. Go to https://platform.openai.com and log in with your organization's OpenAI account.

  2. (Optional) If you have permissions to create projects, create one for your MathWorks models. A project enables you to manage options such as model access, token consumption, and monthly spending limits. From the project selector, select the option to create a new project, and name it "MathWorks". The new project is created and selected by default.

  3. In the left pane, select API keys. Then click the Create new secret key button.

  4. Create a new key with these options:

    • Specify yourself as the owner.

    • Provide an easily identifiable name such as "MathWorks - Copilot Key".

    • Select the project you created or use the default project.

    • Apply all permissions.

  5. Copy the key and store it in a secure location. You will not be able to access it from the OpenAI website later.

Microsoft Azure.  If Microsoft Azure is your LLM provider, before you can connect to your LLM endpoints, you must first deploy the AI models used by MathWorks copilot products into your Azure subscription. (Model deployment is required for Microsoft Azure only. OpenAI provisions the required AI models in advance when you create your account.)

To generate high-quality responses from MathWorks copilot products, you must deploy all of the models in the following table. Different copilot products and functionality might use different combinations of these models. Depending on the AI features used, the costs incurred for each model will vary.

  1. In Microsoft Foundry, navigate to the page where you can create model deployments.

  2. Select the option to deploy a base model.

  3. Select one of the base models shown in this table.

    Base Model

    Model Name

    Model Version

    gpt-4o-minigpt-4o-mini-2024-07-182024-07-18
    gpt-4.1gpt-4.1-2025-04-142025-04-14
    gpt-5-minigpt-5-mini-2025-08-072025-08-07
    gpt-5gpt-5-2025-08-072025-08-07
    gpt-5.4-minigpt-5.4-mini-2026-03-172026-03-17
    gpt-5.4-nanogpt-5.4-nano-2026-03-172026-03-17
    gpt-5.6-lunagpt-5.6-luna2026-07-09
    gpt-5.6-terragpt-5.6-terra2026-07-09
  4. Configure the base model with these options:

    • Model name — Set the model name to the value shown in the Model Name column of the table. This name is a combination of the base model and model version.

    • Deployment type — Choose a deployment type based on the information in the deployment types documentation (Microsoft).

    • Model version upgrade policy — Opt out of automatic model version upgrades.

    • Model version — Set the model version to the value shown in the Model Version column of the table. This version is typically the date the model was released.

    • Rate limit — Set the tokens per minute rate limit to 75000*numUsers, where numUsers is the number of end users.

  5. Deploy the model. The new deployment will appear on the model deployment page.

  6. Repeat the previous steps for each model in the table.

When you are done, you can obtain the API key and server URL needed to enable MathWorks copilot products from the model deployment page.

Install Documentation for RAG Enrichment (Recommended)

To fully enable MathWorks copilot products to use your own organization-approved LLMs, install the documentation for all your MathWorks products on your local machine or network. MathWorks copilot products use MathWorks documentation and retrieval-augmented generation (RAG) to respond to user prompts. Without locally installed documentation, MathWorks copilot products cannot use RAG with your own LLM, possibly leading to lower quality responses.

Choose one of the following options for installing documentation locally:

  • To install the documentation on your computer, follow the instructions in Install Documentation for Temporary Offline Use. This procedure is simpler, but you must repeat the procedure for each computer that needs access to the Bring Your Own Key feature.

  • To install the documentation on a network drive that multiple computers can access, follow the instructions in Install Documentation on Permanently Offline Computers. This procedure is more complex, but an IT administrator can complete the procedure just once.

Install Connector Software

The Bring Your Own Key setup software runs inside MATLAB Connector, an application that runs background services for MathWorks products. To install MATLAB Connector and the Bring Your Own Key setup software, use the following platform-specific instructions. Repeat these steps for each computer that needs access to the Bring Your Own Key feature.

Windows.  On Windows® machines, install the connector software using these steps:

  1. To download the installer ZIP file, click this link: Bring Your Own Key Setup for Windows.

  2. Right-click the downloaded ZIP file and click Extract All.

  3. Choose a destination folder where you want to extract the files and click Extract. You must select a location on your local computer and not a shared network location.

  4. Open Windows Command Prompt.

  5. Navigate to the folder where you extracted the contents.

    cd "\path\to\folder"
    
  6. Run the installer.

    bin\win64\InstallMathWorksServiceHost.exe -feature ondevicecopilotsettings
    

macOS.  On macOS machines, install the connector software using these steps:

  1. To download the installer ZIP file, click this link: Bring Your Own Key Setup for macOS.

  2. Locate the downloaded ZIP file and extract its contents (a DMG file) to a folder of your choice.

  3. Mount the extracted DMG file.

    1. Control-click the extracted DMG file.

    2. Select Open With and choose DiskImageMounter to mount the DMG file.

  4. Open a Terminal window.

  5. Navigate to the folder where you extracted the contents.

    cd /path/to/folder
    
  6. Run the installer.

    /Volumes/mathworksservicehost_YYYY.n.n.n_maca64_installer/InstallMathWorksServiceHost.app/ ^
    Contents/MacOS/InstallMathWorksServiceHost -feature ondevicecopilotsettings
    

    Replace YYYY.n.n.n with the MATLAB Connector version you downloaded (for example, 2026.1.0.0).

Linux.  On Linux® machines, install the connector software using these steps:

  1. To download the installer binary file, click this link: Bring Your Own Key Setup for Linux.

  2. Open a Terminal window.

  3. Navigate to the folder that contains the downloaded .bin file.

    cd /path/to/folder
    

  4. Run the installer.

    sh ~/Downloads/mathworksservicehost_YYYY.n.n.n_glnxa64_installer.bin -feature ondevicecopilotsettings
    

    Replace YYYY.n.n.n with the MATLAB Connector version you downloaded (for example, 2026.1.0.0).

Connect MathWorks Copilot Products to LLM Provider Using Key

After installation, MATLAB Connector opens to the Bring Your Own Key setup application.

Bring Your Own Key Setup screen

Use this application to connect MathWorks copilot products to your LLM provider. Repeat this setup process for each computer that you want to access your organization-approved LLM.

Start.  On the Start page of the application, log in to your MathWorks Account if prompted, and click Next to continue.

Configure.  On the Configure page, configure your LLM provider connection.

  1. Select MathWorks Public Cloud, OpenAI, or Microsoft Azure as your LLM provider and then enter the information required by your provider:

    • MathWorks Public Cloud — No information required. This option disables the Bring Your Own Key feature and reverts to the LLM running on the MathWorks public cloud.

    • OpenAI — Enter the OpenAI key in the Key field. To obtain a key from your OpenAI account, see the OpenAI section of the Configure LLM to Get Key instructions.

    • Microsoft Azure — Enter your model deployment's URL and key in the URL and Key fields, respectively. Obtain these values in Microsoft Foundry, from the model deployment page for the AI models you deployed in the Microsoft Azure section of the Configure LLM to Get Key instructions.

  2. Enter the URL of the documentation you installed in the Install Documentation for RAG Enrichment (Recommended) section. To get this URL, at the MATLAB command prompt, enter: doc

    Copy the URL of the documentation home page that opens and paste it into the URL field. This URL has the form http://hostname:port (for example, http://127.0.0.1:12345).

  3. Click Next to continue.

Settings.  On the Settings page, review and optionally update these settings:

  • Leave Start MATLAB Connector at system startup selected to have MATLAB Connector start whenever you restart your computer.

  • Select Help improve MATLAB Connector to send your experience information to MathWorks.

When you are done, click Next to continue.

Finish.  On the Finish page, review the setup information. Then, click Back to modify your configuration as needed, or click Finish to complete the setup process. The next time you run MathWorks copilot products on this computer, the queries are routed to the endpoints of your LLM provider.

Manage Connector Software

Use MATLAB Connector to manage your Bring Your Own Key settings and LLM provider connections.

Start Connector

If MATLAB Connector is not running, you can start it from your operating system:

  • Windows — In the Start menu, select MATLAB Connector.

  • macOS — Navigate to ~/Applications in Finder, and double-click MATLAB Connector.

  • Linux — Execute ~/bin/MATLABConnector start in a Terminal window.

Open Connector

If the connector is already running, you can open it and bring it to the foreground:

  • Windows — Go to your system notification area, and click the MATLAB Connector icon .

  • macOS — Go to your menu bar and in the status area, click the MATLAB Connector icon .

  • Linux — Execute ~/bin/MATLABConnector toggle in a Terminal window.

Check Status and Update Connector Settings

To check the status of your configuration, or to update settings for MATLAB Connector, follow these steps:

  1. Open the connector.

    At the top of the main pane, the connector displays a banner message. If the connection to your LLM is set up, then the message states that your configuration is ready to use.

  2. In the left pane, click the Settings button to open the MATLAB Connector Settings page.

  3. Navigate to the Bring Your Own Key tab. This tab displays the same message as the banner message in the main pane of the connector.

    The settings page also provides tabs for general settings, account information, and additional applications that might be running in MATLAB Connector, such as MATLAB Drive. For more details, see MATLAB Drive Settings and Account Information.

Uninstall Connector

When you no longer need to use MathWorks copilot products, uninstall MATLAB Connector and the Bring Your Own Key setup software from your computer. Follow the platform-specific uninstallation instructions.

Windows.  On Windows machines, uninstall the connector software using these steps:

  1. Shut down MATLAB Connector by clicking the Exit button in the bottom-left corner of the connector window.

  2. From the Windows Start menu, search for "MATLAB Connector".

  3. Right-click the MATLAB Connector app and click Uninstall.

  4. (Optional) If you are on a shared computer, clear your cached account information by deleting the ServiceHost folder. The default location for this folder is C:\Users\username\AppData\Local\MathWorks\ServiceHost.

macOS.  On macOS machines, uninstall the connector software using these steps:

  1. In the connector, click the Settings button , and copy the version number of the connector. You will need this version number in a later step.

  2. Shut down MATLAB Connector by clicking the Exit button in the bottom-left corner of the connector window.

  3. From a Terminal window, navigate to the MATLAB Connector installation folder.

    cd ~/Library/Application Support/MathWorks/ServiceHost
    
  4. Run the uninstaller.

    ./vYYYY.n.n.n/mci/InstallMathWorksServiceHost.app/Contents/bin/maci64/UninstallMathWorksServiceHost
    

    Replace YYYY.n.n.n with the MATLAB Connector version number you copied in step 1.

  5. (Optional) If you are on a shared computer, clear your cached account information by deleting the ServiceHost folder. The default location for this folder is ~/Library/Application Support/MathWorks/ServiceHost.

Linux.  On Linux machines, uninstall the connector software using these steps:

  1. In the connector, click the Settings button , and copy the version number of the connector. You will need this version number in a later step.

  2. Shut down MATLAB Connector by clicking the Exit button in the bottom-left corner of the connector window.

  3. From a Terminal window, navigate to the MATLAB Connector installation folder.

    cd ~/.MathWorks/ServiceHost/hostname
    

    Replace hostname with the hostname of your computer. To find your computer's hostname, in the Terminal window, enter: hostname

  4. Run the uninstaller.

    ./vYYYY.n.n.n/mci/bin/glnxa64/UninstallMathWorksServiceHost.sh
    

    Replace YYYY.n.n.n with the MATLAB Connector version number you copied in step 1.

  5. (Optional) If you are on a shared computer, clear your cached account information by deleting the ~/.MathWorks/ServiceHost/hostname folder.

Manage Configuration of Bring Your Own Key

After you set up your initial connection to an LLM provider, you can manage your configuration through the Bring Your Own Key software running in MATLAB Connector.

Modify LLM Provider

To modify details about your LLM provider or switch to a new LLM provider, follow these steps:

  1. Open the connector.

  2. On the Bring Your Own Key page, click the Manage Configurations button to open the window for configuring your LLM provider.

  3. Select your LLM provider. Then, enter the updated LLM provider information and, optionally, the documentation URL.

  4. Click OK.

The next time you run MathWorks copilot products on this computer, your queries are routed to the endpoints of the updated LLM provider.

Revert to MathWorks Public Cloud LLM

To disable the Bring Your Own Key feature and revert to using the LLM running on the MathWorks public cloud, follow these steps:

  1. Open the connector.

  2. On the Bring Your Own Key page, click the Manage Configurations button to open the window for configuring your LLM provider.

  3. Select MathWorks Public Cloud.

  4. Click OK.

The next time you run MathWorks copilot products on this computer, your queries are routed to the LLM running on the MathWorks public cloud.

See Also

Topics