0.0
The project is in a healthy, maintained state
Official Ruby client for interacting with Deepseek's API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 2.7
~> 2.6
 Project Readme

Deepseek Ruby Client

Gem Version

Official Ruby client for the Deepseek API. This library provides convenient access to the Deepseek API from applications written in Ruby.

Installation

Add this line to your application's Gemfile:

gem 'deepseek-ruby'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install deepseek-ruby

Usage

First, configure the gem with your API key:

Deepseek.configure do |config|
  config.api_key = ENV['DEEPSEEK_API_KEY']
  # Optional configurations:
  # config.base_url = 'https://api.deepseek.com/v1'
  # config.http_adapter = Faraday.default_adapter
end

Basic Example

client = Deepseek::Client.new

begin
  response = client.chat_completions(
    model: "deepseek-chat",
    messages: [
      { role: "user", content: "Hello!" }
    ]
  )

  puts response.choices.first["message"]["content"]
rescue Deepseek::ApiError => e
  puts "Error #{e.status}: #{e.body}"
end

Documentation

Required Parameters

The chat_completions method requires:

  • model: The ID of the model to use
  • messages: An array of message objects with role and content

Response Object

The response object provides:

  • choices: Array of generated responses
  • usage: Hash with token usage statistics

Error Handling

The client raises Deepseek::ApiError for API errors, containing:

  • status: HTTP status code
  • body: Response body

Contributing

Bug reports and pull requests are welcome on GitHub at github.com/seifoueddine/deepseek-ruby.

License

The gem is available as open source under the terms of the MIT License. [file content end]

This README.md file includes the provided content and maintains the structure and additional sections for documentation, development, contributing, and licensing. It also includes the badge for the gem version and links to the repository.