{"id":19660630,"url":"https://github.com/skotchpine/orbai","last_synced_at":"2026-05-04T22:33:12.491Z","repository":{"id":202916323,"uuid":"708405220","full_name":"skotchpine/orbai","owner":"skotchpine","description":"orbai is an idiomatic Ruby DSL for OpenAI's powerful API","archived":false,"fork":false,"pushed_at":"2023-10-22T15:14:11.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-08T03:51:23.988Z","etag":null,"topics":["chatgpt","chatgpt-api","openai","openai-api","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"https://github.com/skotchpine/orbai","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skotchpine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-22T13:23:08.000Z","updated_at":"2023-10-22T15:22:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"31604a30-efe7-4609-951f-61169e88a29b","html_url":"https://github.com/skotchpine/orbai","commit_stats":null,"previous_names":["skotchpine/orbai","skotchpine/orbnai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/skotchpine/orbai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skotchpine%2Forbai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skotchpine%2Forbai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skotchpine%2Forbai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skotchpine%2Forbai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skotchpine","download_url":"https://codeload.github.com/skotchpine/orbai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skotchpine%2Forbai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32628209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"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","openai","openai-api","ruby","ruby-on-rails"],"created_at":"2024-11-11T16:04:42.090Z","updated_at":"2026-05-04T22:33:12.470Z","avatar_url":"https://github.com/skotchpine.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `orbai`: A Ruby DSL for OpenAI\n\nWelcome to `orbai`, an idiomatic Ruby DSL for OpenAI's powerful API. With the\ncombination of Ruby's natural language processing strengths and OpenAI's\nadvanced capabilities, your applications are set to take a massive leap forward.\n\n## Disclaimer\n\nPlease be aware that `orbai` is in its early stages and is not maintained\nregularly. While we aim to provide the best, there might be bugs or\nunimplemented features. Your patience and contributions are highly appreciated.\n\n## Quick Start (For Rubyists)\n\n1. Install the orbai gem:\n\n```sh\ngem install orbai\n```\n\n1. [Have an OpenAI API key](https://beta.openai.com/account/api-keys) in your\n   environment. By default, `orbai` will look for `OPENAI_API_KEY`..\n\n1. Use `orbai` to query OpenAI:\n\n```ruby\nrequire \"orbai\"\n\nOrbai.query(\"What's the capital of France?\")\n\n# =\u003e \"The capital of France is Paris.\"\n```\n\n## Rationale\n\n1. **Ruby is the Best Language for DSLs**: Ruby's expressiveness has made it the\n   go-to language for Domain Specific Languages, finding its use in a myriad of\n   practical domains.\n2. **OpenAI \u0026 Ruby**: OpenAI offers transformative capabilities to the domains\n   where Ruby DSLs excel.\n3. **orbai**: Born out of the need for an expressive, easy-to-integrate tool\n   that merges the power of OpenAI and the elegance of Ruby.\n\n## Getting Started (For Newbies)\n\n1. Installing Ruby: If you're a technical person, we recommend using\n   [asdf-vm](https://github.com/asdf-vm/asdf) for version management.\n1. Learning Ruby: If you're new to Ruby... `TODO`\n1. Follow the \"Quick Start\" guide above to get up and running.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run\n`rake spec` to run the tests. You can also run `bin/console` for an interactive\nprompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To\nrelease a new version, update the version number in `version.rb`, and then run\n`bundle exec rake release`, which will create a git tag for the version, push\ngit commits and the created tag, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\n\n## Contributing\n\nWe welcome contributions to `orbai`! If you stumble upon issues or have features\nyou'd like to suggest, please:\n\n- [Submit an issue](https://github.com/skotchpine/orbai/issues)\n- For direct contributions,\n  [submit a pull request](https://github.com/skotchpine/orbai/pulls).\n\n## Help Wanted!\n\n- 🔲 Feedback\n- 🔲 Docs\n- 🔲 Tests\n- 🔲 Triage\n- 🔲 Imagination\n\n## `Orbai::DSL`\n\n### Simple Query API\n\n```ruby\nrequire \"orbai\"\nOrbai.query(\"What is your favorite color?\")\n#=\u003e \"My favorite color is blue.\"\n```\n\n### Wishlist\n\n- 🔲 Config DX\n- 🔲 Roles Builder DX\n- 🔲 Context Params DX\n- 🔲 Extract structured data\n- 🔲 Functions DX\n- 🔲 Images DX\n- 🔲 Audio DX\n- 🔲 Files DX\n- 🔲 Embeddings DX\n- 🔲 Fine-tuning DX\n\n## `Orbai` Module / `HttpClient` HTTP Methods\n\nThe `Orbai` module is just a container for everything else.\n\nFor ease of use, it includes http getters through an `HttpClient` singleton.\n\nThe HTTP getters throw an `Orbai::HTTPClient::Error` if the request fails. The\nOpenAI API `type` field from the error response is assigned to\n`Orbai::HTTPClient::Error#type`.\n\n### Example\n\n```ruby\nOrbai.get(\"/chat/completions\", model: 'gpt-3.5-turbo', messages: [\n  {role:'system',content:'Act as a helpful prompt.'},\n  {role:'user',content:'What is the capital of France?'},\n])\n\n# Returns\n{\"id\"=\u003e\"chatcmpl-XXXXXXXX\",\n \"object\"=\u003e\"chat.completion\",\n \"created\"=\u003e1697444538,\n \"model\"=\u003e\"gpt-3.5-turbo-0613\",\n \"choices\"=\u003e\n  [{\"index\"=\u003e0,\n    \"message\"=\u003e\n     {\"role\"=\u003e\"assistant\", \"content\"=\u003e\"The capital of France is Paris.\"},\n    \"finish_reason\"=\u003e\"stop\"}],\n \"usage\"=\u003e{\"prompt_tokens\"=\u003e24, \"completion_tokens\"=\u003e7, \"total_tokens\"=\u003e31}}\n```\n\n### `Orbai` Shortcuts / `HttpClient` HTTP Methods\n\n```ruby\nc = Orbai::HttpClient.new\n\n# HttpClient singleton\nc.http_client #=\u003e #\u003cOrbai::HttpClient\u003e\n\n# HTTP Methods\nc.get(path, **params) #=\u003e Returns JSON result as a ruby hash.\nc.post(path, **params)\nc.put(path, **params)\nc.patch(path, **params)\nc.delete(path, **params)\nc.http_request(method, path, **params)\n```\n\n## `Orbai::HttpClient`\n\nThe `HttpClient` class is used to make requests to the OpenAI API. It returns\nthe JSON response from the API as a ruby hash.\n\n### Example:\n\n```ruby\nc = Orbai::HttpClient.new\n\nc.chat_completions(\n  model: 'gpt-3.5-turbo',\n  messages: [\n    {role:'system',content:'Act as a helpful prompt.'},\n    {role:'user',content:'What is the capital of France?'},\n  ],\n)\n\n# Returns\n{\"id\"=\u003e\"chatcmpl-XXXXXXXX\",\n \"object\"=\u003e\"chat.completion\",\n \"created\"=\u003e1697983333,\n \"model\"=\u003e\"gpt-3.5-turbo-0613\",\n \"choices\"=\u003e\n  [{\"index\"=\u003e0,\n    \"message\"=\u003e\n     {\"role\"=\u003e\"assistant\", \"content\"=\u003e\"The capital of France is Paris.\"},\n    \"finish_reason\"=\u003e\"stop\"}],\n \"usage\"=\u003e{\"prompt_tokens\"=\u003e24, \"completion_tokens\"=\u003e7, \"total_tokens\"=\u003e31}}\n```\n\n### API Methods Cheatsheet\n\n```ruby\nc = Orbai::HttpClient.new\n\n# Chat\n#   POST /chat/completions\nc.chat_completions(**params)\n\n# Completions\n#   POST /completions\nc.completions(**params)\n\n# Edits\n#   POST /edits\nc.edits(**params)\n\n# Images\n#   POST /images/generations\nc.create_image(**params)\n#   POST /images/edits\nc.create_image_edit(**params)\n#   POST /images/variations\nc.create_image_variation(**params)\n\n# Embeddings\n#   POST /embeddings\nc.create_embedding(**params)\n\n# Fine_tuning\n#\n#   POST /fine_tuning/jobs\nc.create_fine_tuning_jobs(**params)\n#   GET /fine_tuning/jobs\nc.list_fine_tuning_jobs(**params)\n#   GET /fine_tuning/jobs/{fine_tuning_job_id}\nc.retrieve_fine_tuning_job(id, **params)\n#   POST /fine_tuning/jobs/{fine_tuning_job_id}/cancel\nc.cancel_fine_tuning_job(id, **params)\n#   GET /fine_tuning/jobs/{fine_tuning_job_id}/events\nc.list_fine_tuning_events(id, **params)\n\n# Audio\n#   POST /audio/transcriptions\nc.create_transcription(**params)\n#   POST /audio/translations\nc.create_translation(**params)\n\n# Files\n#   GET /files\nc.list_files(**params)\n#   POST /files\nc.upload_file(**params)\n#   DELETE /files/{file_id}\nc.delete_file(id, **params)\n#   GET /files/{file_id}\nc.retrieve_file(id, **params)\n#   GET /files/{file_id}/content\nc.file_content(id, **params)\n\n# Models\n#   GET /models\nc.list_models(**params)\n#   GET /models/{model}\nc.retrieve_model(id, **params)\n#   DELETE /models/{model}\nc.delete_model(id, **params)\n\n# Moderations\n#   POST /moderations\nc.create_moderation(**params)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskotchpine%2Forbai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskotchpine%2Forbai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskotchpine%2Forbai/lists"}