{"id":42599982,"url":"https://github.com/saleszera/ruby-chatkit","last_synced_at":"2026-01-29T00:18:54.647Z","repository":{"id":325959317,"uuid":"1099823957","full_name":"saleszera/ruby-chatkit","owner":"saleszera","description":"🤖 Ruby client library for OpenAI's ChatKit API - A Ruby abstraction of chatkit-js with session management, conversations, and file uploads","archived":false,"fork":false,"pushed_at":"2025-12-12T20:06:23.000Z","size":114,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-14T03:30:39.764Z","etag":null,"topics":["chatkit","chatkit-api","openai","ruby","ruby-gem"],"latest_commit_sha":null,"homepage":"","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/saleszera.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-19T13:44:40.000Z","updated_at":"2025-12-12T20:06:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/saleszera/ruby-chatkit","commit_stats":null,"previous_names":["saleszera/ruby-chatkit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/saleszera/ruby-chatkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saleszera%2Fruby-chatkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saleszera%2Fruby-chatkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saleszera%2Fruby-chatkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saleszera%2Fruby-chatkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saleszera","download_url":"https://codeload.github.com/saleszera/ruby-chatkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saleszera%2Fruby-chatkit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28857546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T22:56:21.783Z","status":"ssl_error","status_checked_at":"2026-01-28T22:56:00.861Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["chatkit","chatkit-api","openai","ruby","ruby-gem"],"created_at":"2026-01-29T00:18:53.830Z","updated_at":"2026-01-29T00:18:54.640Z","avatar_url":"https://github.com/saleszera.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruby ChatKit\n\nA Ruby client library for [OpenAI's ChatKit API](https://platform.openai.com/docs/api-reference/chatkit), providing easy-to-use interfaces for creating sessions, sending messages, and uploading files.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Configuration](#configuration)\n  - [Quick Start](#quick-start)\n  - [Debugging with Logger](#debugging-with-logger)\n  - [Sending Messages with File Attachments](#sending-messages-with-file-attachments)\n  - [Advanced Session Configuration](#advanced-session-configuration)\n  - [Manual Session and Conversation Management](#manual-session-and-conversation-management)\n  - [File Upload](#file-upload)\n- [Development](#development)\n- [Contributing](#contributing)\n- [License](#license)\n- [Code of Conduct](#code-of-conduct)\n\n## Features\n\n- 🔐 Session management with automatic refresh\n- 💬 Send text messages to ChatKit conversations\n- 📎 File upload support with message attachments\n- 🔄 Streaming response parsing\n- ⚡ Built-in error handling\n- 📝 Optional logging for debugging HTTP requests and streams\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'ruby-chatkit'\n```\n\nAnd then execute:\n\n```bash\nbundle install\n```\n\nOr install it yourself as:\n\n```bash\ngem install ruby-chatkit\n```\n\n## Usage\n\n### Configuration\n\nConfigure the gem with your OpenAI API key:\n\n```ruby\nChatKit.configure do |config|\n  config.api_key = \"sk-proj-your-api-key-here\"\nend\n```\n\nYou can also set the API key using an environment variable:\n\n```bash\nexport OPENAI_API_KEY=\"sk-proj-your-api-key-here\"\n```\n\n### Quick Start\n\n```ruby\n# Initialize the client\nclient = ChatKit::Client.new\n\n# Create a session\nclient.create_session!(\n  user_id: \"user_123\",\n  workflow_id: \"wf_your_workflow_id\"\n)\n\n# Send a message\nresponse = client.send_message!(text: \"Hello, how are you?\")\nputs response.text\n```\n\n### Debugging with Logger\n\nEnable logging to debug HTTP requests, responses, and streaming data:\n\n```ruby\n# Initialize client with logger\nlogger = Logger.new(STDOUT)\nclient = ChatKit::Client.new(logger: logger)\n\n# Create session and send messages - all requests will be logged\nclient.create_session!(\n  user_id: \"user_123\",\n  workflow_id: \"wf_your_workflow_id\"\n)\n\nresponse = client.send_message!(text: \"Hello, how are you?\")\n# Logs will show:\n# - HTTP method and URI\n# - Response status codes\n# - Stream chunks (debug level)\n```\n\n### Sending Messages with File Attachments\n\n```ruby\n# Open a file\nfile = File.open(\"/path/to/your/image.png\")\n\n# Send message with attachment\nresponse = client.send_message!(\n  text: \"Could you describe this image?\",\n  files: [file]\n)\n\nputs response.text\n```\n\n### Advanced Session Configuration\n\nYou can customize session behavior with additional configuration options:\n\n```ruby\nclient.create_session!(\n  user_id: \"user_123\",\n  workflow_id: \"wf_your_workflow_id\",\n  chatkit_configuration: {\n    # Chat history retention\n    history: {\n      enabled: true,           # Enable conversation history (default: true)\n      recent_threads: 10       # Number of recent threads to keep (default: nil - unlimited)\n    },\n    # File upload settings\n    file_upload: {\n      enabled: true,           # Allow file uploads (default: false)\n      max_file_size: 512,      # Maximum file size in MB (default: 512)\n      max_files: 10            # Maximum number of files per message (default: 10)\n    },\n    # Automatic thread titling\n    automatic_thread_titling: {\n      enabled: true            # Auto-generate thread titles (default: true)\n    }\n  },\n  # Session expiration\n  expires_after: {\n    anchor: \"creation\",        # Base timestamp: \"creation\" or \"last_activity\"\n    seconds: 3600              # Session lifetime in seconds (default: 600 - 10 minutes)\n  },\n  # Rate limiting\n  rate_limits: {\n    max_requests_per_1_minute: 100  # Max requests per minute (default: 10)\n  }\n)\n```\n\n**Configuration Options:**\n\n- [history](https://platform.openai.com/docs/api-reference/chatkit/sessions/create#chatkit_sessions_create-chatkit_configuration-history): Controls conversation history retention\n\n  - `enabled`: Whether to retain chat history (default: `true`)\n  - `recent_threads`: Limit the number of recent threads kept (default: `nil` - unlimited)\n\n- [file_upload](https://platform.openai.com/docs/api-reference/chatkit/sessions/create#chatkit_sessions_create-chatkit_configuration-file_upload): Controls file upload capabilities\n\n  - `enabled`: Allow file uploads in conversations (default: `false`)\n  - `max_file_size`: Maximum file size in MB (default: `512`)\n  - `max_files`: Maximum number of files per message (default: `10`)\n\n- [automatic_thread_titling](https://platform.openai.com/docs/api-reference/chatkit/sessions/create#chatkit_sessions_create-chatkit_configuration-automatic_thread_titling): Automatically generate descriptive thread titles\n\n  - `enabled`: Enable auto-titling (default: `true`)\n\n- [expires_after](https://platform.openai.com/docs/api-reference/chatkit/sessions/create#chatkit_sessions_create-expires_after): Session expiration settings\n\n  - `anchor`: Base timestamp - `\"creation\"` (session created) or `\"last_activity\"` (last request)\n  - `seconds`: Time in seconds until session expires (default: `600` - 10 minutes)\n\n- [rate_limits](https://platform.openai.com/docs/api-reference/chatkit/sessions/create#chatkit_sessions_create-rate_limits): Request rate limiting\n  - `max_requests_per_1_minute`: Maximum API requests per minute (default: `10`)\n\n### Manual Session and Conversation Management\n\nFor more control, you can use the underlying classes directly:\n\n```ruby\n# Create a session manually\nsession = ChatKit::Session.create!(\n  user_id: \"user_123\",\n  workflow: { id: \"wf_your_workflow_id\" },\n  client: client\n)\n\n# Send a conversation message\nconversation = ChatKit::Conversation.send_message!(\n  client_secret: session.response.client_secret,\n  text: \"Hello!\",\n  client: client\n)\n\n# Access the response\nanswer = conversation.response.answer\nputs answer.text\n```\n\n### File Upload\n\nUpload files to ChatKit:\n\n```ruby\nfile = File.open(\"/path/to/document.pdf\")\n\nresponse = ChatKit::Files.upload!(\n  client_secret: session.response.client_secret,\n  file: file,\n  client: client\n)\n\nputs response.id\nputs response.name\nputs response.mime_type\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/saleszera/ruby-chatkit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ruby-chatkit/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Ruby::Chatkit project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ruby-chatkit/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaleszera%2Fruby-chatkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaleszera%2Fruby-chatkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaleszera%2Fruby-chatkit/lists"}