AI Search API in Ruby.

AI Search API needs nothing but Ruby’s standard net/http. Capture the answer a real user sees on ChatGPT, Perplexity, Copilot or Google AI and read the canonical Envelope back.

Bearer-authenticate, POST to /v1/search, and either block for the Envelope (sync) or take the 202 and poll. Charged only on a successful capture; 500 free credits to start.

search.rb, one surface, inline Envelope
require "net/http"
require "json"

uri = URI("https://api.aisearchapi.dev/v1/search?mode=sync")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['AISEARCH_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = { query: "best crm for startups", surfaces: ["chatgpt"] }.to_json

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(req)
end

data = JSON.parse(res.body)
puts data.dig("children", 0, "answer", "text")

Fan out across surfaces.

Add more surfaces or regions and the call goes async: a 202 with a jobId, one child capture per (surface × region). Poll /v1/jobs/:id or attach a signed webhook.

The full submit → poll → read round-trip and a webhook receiver are in the docs.

Submit then poll GET /v1/jobs/:id
# A multi-surface / multi-region POST returns 202 + { "jobId" => "..." }.
# Poll until the job status is terminal:
#
#   loop do
#     sleep 2
#     j = JSON.parse(get_with_bearer("#{BASE}/v1/jobs/#{job_id}"))
#     break if %w[completed partial failed canceled expired].include?(j["job"]["status"])
#   end
#
# Each (surface × region) is one child capture, counted once.

Ruby + AI Search API, asked precisely.

Is there a Ruby gem?

Not yet. net/http and json from the standard library cover the whole contract; the snippets here are the full integration.

How do I fan out across surfaces in Ruby?

Pass several surfaces (and regions) in the POST body. The response is a 202 with a jobId; poll GET /v1/jobs/:id until the status is terminal, or receive a signed webhook per child.

Ship it in Ruby today.

Grab a key, spend 500 free credits on a real fan-out, and read the Envelope back. Charged only on success.

other languages:PythonNode.jsGoPHP