HINOW Ruby SDK
Official Ruby SDK for the HINOW AI Inference API.
Installation
gem install hinow-aiOr add to your Gemfile:
gem 'hinow-ai'Quick Start
require 'hinow'
client = Hinow::Client.new(api_key: 'hi_your_api_key')
# Chat completion
response = client.chat.completions.create(
model: 'deepseek-ai/deepseek-v3.2',
messages: [{ role: 'user', content: 'Hello!' }],
temperature: 0.7
)
puts response['choices'][0]['message']['content']Configuration
Global Configuration
Hinow.configure do |config|
config.api_key = 'hi_your_api_key'
config.base_url = 'https://api.hinow.ai'
config.timeout = 120
end
# Then use the global client
response = Hinow.client.chat.completions.create(...)Environment Variable
export HINOW_API_KEY=hi_your_api_keyclient = Hinow::Client.new # Uses HINOW_API_KEYFeatures
Chat Completions
response = client.chat.completions.create(
model: 'deepseek-ai/deepseek-v3.2',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the capital of France?' }
],
temperature: 0.7,
max_tokens: 1000
)Function Calling
response = client.chat.completions.create(
model: 'deepseek-ai/deepseek-v3.2',
messages: [{ role: 'user', content: "What's the weather in Paris?" }],
tools: [{
type: 'function',
function: {
name: 'get_weather',
description: 'Get the current weather in a city',
parameters: {
type: 'object',
properties: {
location: { type: 'string', description: 'City name' }
},
required: ['location']
}
}
}]
)
if response['choices'][0]['message']['tool_calls']
response['choices'][0]['message']['tool_calls'].each do |tool_call|
puts "Function: #{tool_call['function']['name']}"
puts "Arguments: #{tool_call['function']['arguments']}"
end
endImage Generation
response = client.images.generate(
model: 'dall-e-3',
prompt: 'A beautiful sunset over mountains',
size: '1024x1024',
quality: 'hd'
)
response['data']['urls'].each { |url| puts "Image URL: #{url}" }Text to Speech
response = client.audio.speech(
model: 'tts-1',
input: 'Hello, how are you today?',
voice: 'alloy',
speed: 1.0
)
response['data']['urls'].each { |url| puts "Audio URL: #{url}" }Speech to Text
response = client.audio.transcribe(
model: 'whisper-1',
file: '/path/to/audio.mp3',
language: 'en'
)
puts "Transcription: #{response['data']['text']}"Video Generation
response = client.video.generate(
model: 'video-model',
prompt: 'A cat playing piano',
duration: 5,
resolution: '1080p'
)
response['data']['urls'].each { |url| puts "Video URL: #{url}" }Embeddings
response = client.embeddings.create(
model: 'text-embedding-ada-002',
input: 'Hello world'
)
embedding = response['data'][0]['embedding']
puts "Embedding dimensions: #{embedding.length}"List Models
response = client.models.list
response['data'].each { |model| puts "Model: #{model['id']}" }Check Balance
balance = client.get_balance
puts "Balance: #{balance['data']['balance']} #{balance['data']['currency']}"Error Handling
begin
response = client.chat.completions.create(...)
rescue Hinow::Error => e
puts "Error: #{e.message}"
puts "Status code: #{e.status_code}"
endLinks
License
MIT License