{"id":50843024,"url":"https://github.com/matlab/matlab-ai-agent-sdk","last_synced_at":"2026-06-14T07:35:52.031Z","repository":{"id":363580983,"uuid":"1251160046","full_name":"matlab/matlab-ai-agent-sdk","owner":"matlab","description":"​​MATLAB AI Agent SDK​","archived":false,"fork":false,"pushed_at":"2026-06-12T08:26:30.000Z","size":213,"stargazers_count":19,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-06-14T07:35:50.713Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-27T09:52:23.000Z","updated_at":"2026-06-14T05:50:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/matlab/matlab-ai-agent-sdk","commit_stats":null,"previous_names":["matlab/matlab-ai-agent-sdk"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/matlab/matlab-ai-agent-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matlab%2Fmatlab-ai-agent-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matlab%2Fmatlab-ai-agent-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matlab%2Fmatlab-ai-agent-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matlab%2Fmatlab-ai-agent-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matlab","download_url":"https://codeload.github.com/matlab/matlab-ai-agent-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matlab%2Fmatlab-ai-agent-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34313515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-14T07:35:51.351Z","updated_at":"2026-06-14T07:35:52.026Z","avatar_url":"https://github.com/matlab.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MATLAB AI Agent SDK\n\n[![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=matlab/matlab-ai-agent-sdk)\n\nMATLAB® AI Agent SDK lets you build and run AI agents in MATLAB.\n\n- Create agents based on OpenAI®, Ollama™, or OpenAI-compatible APIs.\n\n- Integrate LLMs and agentic workflows into your workflows in a targeted manner, retaining deterministic workflows when those are more suitable.\n\n- Let your agent work on large amounts of data without needing to send the data to the LLM.\n\n## Research Preview\n\nThis SDK is a Research Preview under active development and APIs may change.\n\nPlease leave feedback, report bugs and feature requests via [Issues](../../issues). We review all contributions, but we do not merge external pull requests. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\n## Setup\n\nYou can use the add\\-on in MATLAB Online™ by clicking this link: [![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=matlab/matlab-ai-agent-sdk)\n\nTo use the add\\-on on an installed version of MATLAB, you can clone the GitHub repository. In the MATLAB Command Window, run this command:\n```\n\u003e\u003e !git clone https://github.com/matlab/matlab-ai-agent-sdk.git\n```\nTo run code from the add\\-on outside of the installation directory, add the path to the installation directory.\n```\n\u003e\u003e addpath(\"path/to/matlab-ai-agent-sdk\")\n```\n\n### OpenAI\n\nUsing the OpenAI API requires an OpenAI API key. For information on how to obtain one, as well as pricing, terms and conditions of use, and available models, see the [OpenAI documentation](https://platform.openai.com/docs/overview).\n\nSet your key as an environment variable in a `.env` file:\n\n```\nOPENAI_API_KEY=\u003cyour key\u003e\n```\n\nThen load it in MATLAB.\n\n```matlab\nloadenv(\".env\")\n```\n\n### Ollama\n\nTo connect to local or remote [Ollama](https://ollama.com/) models, first install Ollama.\n\nAfter you have installed Ollama, you can install models from the MATLAB Command Window:\n```matlab\n!ollama pull \u003cmodelname\u003e\n```\n\n## Get Started\n\nCreate an LLM client by using the `aisdk.LLMClient` function and using the API and the model name as input arguments, for example:\n\n```matlab\nclientOpenAI = aisdk.LLMClient(\"openai\", \"gpt-4.1-mini\");\nclientOllama = aisdk.LLMClient(\"ollama\", \"\u003cmodel-name\u003e\");\n```\n\nThen, generate text by using the `generate` function.\n\n```matlab\ntext = generate(client, \"This is an example prompt.\")\n```\n```\ntext = \n    \"This is an example reponse.\"\n```\n\n### Create Chat With LLM\n\nThis example shows how to create a conversation with an LLM and automatically keep track of the message history.\n\nCreate the agent from an LLM client `client` by using the `aisdk.AIAgent` function. Provide a system prompt.\n\n```matlab\nsystemPrompt = \"Reply as if you are writing telegrams.\";\nagent = aisdk.AIAgent(client,systemPrompt);\n```\nRun the agent by using the `run` function. Provide a prompt.\n\n```matlab\nprompt = \"TOMATO FRUIT OR VEGETABLE STOP\";\nrun(agent,prompt)\n```\n```\nans = \n\n    \"TOMATO TECHNICALLY A FRUIT STOP COMMONLY USED AS VEGETABLE IN CULINARY CONTEXT STOP END OF TRANSMISSION.\"\n```\n\nAsk a follow up question by using the `run` function.\n\n```matlab\nrun(agent,\"HOW ABOUT AVOCADO STOP\")\n```\n```\nans = \n\n    \"AVOCADO ALSO A FRUIT STOP KNOWN AS ALLIGATOR PEAR STOP HIGH IN HEALTHY FATS AND NUTRIENTS STOP END OF TRANSMISSION.\"\n```\nInspect the chat history by using the `Messages` property of the agent.\n\n```matlab\nagent.Messages\n```\n```\nans = \n\n  1×4 LLMTextMessage array with messages:\n\n    1    User         Text    \"TOMATO FRUIT OR VEGETABLE STOP\"\n    2    Assistant    Text    \"TOMATO TECHNICALLY A FRUIT STOP COMMONLY USED AS VEGETABLE I...\"\n    3    User         Text    \"HOW ABOUT AVOCADO STOP\"\n    4    Assistant    Text    \"AVOCADO ALSO A FRUIT STOP KNOWN AS ALLIGATOR PEAR STOP HIGH ...\"\n```\n\n### Create AI Agent With Tools\n\nThis example shows how to create an AI agent with a set of tools.\n\nCreate a function that counts the number of times a letter appears in a word.\n\n```matlab\nfunction numLetter = countLetters(word,letter)\n    numLetter = count(word,letter);\nend\n```\nCreate a tool from the `countLetters` function by using the `aisdk.LLMTool` function. Add information about input and output arguments to the tool by using the `aisdk.LLMToolArgument` function.\n\n```matlab\ntool = aisdk.LLMTool(@countLetters);\ntool.InputArguments(1) = aisdk.LLMToolArgument(\"word\",DataType=\"string\");\ntool.InputArguments(2) = aisdk.LLMToolArgument(\"letter\",DataType=\"string\");\ntool.OutputArguments = aisdk.LLMToolArgument(\"numLetter\",DataType=\"number\");\n```\n\nCreate the agent from an LLM client `client` by using the `aisdk.AIAgent` function. Leave the system prompt empty.\n\n```matlab\nsystemPrompt = \"\";\nagent = aisdk.AIAgent(client,systemPrompt,tool);\n```\n\nRun the agent by using the `run` function.\n\n```matlab\nrun(agent,\"How many times is the letter r in the word strawberry?\")\n```\n```\nans = \"The letter \"r\" appears 3 times in the word \"strawberry.\"\"\n```\n\n### Configure Tool to Use Agent Workspace\nThis example shows how to configure an LLM tool to use data from the agent workspace as input or output data.\n\nThe `eig` function calculates the eigenvectors and eigenvalues of matrices. Vectors and matrices can contain a lot of numerical data. Instead of sending all this data to an LLM, which would cost tokens, keep the data in the agent workspace and configure your tools to work on that workspace.\n\nCreate a function called `eigTool`.\n\n- The first input argument of the function must be a structure array. Call the argument `ws`.\n\n- The last output argument of the function must be the same structure array.\n\nTo allow the agent to understand the outcome of the tool call, add another output argument, observation, that contains a natural language description of the outcome of the tool call. Describe the outcome using the observation output argument.\n\n```matlab\nfunction [observation,ws] = eigTool(ws)\n% Compute the eigenvalues of a matrix\nws.eigenvalues = eig(ws.matrix);\nobservation = \"Eigenvalues added to the workspace as a variable called eigenvalues.\";\nend\n```\n\nCreate an LLM tool from the `eigTool` function by using the `aisdk.LLMTool` function. Set the `Workspace` name-value argument to `\"agent\"`.\n\n```matlab\ntool = aisdk.LLMTool(@eigTool,Workspace=\"agent\");\n```\n\nYou can now add the tool to an agent `agentWithWorkspace`. Add a matrix `A` to the agent workspace by setting the `Workspace` property. Call the field `matrix` to match the field name in the tool definition.\n\n```matlab\nagentWithWorkspace.Tools = tool;\nagentWithWorkspace.Workspace.matrix = A;\n```\n\n## Functions\n\n| Function | Description |\n|----|----|\n| [aisdk.AIAgent](doc/AIAgent.md) | Build AI agent | \n|[aisdk.LLMClient](doc/LLMClient.md) | Connect to third-party LLM API |\n| [aisdk.LLMTool](doc/LLMTool.md) | Tool for AI agent |\n| [aisdk.LLMToolArgument](doc/LLMToolArgument.md) | Argument for LLM tool |\n| [aisdk.LLMMessage](doc/LLMMessage.md) | Create LLM message |\n| [OpenAIClient](doc/llms/client/OpenAIClient.md) | Client for OpenAI API |\n| [OllamaClient](doc/llms/client/OllamaClient.md) | Client for Ollama API |\n| [LocalLLMTool](doc/llms/tool/LocalLLMTool.md) | Tool for AI agent from local function |\n| [MCPTool](doc/llms/tool/MCPTool.md) | Tool for AI agent from MCP server |\n| [LLMTextMessage](doc/llms/message/LLMTextMessage.md) | LLM message containing text |\n| [LLMImageMessage](doc/llms/message/LLMImageMessage.md) | LLM message containing image |\n| [LLMToolCallMessage](doc/llms/message/LLMToolCallMessage.md) | LLM message containing tool call |\n| [LLMToolResultMessage](doc/llms/message/LLMToolResultMessage.md) | LLM message containing tool result |\n\n## Examples\n\n| Example                                                                              | Description                                                                                                                                                                                                                 |\n| ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| [CreateSimpleChatBotUsingAIAgent.m](doc/examples/CreateSimpleChatBotUsingAIAgent.m)     | Create interactive chatbot in Command Window                                                                                                                                                                                   |\n| [AnalyzeTextUsingParallelToolCalls.m](doc/examples/AnalyzeTextUsingParallelToolCalls.m) | Extract structured data from text                                                                                                                                                                 |\n| [FitPolynomialToDataUsingAIAgent.m](doc/examples/FitPolynomialToDataUsingAIAgent.m)     | Build AI agent that fits polynomials to data (requires Curve Fitting Toolbox™) |\n| [NestedToolsAndSubagentsExample.m](doc/examples/NestedToolsAndSubagentsExample.m)       | Create tools that provide other tools                                                                                                                                                                             |\n| [MCPClientAndAgentTools.m](doc/examples/MCPClientAndAgentTools.m)                       | Connect agent to Model Context Protocol (MCP) server                                                                                                                                                                   |\n\n## License\n\nThe license is available in the [LICENSE](LICENSE) file in this GitHub repository.\n\n## Contact\n\nTo ask questions, report issues, or request technical support, open an [Issue](../../issues).\n\n---\n\n*Copyright 2026 The MathWorks, Inc.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatlab%2Fmatlab-ai-agent-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatlab%2Fmatlab-ai-agent-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatlab%2Fmatlab-ai-agent-sdk/lists"}