← API Reference

Language Guide · Ruby

Manage AI Prompts in Ruby

No SDK required. One HTTP call.

Fetch versioned, variable-interpolated AI prompts from Ruby using the standard library. Works with Rails, Sinatra, and any Ruby application — no new gems required.

Code Example

One function. Any AI provider.

Fetch a versioned, interpolated prompt from PromptForge with a single HTTP call. The returned content string passes directly to your AI SDK — no transformation, no adapter, no extra library.

  1. 1Fetch a versioned prompt by ID with your variable values.
  2. 2Receive the fully rendered content string in the response.
  3. 3Pass it directly to your AI provider SDK as the system prompt.
promptforge.ruby
Ruby
require 'net/http'
require 'json'

def fetch_prompt(api_key:, prompt_id:, vars: {})
  uri       = URI("https://www.promptforge-app.com/api/v1/prompts/#{prompt_id}")
  uri.query = URI.encode_www_form({ _version: 'latest' }.merge(vars))

  request                  = Net::HTTP::Get.new(uri)
  request['Authorization'] = "Bearer #{api_key}"

  response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
    http.request(request)
  end

  JSON.parse(response.body)['content']
end

content = fetch_prompt(
  api_key:   ENV['PROMPTFORGE_API_KEY'],
  prompt_id: 'YOUR_PROMPT_ID',
  vars:      { role: 'developer', task: 'review code' },
)

# Pass content to any AI SDK

Why Ruby teams choose PromptForge

Designed for developers who want control without complexity.

Zero new gems

Net::HTTP and JSON are in the Ruby standard library. No Gemfile entry, no bundle install, no gem conflicts to worry about.

Rails-friendly by default

Wrap in a service object, call from an initializer, or memoize with Rails.cache.fetch. Fits every Rails architecture pattern without friction.

Cache per version for performance

Pin to a specific version number and cache the response indefinitely. When you publish a new prompt version, bump the pin to invalidate automatically.

Integrate in 4 steps

From zero to fetching your first versioned prompt in under 10 minutes. No framework setup, no SDK installation — just HTTP.

  1. 1

    Create a prompt with variables

    Open the dashboard, click New Prompt, and write your system prompt using {{variable}} placeholders for any dynamic values.

  2. 2

    Copy your prompt ID

    Your prompt ID appears in the URL bar when editing: /dashboard/prompts/YOUR_PROMPT_ID. The API Usage panel also shows it with pre-filled examples.

  3. 3

    Generate an API key

    Go to the API settings page and click Generate Key. Store it with dotenv or the Rails credentials system and read from ENV.

  4. 4

    Fetch with Net::HTTP

    Build a GET request with the Authorization header, start a TLS connection, and parse the response JSON. Pass the content string to your AI provider gem.

Teams building AI features in Ruby

Rails product teams use PromptForge to let non-engineers refine AI prompts without submitting PRs or waiting for deploy windows. The prompt change is live in production on the next request — no Capistrano, no Heroku slug compile, no waiting.

Start Free Trial
No SDK
required
1 call
to fetch any prompt
Instant
prompt updates
Any AI
provider supported

Start for free, upgrade anytime

No credit card required to get started. Paid plans include a 14-day free trial.

Developer Sandbox
Hobby Plan
$0/ forever
  • 1 Production Prompt
  • 1,000 API Requests/mo
  • Stable/Latest Channel Routing
  • No Credit Card Required
Launch Sandbox
Starter
14-day free trial
$9/month

No charge until your trial ends

  • 10k API requests/month
  • 5 prompt
  • Unlimited versions
  • Dynamic variables
  • Version pinning
  • API key management
Start 14-Day Free Trial
Most Popular
Pro
14-day free trial
$29/month

No charge until your trial ends

  • 100k API requests/month
  • 25 prompt
  • Unlimited versions
  • Dynamic variables
  • Version pinning
  • API key management
Start 14-Day Free Trial
Business
14-day free trial
$49/month

No charge until your trial ends

  • 500k API requests/month
  • 100 prompt
  • Unlimited versions
  • Dynamic variables
  • Version pinning
  • API key management
Start 14-Day Free Trial

Questions? Contact us