Moonborn — Developers
Ruby
The official Ruby SDK. Idiomatic, frozen-string compatible, ships within a week of every API release.
The Ruby SDK is moonborn on RubyGems. Generated from the canonical
OpenAPI spec; idiomatic Ruby (snake_case methods, keyword args,
returns plain hashes you can pattern-match on).
Install
gem install moonborn
# or in your Gemfile:
gem 'moonborn', '~> 1.0'First call
require 'moonborn'
client = Moonborn.new(api_key: ENV.fetch('MOONBORN_API_KEY'))
persona = client.personas.create_persona(
intent: 'A 34-year-old founder from Istanbul. Brilliant but restless.',
workspace_id: 'ws_...'
)
puts persona[:id], persona[:status]Chat
session = client.chat.create_session(persona_id: persona[:id])
reply = client.chat.send_message(
session_id: session[:id],
content: 'What drives you?'
)
puts reply[:content], reply[:drift_score]Streaming
client.chat.stream_message(session_id: session[:id], content: 'Tell me a quiet truth.') do |chunk|
case chunk[:type]
when 'token' then print chunk[:delta]
when 'completed' then puts "\ndrift: #{chunk[:drift_score]}"
end
endError handling
begin
client.personas.get_persona(id: 'persona_...')
rescue Moonborn::ApiError => e
case e.code
when 'rate_limited' then sleep(e.retry_after); retry
when 'not_found' then # ...
end
endAuto-retries on 5xx + 429 (configurable via retry_config:).
Tier
Every tier.