{"id":13619138,"url":"https://github.com/wilsonsilva/mistral","last_synced_at":"2025-04-10T12:12:35.880Z","repository":{"id":238189267,"uuid":"791887899","full_name":"wilsonsilva/mistral","owner":"wilsonsilva","description":"A 1:1 Ruby port of the official Mistral Python client, with feature and API parity.","archived":false,"fork":false,"pushed_at":"2024-06-09T21:18:47.000Z","size":73,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T08:55:48.068Z","etag":null,"topics":["ai","artificial-intelligence","mistral","mistral-ai","mistral-api","port","python","ruby","ruby-gem","rubygem"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/mistral","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/wilsonsilva.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}},"created_at":"2024-04-25T15:06:52.000Z","updated_at":"2025-03-16T22:31:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"a3343c71-fb2b-4db0-9239-9c3e343e89ab","html_url":"https://github.com/wilsonsilva/mistral","commit_stats":null,"previous_names":["wilsonsilva/mistral"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fmistral","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fmistral/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fmistral/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fmistral/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wilsonsilva","download_url":"https://codeload.github.com/wilsonsilva/mistral/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217080,"owners_count":21066633,"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":["ai","artificial-intelligence","mistral","mistral-ai","mistral-api","port","python","ruby","ruby-gem","rubygem"],"created_at":"2024-08-01T21:00:35.276Z","updated_at":"2025-04-10T12:12:35.856Z","avatar_url":"https://github.com/wilsonsilva.png","language":"Ruby","readme":"# Mistral Ruby Client\n\n[![Gem Version](https://badge.fury.io/rb/mistral.svg)](https://badge.fury.io/rb/mistral)\n![Build](https://github.com/wilsonsilva/mistral/actions/workflows/main.yml/badge.svg)\n\nMistral is a Ruby gem to interact with the [Mistral AI API](https://www.mistral.ai).\n\nThis client is a 1:1 port of Mistral's [client-python](https://github.com/mistralai/client-python).\nFor a detailed comparison between the Ruby and Python clients, please refer to the\n[PYTHON_CLIENT_COMPARISON.md](https://github.com/wilsonsilva/mistral/blob/main/PYTHON_CLIENT_COMPARISON.md) file.\n\n## 🔑 Key features\n\n- API parity with the official [Python client](https://github.com/mistralai/client-python)\n- Full support for all Mistral AI functionalities, including chat completions, embeddings, and function calling\n- Asynchronous streaming of responses\n- Comprehensive error handling and retry mechanisms\n- Configurable client options (e.g., API endpoint, timeout, max retries)\n- Fully leverages `dry-struct` for type safety and avoids primitive obsession with hashes\n\n## 📦 Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n```\n$ bundle add mistral\n```\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n```\n$ gem install mistral\n```\n\n## ⚡️ Quickstart\n\nHere are a few examples of how to use the Mistral gem:\n\n### Chat completion\n\n```ruby\nrequire 'mistral'\n\napi_key = ENV.fetch('MISTRAL_API_KEY')\nclient = Mistral::Client.new(api_key: api_key)\n\nmodel = 'mistral-small'\n\nchat_response = client.chat(\n model: model,\n messages: [\n   Mistral::ChatMessage.new(role: 'user', content: 'What is the best French cheese?')\n ]\n)\n\nputs chat_response.choices[0].message.content\n```\n\n### Chat completion with streaming\n\n```ruby\nrequire 'mistral'\n\napi_key = ENV.fetch('MISTRAL_API_KEY')\nclient = Mistral::Client.new(api_key: api_key)\n\nmodel = 'mistral-small'\n\nclient.chat_stream(\n  model: model,\n  messages: [\n    Mistral::ChatMessage.new(role: 'user', content: 'What is the best French cheese?')\n  ]\n).each do |chunk|\n  print chunk.choices[0].delta.content if chunk.choices[0].delta.content\nend\n```\n\n## 📚 Documentation\n\nIn the [`examples`](https://github.com/wilsonsilva/mistral/tree/main/examples) folder, you will find how to do:\n\n| File Name                                                                                                                | Description                                                    |\n|--------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|\n| [`chat_no_streaming.rb`](https://github.com/wilsonsilva/mistral/blob/main/examples/chat_no_streaming.rb)                 | How to use the chat endpoint without streaming                 |\n| [`chat_with_streaming.rb`](https://github.com/wilsonsilva/mistral/blob/main/examples/chat_with_streaming.rb)             | How to use the chat endpoint with streaming                    |\n| [`chatbot_with_streaming.rb`](https://github.com/wilsonsilva/mistral/blob/main/examples/chatbot_with_streaming.rb)       | A simple interactive chatbot using streaming                   |\n| [`code_completion.rb`](https://github.com/wilsonsilva/mistral/blob/main/examples/code_completion.rb)                     | How to perform a code completion                               |\n| [`completion_with_streaming.rb`](https://github.com/wilsonsilva/mistral/blob/main/examples/completion_with_streaming.rb) | How to perform a code completion with streaming                |\n| [`embeddings.rb`](https://github.com/wilsonsilva/mistral/blob/main/examples/embeddings.rb)                               | How to use the embeddings endpoint                             |\n| [`function_calling.rb`](https://github.com/wilsonsilva/mistral/blob/main/examples/function_calling.rb)                   | How to call functions using the chat endpoint                  |\n| [`json_format.rb`](https://github.com/wilsonsilva/mistral/blob/main/examples/json_format.rb)                             | How to request and parse JSON responses from the chat endpoint |\n| [`list_models.rb`](https://github.com/wilsonsilva/mistral/blob/main/examples/list_models.rb)                             | How to list available models                                   |\n\n## 🔨 Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\nYou can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,\nwhich will create a git tag for the version, push git commits and the created tag, and push the `.gem` file\nto [rubygems.org](https://rubygems.org).\n\nThe health and maintainability of the codebase is ensured through a set of Rake tasks to test and lint the gem:\n\n```\nrake build                    # Build mistral into the pkg directory\nrake build:checksum           # Generate SHA512 checksum if mistral.gem into the checksums directory\nrake clean                    # Remove any temporary products\nrake clobber                  # Remove any generated files\nrake install                  # Build and install mistral.gem into system gems\nrake install:local            # Build and install mistral.gem into system gems without network access\nrake release[remote]          # Create tag v0.1.0 and build and push mistral.gem to https://rubygems.org\nrake rubocop                  # Run RuboCop\nrake rubocop:autocorrect      # Autocorrect RuboCop offenses (only when it's safe)\nrake rubocop:autocorrect_all  # Autocorrect RuboCop offenses (safe and unsafe)\nrake test                     # Run the test suite\nrake test:cmd                 # Print out the test command\nrake test:isolated            # Show which test files fail when run in isolation\nrake test:slow                # Show bottom 25 tests wrt time\n```\n\n## 🐞 Issues \u0026 Bugs\n\nIf you find any issues or bugs, please report them [here](https://github.com/wilsonsilva/mistral/issues), I will be happy\nto have a look at them and fix them as soon as possible.\n\nPlease let me know if the [client-python](https://github.com/mistralai/client-python) introduces any new features,\nso I can keep this gem in sync with the latest updates.\n\n## 🤝 Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wilsonsilva/mistral.\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere\nto the [code of conduct](https://github.com/wilsonsilva/mistral/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 mistral project's codebases, issue trackers, chat rooms and mailing lists is expected\nto follow the [code of conduct](https://github.com/wilsonsilva/mistral/blob/main/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":["Open Source"],"sub_categories":["API Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilsonsilva%2Fmistral","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilsonsilva%2Fmistral","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilsonsilva%2Fmistral/lists"}