FastDeepseek
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
endList the models available to your API key:
models = client.models
models.fetch("data").each do |model|
puts model.fetch("id")
endThe 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}"
endContributing
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.