Skip to content

Fetch-Hive/ruby-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fetch_hive

Official Ruby SDK for Fetch Hive — invoke AI prompts, workflows, and agents from your application.

Gem Version

Installation

Add to your Gemfile:

gem "fetch_hive", "~> 0.2.4"

Then run:

bundle install

Or install directly:

gem install fetch_hive

Quick start

require "fetch_hive"

client = FetchHive::Client.new(api_key: ENV["FETCH_HIVE_API_KEY"])

Get your API key from the Fetch Hive dashboard.

Invoke a prompt

result = client.invoke_prompt(
  deployment: "my-prompt",
  inputs: { name: "Alice", topic: "machine learning" }
)
puts result["response"]

Invoke a prompt (streaming)

client.invoke_prompt_stream(deployment: "my-prompt", inputs: { name: "Alice" }) do |chunk|
  case chunk["type"]
  when "response" then print chunk["response"]
  when "usage"    then puts "\nUsage: #{chunk['usage']}"
  end
end

Invoke a workflow

run = client.invoke_workflow(
  deployment: "my-workflow",
  inputs: { customer_id: "42" }
)
puts run["status"], run["output"]

Invoke a workflow (async)

run = client.invoke_workflow(
  deployment: "my-workflow",
  inputs: { customer_id: "42" },
  async_mode: true,
  callback_url: "https://example.com/webhook"
)
puts "Queued: #{run['run_id']}"

Invoke an agent

reply = client.invoke_agent(
  agent: "my-agent",
  message: "What is the weather in London?"
)
puts reply["response"]

Invoke an agent (streaming)

client.invoke_agent_stream(
  agent: "my-agent",
  message: "What is the weather in London?",
  thread_id: "session-abc123"  # optional — persist conversation history
) do |chunk|
  case chunk["type"]
  when "response" then print chunk["response"]
  when "tool"     then puts "\nCalling tool: #{chunk['tool']}"
  when "usage"    then puts "\nUsage: #{chunk['usage']}"
  end
end

Multimodal (image) inputs

result = client.invoke_agent(
  agent: "vision-agent",
  message: "Describe this image",
  image_urls: ["https://example.com/photo.jpg"]
)
puts result["response"]

Authentication

Pass the API key to the constructor or set the environment variable:

export FETCH_HIVE_API_KEY=fhk_...
client = FetchHive::Client.new  # picks up FETCH_HIVE_API_KEY automatically

Configuration

Option Default Description
api_key ENV["FETCH_HIVE_API_KEY"] Bearer token from the Fetch Hive dashboard
base_url https://api.fetchhive.com/v1 Override the API base URL
timeout 120 Request timeout in seconds

Links

Version

0.2.4

License

MIT — see LICENSE.

About

Ruby SDK for the Fetch Hive platform.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages