
Security News
pnpm 11.5 Adds Support for Recognizing npm Staged Publishes
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.
deepseek-client
Advanced tools
A 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.
Add this line to your application's Gemfile:
gem 'deepseek'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install deepseek
require 'deepseek'
# Initialize client
client = Deepseek::Client.new(api_key: 'your-api-key')
# Make a chat completion request
response = client.chat(
messages: [
{ role: 'user', content: 'What is artificial intelligence?' }
],
model: 'deepseek-chat'
)
puts response['choices'][0]['message']['content']
client = Deepseek::Client.new(
api_key: 'your-api-key',
timeout: 60, # Custom timeout in seconds
max_retries: 3 # Number of retries for failed requests
)
The SDK supports configuration through environment variables:
DEEPSEEK_API_KEY=your-api-key
DEEPSEEK_API_BASE_URL=https://api.deepseek.com # Optional
DEEPSEEK_TIMEOUT=30 # Optional
DEEPSEEK_MAX_RETRIES=3 # Optional
Make a chat completion request.
Parameters:
messages (Array, required): Array of message objectsmodel (String, optional): Model to use, defaults to 'deepseek-chat'temperature (Float, optional): Sampling temperatureResponse Format:
{
"choices" => [{
"message" => {
"content" => "Hello! How can I help you today?",
"role" => "assistant"
},
"finish_reason" => "stop"
}],
"created" => 1677649420,
"id" => "chatcmpl-123",
"model" => "deepseek-chat",
"usage" => {
"completion_tokens" => 17,
"prompt_tokens" => 57,
"total_tokens" => 74
}
}
response = client.chat(
messages: [
{ role: 'system', content: 'You are a friendly AI assistant.' },
{ role: 'user', content: 'Hello!' }
],
temperature: 0.7,
model: 'deepseek-chat'
)
conversation = [
{ role: 'user', content: 'What is your favorite color?' },
{ role: 'assistant', content: 'I don\'t have personal preferences, but I can discuss colors!' },
{ role: 'user', content: 'Tell me about blue.' }
]
response = client.chat(
messages: conversation,
temperature: 0.8
)
client = Deepseek::Client.new(
api_key: ENV['DEEPSEEK_API_KEY'],
timeout: 60, # Custom timeout
max_retries: 5, # Custom retry limit
api_base_url: 'https://custom.deepseek.api.com' # Custom API URL
)
The SDK provides comprehensive error handling for various scenarios:
begin
response = client.chat(messages: messages)
rescue Deepseek::AuthenticationError => e
# Handle authentication errors (e.g., invalid API key)
puts "Authentication error: #{e.message}"
rescue Deepseek::RateLimitError => e
# Handle rate limit errors
puts "Rate limit exceeded: #{e.message}"
rescue Deepseek::InvalidRequestError => e
# Handle invalid request errors
puts "Invalid request: #{e.message}"
rescue Deepseek::ServiceUnavailableError => e
# Handle API service errors
puts "Service error: #{e.message}"
rescue Deepseek::APIError => e
# Handle other API errors
puts "API error: #{e.message}"
end
The SDK automatically handles retries with exponential backoff for failed requests:
After 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.
bundle exec rake spec
bin/console
Bug 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.
For detailed contribution guidelines, please see our Contributing Guide.
If you discover any issues or have questions, please create an issue on GitHub.
The gem is available as open source under the terms of the MIT License. See LICENSE.txt for details.
Everyone interacting in the Deepseek project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that deepseek-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.