-
|
I plan to use 1/ I need to set the header Thank you for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
I monkeypatched RubyLLM to use it with Cloudflare AI Gateway with RubyLLM. I also use their Bring your own keys (BYOK) feature to manage API keys so I only need to set module RubyLLM
module Providers
class OpenAI < Provider
def headers
{
"cf-aig-authorization" => "Bearer #{cloudflare_api_token_from_somewhere}",
}
end
class << self
def configuration_requirements
[]
end
end
end
end
end
RubyLLM.configure do |config|
config.openai_api_base = "https://gateway.ai.cloudflare.com/v1/#{account_id}/#{gateway_id}/compat"
# For Cloudflare AI Gateway to work. Reference: https://github.com/crmne/ruby_llm/pull/381
config.openai_use_system_role = true
end |
Beta Was this translation helpful? Give feedback.
-
|
you can use |
Beta Was this translation helpful? Give feedback.
you can use
.with_headersto remove the need for the monkey patch!