{"id":22668140,"url":"https://github.com/wojtekb30/easyapiopenai","last_synced_at":"2026-01-30T13:03:58.389Z","repository":{"id":262628186,"uuid":"865606639","full_name":"Wojtekb30/EasyAPIOpenAI","owner":"Wojtekb30","description":"Python classes which allow using OpenAI API easily. Based fully on web requests.","archived":false,"fork":false,"pushed_at":"2024-11-13T13:34:43.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T06:42:45.266Z","etag":null,"topics":["ai","library","openai-api","python3","requests"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/EasyAPIOpenAI/","language":"Python","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/Wojtekb30.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-30T20:08:17.000Z","updated_at":"2024-11-13T13:34:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"50361e6d-f37e-4705-8e11-e757f3826c3c","html_url":"https://github.com/Wojtekb30/EasyAPIOpenAI","commit_stats":null,"previous_names":["wojtekb30/easyapiopenai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Wojtekb30/EasyAPIOpenAI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wojtekb30%2FEasyAPIOpenAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wojtekb30%2FEasyAPIOpenAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wojtekb30%2FEasyAPIOpenAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wojtekb30%2FEasyAPIOpenAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wojtekb30","download_url":"https://codeload.github.com/Wojtekb30/EasyAPIOpenAI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wojtekb30%2FEasyAPIOpenAI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28913328,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T12:13:43.263Z","status":"ssl_error","status_checked_at":"2026-01-30T12:13:22.389Z","response_time":66,"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":["ai","library","openai-api","python3","requests"],"created_at":"2024-12-09T15:13:54.447Z","updated_at":"2026-01-30T13:03:58.373Z","avatar_url":"https://github.com/Wojtekb30.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAI-API-requests\n\nPython classes that allow for easy interaction with the OpenAI API, based fully on web requests.\n\nThe classes are well documented within the code file.\n\n## Currently Available Classes\n\n### ChatGPTAgent\n- Allows you to create an instance (object) of ChatGPT.\n- Saves conversation history and supports tweaking all parameters like model, system prompt, temperature, etc.\n- **Methods:**\n  - `GetResponse`: Send a new message to the chatbot.\n  - `ChangeSystemMessage`: Change the system message without affecting conversation history.\n  - `ClearHistory`: Reset message history.\n\n### ImgChatGPTAgent\n- Similar to `ChatGPTAgent`, but introduces an additional method:\n  - `GetResponseWithImg`: Send a message containing an image file.\n- **Note:** As of now, only ChatGPT 4o and 4o-mini support processing images.\n\n### DallEAgent\n- Allows you to generate an image with the DALL-E AI image generator.\n- **Methods:**\n  - `GetImage`: Get the image as a PIL Image variable.\n  - `GetImageURL`: Get a link to the generated image.\n\n## Usage\n\nYou can download the package using PIP:\n\n```bash\npip install EasyAPIOpenAI\n```\n\nThen, use it as follows:\n\n```python\nimport easyapiopenai as oai\n\nagent = oai.ChatGPTAgent(\"api-key\", 'gpt-3.5-turbo')\n```\n\nAlternatively, if you prefer not to use PIP or are working with MicroPython, download the source code into the same folder and write:\n\n```python\nfrom APIWojOpenAI import *\n```\n\nMake sure to adjust the filename as necessary.\n\nThen, you can use it like this:\n\n```python\nagent = ChatGPTAgent(\"api-key\", 'gpt-3.5-turbo')\n```\n\nThe `ChatGPTAgent` class should work well on embedded MicroPython systems, such as Raspberry Pi Pico. In that case, remove other classes from the file and replace all import statements with:\n\n```python\nimport urequests as requests\n```\n\n## Example Code\n\n```python\nimport easyapiopenai as oai\n\nAPI_KEY = 'KEY'  # OpenAI API key; always remember to secure it properly.\n\nbot = oai.ChatGPTAgent(API_KEY, model=\"gpt-3.5-turbo\", max_tokens=1000, role=\"Your name is Bob\")\n\nmessage = \"Hello, who are you?\"  # Sample message\nanswer = bot.GetResponse(message)  # Get answer\nprint(answer)\n\nmessage = \"Remember that my favourite animal is a lizard.\"  # Second sample message\nanswer = bot.GetResponse(message)  # Get next answer, continuing conversation\nprint(answer)\n\nmessage = \"What is my favourite animal?\"  # Third sample message, to prove it remembers\nanswer = bot.GetResponse(message)  # Get next answer, continuing conversation\nprint(answer)\n```\n\n**Output:**\n```\nHi there! My name is Bob. How can I assist you today?\nGot it! Your favorite animal is a lizard. Would you like to talk about lizards or anything else related to them?\nYour favorite animal is a lizard.\n```\n\n## Known Errors and Things to Keep in Mind\n\n- An incorrect API key, nonexistent AI model, or other impossible parameters will result in a 404 error.\n- `ImgChatGPTAgent` may not remember the image for longer than one or two subsequent questions.\n- If chat history exceeds 100 messages, the AI might stop working. This behavior depends on the AI model; it has been observed with GPT-3.5-turbo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwojtekb30%2Feasyapiopenai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwojtekb30%2Feasyapiopenai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwojtekb30%2Feasyapiopenai/lists"}