{"id":28047874,"url":"https://github.com/567-labs/instructor-rb","last_synced_at":"2025-10-09T03:34:19.810Z","repository":{"id":217989585,"uuid":"745282341","full_name":"567-labs/instructor-rb","owner":"567-labs","description":"Structured outputs for LLMs","archived":false,"fork":false,"pushed_at":"2025-05-15T13:49:22.000Z","size":373,"stargazers_count":81,"open_issues_count":8,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-10-07T21:32:37.410Z","etag":null,"topics":["artificial-intelligence","artificial-intelligence-projects","chatgpt","chatgpt-api","function-calling","large-language-models","llm","openai","openai-api","openai-assistant-api","structured-data"],"latest_commit_sha":null,"homepage":"https://useinstructor.com/","language":"Ruby","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/567-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"docs/contributing.md","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-01-19T02:02:24.000Z","updated_at":"2025-09-30T22:31:28.000Z","dependencies_parsed_at":"2024-01-19T04:24:26.491Z","dependency_job_id":"4b2099b7-2961-4c6e-b7e8-f58438615bea","html_url":"https://github.com/567-labs/instructor-rb","commit_stats":null,"previous_names":["instructor-ai/instructor-rb","567-labs/instructor-rb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/567-labs/instructor-rb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/567-labs%2Finstructor-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/567-labs%2Finstructor-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/567-labs%2Finstructor-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/567-labs%2Finstructor-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/567-labs","download_url":"https://codeload.github.com/567-labs/instructor-rb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/567-labs%2Finstructor-rb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000714,"owners_count":26082911,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"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":["artificial-intelligence","artificial-intelligence-projects","chatgpt","chatgpt-api","function-calling","large-language-models","llm","openai","openai-api","openai-assistant-api","structured-data"],"created_at":"2025-05-11T21:05:06.964Z","updated_at":"2025-10-09T03:34:19.805Z","avatar_url":"https://github.com/567-labs.png","language":"Ruby","readme":"# instructor-rb\n\n_Structured extraction in Ruby, powered by llms, designed for simplicity, transparency, and control._\n\n---\n\n[![Twitter Follow](https://img.shields.io/twitter/follow/jxnlco?style=social)](https://twitter.com/jxnlco)\n[![Twitter Follow](https://img.shields.io/twitter/follow/sbayona?style=social)](https://twitter.com/sbayona)\n[![Documentation](https://img.shields.io/badge/docs-available-brightgreen)](https://jxnl.github.io/instructor-rb)\n[![GitHub issues](https://img.shields.io/github/issues/instructor-ai/instructor-rb.svg)](https://github.com/instructor-ai/instructor-rb/issues)\n[![Discord](https://img.shields.io/discord/1192334452110659664?label=discord)](https://discord.gg/CV8sPM5k5Y)\n\nInstructor-rb is a Ruby library that makes it a breeze to work with structured outputs from large language models (LLMs). Built on top of [EasyTalk](https://github.com/sergiobayona/easy_talk), it provides a simple, transparent, and user-friendly API to manage validation, retries, and streaming responses. Get ready to supercharge your LLM workflows!\n\n# Getting Started\n\n  1. Install Instructor-rb at the command prompt if you haven't yet:\n  \n        ```bash\n        $ gem install instructor-rb\n        ```\n\n  2. In your Ruby project, require the gem:\n\n        ```ruby\n        require 'instructor'\n        ```\n\n  3. At the beginning of your script, initialize and patch the client:\n\n      For the OpenAI client:\n\n        ```ruby\n        client = Instructor.from_openai(OpenAI::Client)\n        ```\n      For the Anthropic client:\n\n        ```ruby\n        client = Instructor.from_anthropic(Anthropic::Client)\n        ```\n\n## Usage\n\nexport your API key:\n\n```bash\nexport OPENAI_API_KEY=sk-...\n```\n\nor for Anthropic:\n\n```bash\nexport ANTHROPIC_API_KEY=sk-...\n```\n\nThen use Instructor by defining your schema in Ruby using the `define_schema` block and [EasyTalk](https://github.com/sergiobayona/easy_talk)'s schema definition syntax. Here's an example in:\n\n```ruby\nrequire 'instructor'\n\nclass UserDetail\n  include EasyTalk::Model\n\n  define_schema do\n    property :name, String\n    property :age, Integer\n  end\nend\n\nclient = Instructor.from_openai(OpenAI::Client).new\n\nuser = client.chat(\n  parameters: {\n    model: 'gpt-3.5-turbo',\n    messages: [{ role: 'user', content: 'Extract Jason is 25 years old' }]\n  },\n  response_model: UserDetail\n)\n\nuser.name\n# =\u003e \"Jason\"\nuser.age\n# =\u003e 25\n\n```\n\n  \n\u003e ℹ️ **Tip:**  Support in other languages\n\n    Check out ports to other languages below:\n\n    - [Python](https://www.github.com/jxnl/instructor)\n    - [TS/JS](https://github.com/instructor-ai/instructor-js/)\n    - [Ruby](https://github.com/instructor-ai/instructor-rb)\n    - [Elixir](https://github.com/thmsmlr/instructor_ex/)\n\n    If you want to port Instructor to another language, please reach out to us on [Twitter](https://twitter.com/jxnlco) we'd love to help you get started!\n\n## Why use Instructor?\n\n\n1. **OpenAI Integration** — Integrates seamlessly with OpenAI's API, facilitating efficient data management and manipulation.\n\n2. **Customizable** — It offers significant flexibility. Users can tailor validation processes and define unique error messages.\n\n3. **Tested and Trusted** — Its reliability is proven by extensive real-world application.\n\n[Installing Instructor](installation.md) is a breeze. \n\n## Contributing\n\nIf you want to help out, checkout some of the issues marked as `good-first-issue` or `help-wanted`. Found [here](https://github.com/instructor-ai/instructor-js/labels/good%20first%20issue). They could be anything from code improvements, a guest blog post, or a new cook book.\n\nCheckout the [contribution guide]() for details on how to set things up, testing, changesets and guidelines.\n\n## License\n\nThis project is licensed under the terms of the MIT License.\n\n## TODO\n- [ ] Add patch\n  - [ ] Mode.FUNCTIONS\n  - [ ] Mode.TOOLS\n  - [ ] Mode.MD_JSON\n  - [ ] Mode.JSON\n- [ ] Add response_model\n- [ ] Support async\n- [ ] Support stream=True, Partial[T] and iterable[T]\n- [ ] Support Streaming\n- [ ] Optional/Maybe types\n- [ ] Add Tutorials, include in docs\n    - [ ] Text Classification\n    - [ ] Search Queries\n    - [ ] Query Decomposition\n    - [ ] Citations\n    - [ ] Knowledge Graph\n    - [ ] Self Critique\n    - [ ] Image Extracting Tables\n    - [ ] Moderation\n    - [ ] Entity Resolution\n    - [ ] Action Item and Dependency Mapping\n- [ ] Logging for Distillation / Finetuning\n- [ ] Add `llm_validator`","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F567-labs%2Finstructor-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F567-labs%2Finstructor-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F567-labs%2Finstructor-rb/lists"}