{"id":15713555,"url":"https://github.com/dmarshaltu/openai","last_synced_at":"2025-05-12T22:54:53.942Z","repository":{"id":186591442,"uuid":"675409922","full_name":"DmarshalTU/openai","owner":"DmarshalTU","description":"OpenAI library for Crystal, providing an interface to interact with various OpenAI services.","archived":false,"fork":false,"pushed_at":"2024-01-17T01:36:09.000Z","size":834,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T22:54:47.071Z","etag":null,"topics":["chatgpt","chatgpt-api","crystal","crystal-lang","crystal-language","openai"],"latest_commit_sha":null,"homepage":"https://bento.me/dmarshaltu","language":"Crystal","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/DmarshalTU.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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":"2023-08-06T20:18:23.000Z","updated_at":"2025-03-26T13:22:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"a5cf805c-9b73-4a0b-9bc3-1de0e49566c0","html_url":"https://github.com/DmarshalTU/openai","commit_stats":null,"previous_names":["dmarshaltu/openai"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmarshalTU%2Fopenai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmarshalTU%2Fopenai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmarshalTU%2Fopenai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmarshalTU%2Fopenai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DmarshalTU","download_url":"https://codeload.github.com/DmarshalTU/openai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253837389,"owners_count":21971981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","crystal","crystal-lang","crystal-language","openai"],"created_at":"2024-10-03T21:32:05.091Z","updated_at":"2025-05-12T22:54:53.921Z","avatar_url":"https://github.com/DmarshalTU.png","language":"Crystal","funding_links":["https://www.buymeacoffee.com/100kw"],"categories":[],"sub_categories":[],"readme":"# openaiAPI\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/100kw)\n\n\n![opanAI](./images/opanaiAPI.png)\n\nOpenAI library for Crystal, providing an interface to interact with various OpenAI services.\n\n## Features\n\n- [x] Authentication\n- Engine Interaction\n  - [x] List available engines.\n  - [ ] Retrieve details about a specific engine.\n- [x] Completion Requests\n  - [x] Create completions.\n  - [ ] Retrieve a specific completion.\n- [x] Error Handling\n  - [ ] Implement robust error handling for different scenarios.\n- [ ] Usage Information\n  - [ ] Provide methods to retrieve API usage information.\n- [ ] Documentation and Examples\n  - [ ] Include comprehensive documentation and example code for each function.\n- [ ] Testing\n  - [ ] Write unit tests to cover the main functionality.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     openai:\n       github: dmarshaltu/openai\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"openai\"\n\n\nOPENAI_KEY = api_key().to_s\nclient = OpenAI::Client.new(OPENAI_KEY)\n\n# Example usage: List available models\nbegin\n  models = client.list_models\nrescue OpenAI::AuthenticationError\n  puts \"Authentication failed: Check your API key.\"\nend\n\n# Define your messages array\nmessages = [\n  {\"role\" =\u003e \"system\", \"content\" =\u003e \"You are a helpful assistant.\"},\n  {\"role\" =\u003e \"user\", \"content\" =\u003e \"Tell me a joke.\"}\n]\n\nmodel = \"gpt-3.5-turbo\"\nmax_tokens = 150\n\nresponse = client.create_chat_completion(messages, model, max_tokens)\nputs response\n\n```\n\nresponse:\n\n```bash\n\"OPENAI_KEY\"\n2024-01-11T14:13:52.075201Z  DEBUG - http.client: Performing request -- method: \"GET\", host: \"api.openai.com\", port: 443, resource: \"/v1/engines\"\n{\n  \"object\": \"list\",\n  \"data\": [\n    {\n      \"object\": \"engine\",\n      \"id\": \"gpt-4-0613\",\n      \"ready\": true,\n      \"owner\": \"openai\",\n      \"permissions\": null,\n      \"created\": null\n    },\n    {\n      \"object\": \"engine\",\n      \"id\": \"curie-search-query\",\n      \"ready\": true,\n      \"owner\": \"openai-dev\",\n      \"permissions\": null,\n      \"created\": null\n    },\n    ...\n    ...\n    ...\n2024-01-11T14:13:52.889580Z  DEBUG - http.client: Performing request -- method: \"POST\", host: \"api.openai.com\", port: 443, resource: \"/v1/chat/completions\"\n{text: \"Sure, here's a classic one for you: \\n\\nWhy don't scientists trust atoms? \\n\\nBecause they make up everything!\", id: \"chatcmpl-8fq6bn9amQ58M942YLnTDUtvS62TV\"}\n\n```\n\nExample project with image creation and DallE 3:\n[microdallecr](https://github.com/DmarshalTU/microdallecr.git)\n\n## Development\n\nTODO: Write development instructions here\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/dmarshaltu/openai/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [dmarshaltu](https://github.com/dmarshaltu) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmarshaltu%2Fopenai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmarshaltu%2Fopenai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmarshaltu%2Fopenai/lists"}