Some checks are pending
CI — CoM Config Validation / Validate JSON Configs (push) Waiting to run
CI — CoM Config Validation / Validate YAML Configs (push) Waiting to run
CI — CoM Config Validation / Lint Shell Scripts (push) Waiting to run
CI — CoM Config Validation / Secret Detection (push) Waiting to run
CI — CoM Config Validation / Lint Markdown (push) Waiting to run
CI — CoM Config Validation / Validate CODEOWNERS (push) Waiting to run
Public, sanitized mirror of an AI orchestration command center: agents, skills, MCP servers, slash-command workflows. All infrastructure identifiers, hostnames, mesh IPs/subnets, repo paths, maintainer identity, and hardware fleet specifics scrubbed to <placeholders>; session debug logs and host-specific memory removed. No live credentials. Verified clean by automated leak sweep. See SANITIZATION.md. churchofmalware.org . authorized research only
1.8 KiB
1.8 KiB
Claude API — Ruby
Note: The Ruby SDK supports the Claude API. A tool runner is available in beta via
client.beta.messages.tool_runner(). Agent SDK is not yet available for Ruby.
Installation
gem install anthropic
Client Initialization
require "anthropic"
# Default (uses ANTHROPIC_API_KEY env var)
client = Anthropic::Client.new
# Explicit API key
client = Anthropic::Client.new(api_key: "your-api-key")
Basic Message Request
message = client.messages.create(
model: :"claude-opus-4-6",
max_tokens: 1024,
messages: [
{ role: "user", content: "What is the capital of France?" }
]
)
puts message.content.first.text
Streaming
stream = client.messages.stream(
model: :"claude-opus-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Write a haiku" }]
)
stream.text.each { |text| print(text) }
Tool Use
The Ruby SDK supports tool use via raw JSON schema definitions and also provides a beta tool runner for automatic tool execution.
Tool Runner (Beta)
class GetWeatherInput < Anthropic::BaseModel
required :location, String, doc: "City and state, e.g. San Francisco, CA"
end
class GetWeather < Anthropic::BaseTool
doc "Get the current weather for a location"
input_schema GetWeatherInput
def call(input)
"The weather in #{input.location} is sunny and 72°F."
end
end
client.beta.messages.tool_runner(
model: :"claude-opus-4-6",
max_tokens: 1024,
tools: [GetWeather.new],
messages: [{ role: "user", content: "What's the weather in San Francisco?" }]
).each_message do |message|
puts message.content
end
Manual Loop
See the shared tool use concepts for the tool definition format and agentic loop pattern.