Skip to content

fix(providers): configure RubyLLM API key from ENV before chatting - #2

Merged
mhenrixon merged 1 commit into
mainfrom
fix/configure-ruby-llm-from-env
Jul 13, 2026
Merged

fix(providers): configure RubyLLM API key from ENV before chatting#2
mhenrixon merged 1 commit into
mainfrom
fix/configure-ruby-llm-from-env

Conversation

@mhenrixon

Copy link
Copy Markdown
Collaborator

Summary

  • lingo translate / lingo quality --ai always failed standalone with Missing configuration for Anthropic: anthropic_api_key even when ANTHROPIC_API_KEY was set — RubyLLM's config does not default API keys from ENV (only log settings), and nothing in locallingo called RubyLLM.configure.
  • Providers::RubyLLM#chat now fills <provider>_api_key from the matching CREDENTIAL_ENV var when the config value is blank. A key configured by the host app (e.g. a Rails initializer) always wins.

Found while migrating the zazu app off its bin/translate script (getzazu/app#2836) — the smoke test of the write path failed on 0.2.1.

Test plan

  • New spec/locallingo/providers/ruby_llm_spec.rb: sets key from ENV, doesn't clobber an explicit key, no-ops when ENV is absent
  • Full suite: 56 examples, 0 failures
  • Verified end-to-end in the zazu app: bin/lingo translate fills fr/af via Anthropic with only ANTHROPIC_API_KEY in ENV

RubyLLM does not read provider API keys from ENV on its own — its config
only defaults log settings from ENV. In a Rails app an initializer calls
RubyLLM.configure, but the lingo CLI runs standalone, so translate/quality
always failed with 'Missing configuration for <provider>' even when the
documented ENV var (e.g. ANTHROPIC_API_KEY) was set.

Providers::RubyLLM#chat now fills <provider>_api_key from the matching
CREDENTIAL_ENV var when the config value is blank. An explicitly
configured key (host-app initializer) always wins.
@mhenrixon mhenrixon self-assigned this Jul 13, 2026
@mhenrixon
mhenrixon merged commit 74f21a2 into main Jul 13, 2026
3 checks passed
@mhenrixon
mhenrixon deleted the fix/configure-ruby-llm-from-env branch July 13, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant