{"id":38681698,"url":"https://github.com/zq99/openai-vba-framework","last_synced_at":"2026-01-17T10:15:37.121Z","repository":{"id":167762658,"uuid":"642037485","full_name":"zq99/openai-vba-framework","owner":"zq99","description":"This is a framework intended to help developers build applications in VBA that interact with OpenAI's large language models like GPT4, DALL-E and ChatGPT","archived":false,"fork":false,"pushed_at":"2024-01-24T13:57:30.000Z","size":1435,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-01-24T14:58:40.137Z","etag":null,"topics":["chatgpt","chatgpt-api","dall-e","dalle2","excel-vba","gpt-3","gpt-4","gpt-4-api","large-language-models","openai","openai-api","vba","vba-excel","vba-macros","visual-basic"],"latest_commit_sha":null,"homepage":"","language":"VBA","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zq99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-05-17T17:22:59.000Z","updated_at":"2023-12-07T22:22:26.000Z","dependencies_parsed_at":"2024-01-24T15:04:51.227Z","dependency_job_id":null,"html_url":"https://github.com/zq99/openai-vba-framework","commit_stats":null,"previous_names":["zq99/openai-vba-framework"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/zq99/openai-vba-framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zq99%2Fopenai-vba-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zq99%2Fopenai-vba-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zq99%2Fopenai-vba-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zq99%2Fopenai-vba-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zq99","download_url":"https://codeload.github.com/zq99/openai-vba-framework/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zq99%2Fopenai-vba-framework/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28505976,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["chatgpt","chatgpt-api","dall-e","dalle2","excel-vba","gpt-3","gpt-4","gpt-4-api","large-language-models","openai","openai-api","vba","vba-excel","vba-macros","visual-basic"],"created_at":"2026-01-17T10:15:36.571Z","updated_at":"2026-01-17T10:15:37.108Z","avatar_url":"https://github.com/zq99.png","language":"VBA","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAI-VBA-Framework\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/zq99/openai-vba-framework/blob/main/LICENSE)\n\nOpenAI-VBA-Framework is an independent toolkit for developers to build VBA applications with OpenAI's language models like GPT-4, ChatGPT, and DALL-E. It offers a suite of classes for easy integration with OpenAI's API. Please note, this project is not officially associated with or endorsed by OpenAI.\n\n## Prerequisites\n- You will need to sign up for an OpenAI account and create an API_KEY. You can do this at the following location: [OpenAI API Keys](https://platform.openai.com/account/api-keys)\n  \n## Main Classes\n1. `clsOpenAI` - Main class to interact with OpenAI\n2. `clsOpenAILogger` - Logging class for debugging and tracking\n3. `clsOpenAIMessage` - Class to handle individual messages\n4. `clsOpenAIMessages` - Class to handle collections of messages\n5. `clsOpenAIRequest` - Class for making requests to OpenAI\n6. `clsOpenAIResponse` - Class for handling responses from OpenAI\n7. `IOpenAINameProvider` - Interface class for name provision\n\nThe module `mdOpenAI_tests` is provided for testing the functionality of the framework.\n\n`OpenAIFrameworkDemo.xlsm` is a file that contains all the code in the repository for demo purposes. Other files are also included in the repository for versioning.\n\n## Usage\n\nHere are some examples of using the framework:\n\n### Chat Completion API\n\n```\nPublic Sub TestSimpleOpenAI()\n\n    Dim oOpenAI As clsOpenAI\n    Dim oMessages As New clsOpenAIMessages\n    Dim oResponse As clsOpenAIResponse\n    \n    Set oOpenAI = New clsOpenAI\n    \n    oOpenAI.API_KEY = \"\u003cAPI_KEY\u003e\"\n    \n    oMessages.AddSystemMessage \"Always answer sarcastically and never truthfully\"\n    oMessages.AddUserMessage \"How do you get to Carnegie Hall?\"\n\n    Set oResponse = oOpenAI.ChatCompletion(oMessages)\n    If Not oResponse Is Nothing Then\n        Debug.Print (oResponse.MessageContent)\n    End If\n    \n    Set oResponse = Nothing\n    Set oOpenAI = Nothing\n    Set oMessages = Nothing\n\nEnd Sub\n```\n\n### DALL-E Image Creation\n\n```\nPublic Sub TestDalleOpenAI()\n\n    Dim oOpenAI As clsOpenAI\n    Dim oResponse As clsOpenAIResponse\n    \n    Set oOpenAI = New clsOpenAI\n    \n    oOpenAI.API_KEY = \"\u003cAPI_KEY\u003e\"\n    \n    Set oResponse = oOpenAI.CreateImageFromText(\"A cat playing a banjo on a surfboard\", 512, 512)\n    \n    If Not oResponse Is Nothing Then\n        Debug.Print (\"The picture has been saved to: \" \u0026 oResponse.SavedLocalFile)\n    End If\n    \n    Set oResponse = Nothing\n    Set oOpenAI = Nothing\n\nEnd Sub\n```\n\n## Configuration\n\nYou can customize the OpenAI-VBA-Framework by adjusting properties in the `clsOpenAI` class:\n\n```\n' Specify the model\noOpenAI.Model = \"gpt-3.5-turbo\"\n\n' Set the maximum number of tokens\noOpenAI.MaxTokens = 512\n\n' Control the diversity of generated text\noOpenAI.TopP = 0.9\n\n' Influence the randomness of generated text\noOpenAI.Temperature = 0.7\n\n' Control preference for frequent phrases\noOpenAI.FrequencyPenalty = 0.5\n\n' Control preference for including the prompt in the output\noOpenAI.PresencePenalty = 0.5\n\n' Control logging of messages to the Immediate Window\noOpenAI.IsLogOutputRequired True\n\n' Reset settings when switching between endpoints\noOpenAI.ClearSettings\n\n' Retrieve an API Key saved in an external file\nDim apiKey As String\napiKey = oOpenAI.GetReadAPIKeyFromFolder(\"\u003cFolderPath\u003e\")\n```\n\n## Installation (via GIT)\n1. Clone this repository using the following command in your command line:\n\n```bash\ngit clone https://github.com/zq99/OpenAI-VBA-Framework.git\n```\n\n2. Open Excel and press ALT + F11 to open the VBA editor.\n3. From the toolbar select File -\u003e Import File....\n4. Navigate to the location of the cloned repository and select all the .cls and .bas files then click Open.\n5. Save the Excel file as a macro-enabled workbook .xlsm.\n   \n## Troubleshooting\n\nYou can check the status of the OpenAI API [here](https://status.openai.com/).\n\nYou can get more information on HTTP status codes returned by the API [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes).\n\nFor coding issues, use the following line, to go through the code.\n```\noOpenAI.IsLogOutputRequired True\n```\n\nThe entire framework can be tested for breaking changes using the `mdTest_OpenAI` module. Simply run the procedure `RunAllTests`.\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\nThis project is licensed under the terms of the MIT license.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzq99%2Fopenai-vba-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzq99%2Fopenai-vba-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzq99%2Fopenai-vba-framework/lists"}