{"id":24974955,"url":"https://github.com/nagstler/deepseek-ruby","last_synced_at":"2025-04-11T11:51:27.914Z","repository":{"id":275410952,"uuid":"926001856","full_name":"nagstler/deepseek-ruby","owner":"nagstler","description":"🐋 Deepseek Ruby – a simple, easy-to-integrate SDK for accessing the Deepseek API","archived":false,"fork":false,"pushed_at":"2025-02-02T14:08:07.000Z","size":31,"stargazers_count":21,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T08:11:12.203Z","etag":null,"topics":["ai","deepseek","deepseek-r1","ruby","ruby-gem","ruby-on-rails"],"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/nagstler.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2025-02-02T09:52:08.000Z","updated_at":"2025-03-07T04:44:28.000Z","dependencies_parsed_at":"2025-02-02T10:41:03.660Z","dependency_job_id":null,"html_url":"https://github.com/nagstler/deepseek-ruby","commit_stats":null,"previous_names":["nagstler/deepseek-ruby"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nagstler%2Fdeepseek-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nagstler%2Fdeepseek-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nagstler%2Fdeepseek-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nagstler%2Fdeepseek-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nagstler","download_url":"https://codeload.github.com/nagstler/deepseek-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248390142,"owners_count":21095736,"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","deepseek","deepseek-r1","ruby","ruby-gem","ruby-on-rails"],"created_at":"2025-02-03T20:43:37.106Z","updated_at":"2025-04-11T11:51:27.891Z","avatar_url":"https://github.com/nagstler.png","language":"Ruby","readme":"# Deepseek Ruby SDK\n\n\u003ca href=\"https://badge.fury.io/rb/deepseek-client\"\u003e\n  \u003cimg src=\"https://img.shields.io/gem/v/deepseek-client?style=for-the-badge\" alt=\"Gem Version\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge\" alt=\"License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codeclimate.com/github/nagstler/deepseek-ruby/maintainability\"\u003e\u003cimg src=\"https://img.shields.io/codeclimate/maintainability/nagstler/deepseek-ruby?style=for-the-badge\" alt=\"Maintainability\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codeclimate.com/github/nagstler/deepseek-ruby/test_coverage\"\u003e\u003cimg src=\"https://img.shields.io/codeclimate/coverage/nagstler/deepseek-ruby?style=for-the-badge\" alt=\"Test Coverage\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/nagstler/deepseek-ruby/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/nagstler/deepseek-ruby/ci.yml?branch=main\u0026style=for-the-badge\" alt=\"CI\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/nagstler/deepseek-ruby/stargazers\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/nagstler/deepseek-ruby?style=for-the-badge\" alt=\"GitHub stars\"\u003e\u003c/a\u003e\n\nA Ruby SDK for interacting with the Deepseek AI API. This SDK provides a simple and intuitive interface for making API calls, handling responses, and managing errors.\n\n## Features\n\n- 🚀 Simple and intuitive interface\n- ⚡️ Automatic retries with exponential backoff\n- 🛡️ Comprehensive error handling\n- ⚙️ Flexible configuration options\n- 🔒 Secure API key management\n- 📝 Detailed response handling\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Configuration](#configuration)\n- [API Reference](#api-reference)\n- [Usage Examples](#usage-examples)\n- [Error Handling](#error-handling)\n- [Retry Handling](#retry-handling)\n- [Development](#development)\n- [Contributing](#contributing)\n- [Support](#support)\n- [License](#license)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'deepseek-client'\n```\n\nAnd then execute:\n\n```bash\n$ bundle install\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install deepseek-client\n```\n\n## Quick Start\n\n```ruby\nrequire 'deepseek'\n\n# Initialize client\nclient = Deepseek::Client.new(api_key: 'your-api-key')\n\n# Make a chat completion request\nresponse = client.chat(\n  messages: [\n    { role: 'user', content: 'What is artificial intelligence?' }\n  ],\n  model: 'deepseek-chat'\n)\n\nputs response['choices'][0]['message']['content']\n```\n\n## Configuration\n\n### Basic Configuration\n\n```ruby\nclient = Deepseek::Client.new(\n  api_key: 'your-api-key',\n  timeout: 60,      # Custom timeout in seconds\n  max_retries: 3    # Number of retries for failed requests\n)\n```\n\n### Environment Variables\n\nThe SDK supports configuration through environment variables:\n\n```bash\nDEEPSEEK_API_KEY=your-api-key\nDEEPSEEK_API_BASE_URL=https://api.deepseek.com  # Optional\nDEEPSEEK_TIMEOUT=30                             # Optional\nDEEPSEEK_MAX_RETRIES=3                         # Optional\n```\n\n## API Reference\n\n### Available Methods\n\n#### chat(messages:, model: 'deepseek-chat', **params)\n\nMake a chat completion request.\n\nParameters:\n- `messages` (Array, required): Array of message objects\n- `model` (String, optional): Model to use, defaults to 'deepseek-chat'\n- `temperature` (Float, optional): Sampling temperature\n\nResponse Format:\n```ruby\n{\n  \"choices\" =\u003e [{\n    \"message\" =\u003e {\n      \"content\" =\u003e \"Hello! How can I help you today?\",\n      \"role\" =\u003e \"assistant\"\n    },\n    \"finish_reason\" =\u003e \"stop\"\n  }],\n  \"created\" =\u003e 1677649420,\n  \"id\" =\u003e \"chatcmpl-123\",\n  \"model\" =\u003e \"deepseek-chat\",\n  \"usage\" =\u003e {\n    \"completion_tokens\" =\u003e 17,\n    \"prompt_tokens\" =\u003e 57,\n    \"total_tokens\" =\u003e 74\n  }\n}\n```\n\n## Usage Examples\n\n### Chat with System Message\n```ruby\nresponse = client.chat(\n  messages: [\n    { role: 'system', content: 'You are a friendly AI assistant.' },\n    { role: 'user', content: 'Hello!' }\n  ],\n  temperature: 0.7,\n  model: 'deepseek-chat'\n)\n```\n\n### Conversation with History\n```ruby\nconversation = [\n  { role: 'user', content: 'What is your favorite color?' },\n  { role: 'assistant', content: 'I don\\'t have personal preferences, but I can discuss colors!' },\n  { role: 'user', content: 'Tell me about blue.' }\n]\n\nresponse = client.chat(\n  messages: conversation,\n  temperature: 0.8\n)\n```\n\n### Advanced Configuration Example\n```ruby\nclient = Deepseek::Client.new(\n  api_key: ENV['DEEPSEEK_API_KEY'],\n  timeout: 60,               # Custom timeout\n  max_retries: 5,           # Custom retry limit\n  api_base_url: 'https://custom.deepseek.api.com'  # Custom API URL\n)\n```\n\n## Error Handling\n\nThe SDK provides comprehensive error handling for various scenarios:\n\n```ruby\nbegin\n  response = client.chat(messages: messages)\nrescue Deepseek::AuthenticationError =\u003e e\n  # Handle authentication errors (e.g., invalid API key)\n  puts \"Authentication error: #{e.message}\"\nrescue Deepseek::RateLimitError =\u003e e\n  # Handle rate limit errors\n  puts \"Rate limit exceeded: #{e.message}\"\nrescue Deepseek::InvalidRequestError =\u003e e\n  # Handle invalid request errors\n  puts \"Invalid request: #{e.message}\"\nrescue Deepseek::ServiceUnavailableError =\u003e e\n  # Handle API service errors\n  puts \"Service error: #{e.message}\"\nrescue Deepseek::APIError =\u003e e\n  # Handle other API errors\n  puts \"API error: #{e.message}\"\nend\n```\n\n## Retry Handling\n\nThe SDK automatically handles retries with exponential backoff for failed requests:\n\n- Automatic retry on network failures\n- Exponential backoff strategy\n- Configurable max retry attempts\n- Retry on rate limits and server errors\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\n### Running Tests\n\n```bash\nbundle exec rake spec\n```\n\n### Running the Console\n\n```bash\nbin/console\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/nagstler/deepseek-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](CODE_OF_CONDUCT.md).\n\nFor detailed contribution guidelines, please see our [Contributing Guide](CONTRIBUTING.md).\n\n## Support\n\nIf you discover any issues or have questions, please create an issue on GitHub.\n\n## License\n\nThe gem is available as open source under the terms of the MIT License. See [LICENSE.txt](LICENSE.txt) for details.\n\n## Code of Conduct\n\nEveryone interacting in the Deepseek project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnagstler%2Fdeepseek-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnagstler%2Fdeepseek-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnagstler%2Fdeepseek-ruby/lists"}