- Notifications
You must be signed in to change notification settings - Fork47
Connect MATLAB to LLM APIs, including OpenAI® Chat Completions, Azure® OpenAI Services, and Ollama™
License
matlab-deep-learning/llms-with-matlab
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Large Language Models (LLMs) with MATLAB lets you connect to large language model APIs using MATLAB®.
You can connect to:
- OpenAI® Chat Completions API — For example, connect to ChatGPT™.
- OpenAI Images API — For example, connect to DALL·E™.
- Azure® OpenAI Service — Connect to OpenAI models from Azure.
- Ollama™ — Connect to models locally or nonlocally.
Using this add-on, you can:
- Generate responses to natural language prompts.
- Manage chat history.
- Generate JSON-formatted and structured output.
- Use tool calling.
- Call external tools provided by MCP servers (requires the MATLAB MCP HTTP Client add-on).
- Generate, edit, and describe images.
For more information about the features in this add-on, see the documentation in thedoc directory.
Using this add-on requires MATLAB R2024a or newer.
You can use the add-on in MATLAB Online™ by clicking this link:
In MATLAB Online, you can connect to OpenAI and Azure. To connect to Ollama, use an installed version of MATLAB and install the add-on using the Add-On Explorer or by cloning the GitHub™ repository.
The recommended way of using the add-on on an installed version of MATLAB is to use the Add-On Explorer.
- In MATLAB, go to theHome tab, and in theEnvironment section, click theAdd-Ons icon.
- In the Add-On Explorer, search for "Large Language Models (LLMs) with MATLAB".
- SelectInstall.
For more information about how to connect to the different APIs from MATLAB, including installation requirements, see:
- Process Generated Text in Real Time by Using ChatGPT in Streaming Mode
- Process Generated Text in Real Time by Using Ollama in Streaming Mode
- Summarize Large Documents Using ChatGPT and MATLAB (requires Text Analytics Toolbox™)
- Create Simple ChatBot (requires Text Analytics Toolbox)
- Create Simple Ollama ChatBot (requires Text Analytics Toolbox)
- Solve Simple Math Problem Using AI Agent
- Fit Polynomial to Data Using AI Agent (requires Curve Fitting Toolbox™)
- Analyze Scientific Papers Using ChatGPT Function Calls
- Analyze Text Data Using Parallel Function Calls with ChatGPT
- Analyze Text Data Using Parallel Function Calls with Ollama
- Retrieval-Augmented Generation Using ChatGPT and MATLAB (requires Text Analytics Toolbox)
- Retrieval-Augmented Generation Using Ollama and MATLAB (requires Text Analytics Toolbox)
| Function | Description |
|---|---|
| openAIChat | Connect to OpenAI Chat Completion API from MATLAB |
| azureChat | Connect to Azure OpenAI Services Chat Completion API from MATLAB |
| ollamaChat | Connect to Ollama Server from MATLAB |
| generate | Generate output from large language models |
| openAIFunction | Use Function Calls from MATLAB |
| addParameter | Add input argument toopenAIFunction object |
| openAIImages | Connect to OpenAI Image Generation API from MATLAB |
| openAIImages.generate | Generate image using OpenAI image generation API |
| edit | Edit images using DALL·E 2 |
| createVariation | Generate image variations using DALL·E 2 |
| messageHistory | Manage and store messages in a conversation |
| addSystemMessage | Add system message to message history |
| addUserMessage | Add user message to message history |
| addUserMessageWithImages | Add user message with images to message history |
| addToolMessage | Add tool message to message history |
| addResponseMessage | Add response message to message history |
| removeMessage | Remove message from message history |
The license is available in thelicense.txt file in this GitHub repository.
Copyright 2023-2025 The MathWorks, Inc.
About
Connect MATLAB to LLM APIs, including OpenAI® Chat Completions, Azure® OpenAI Services, and Ollama™
Topics
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors9
Uh oh!
There was an error while loading.Please reload this page.