0.0
The project is in a healthy, maintained state
Provides an easy-to-use interface for interacting with DeepSeek API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 2.0
~> 2.8
 Project Readme

FastDeepseek

Gem Version

A Ruby client for the hosted DeepSeek API.

Ruby 3.2 and newer are supported. Ruby 2.x is not supported.

Installation

Add gem 'fast-deepseek' to your application's Gemfile and run bundle install, or install it directly with gem install fast-deepseek.

Usage

Create a client with a DeepSeek API key from the DeepSeek Platform:

require "fast_deepseek"

client = FastDeepseek::Client.new(api_key: ENV.fetch("DEEPSEEK_API_KEY"))
response = client.chat("Hello, how are you?", model: "deepseek-chat")

puts response["choices"].first["message"]["content"]

Stream response content as it arrives:

client.chat_stream("Tell me a story", model: "deepseek-chat") do |content|
  print content
end

List the models available to your API key:

models = client.models

models.fetch("data").each do |model|
  puts model.fetch("id")
end

The client uses https://api.deepseek.com by default and sends requests to DeepSeek's /chat/completions endpoint. A custom compatible endpoint can be provided with base_url.

client = FastDeepseek::Client.new(
  api_key: ENV.fetch("DEEPSEEK_API_KEY"),
  base_url: "https://api.deepseek.com"
)

Additional request options can be passed through options:

client.chat(
  "Explain recursion",
  model: "deepseek-chat",
  options: { temperature: 0.7, max_tokens: 200 }
)

Error Handling

The client raises FastDeepseek::Error for request failures, FastDeepseek::RateLimitError for HTTP 429 responses, and FastDeepseek::ServerError for HTTP 5xx responses.

begin
  client.chat("Hello!", model: "deepseek-chat")
rescue FastDeepseek::Error => e
  warn "API request failed: #{e.message}"
end

Contributing

Bug reports and pull requests are welcome at https://github.com/udaykadaboina/fast-deepseek.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting with the FastDeepseek project is expected to follow the code of conduct.