Skip to content

fix: use config API key for embeddings#182

Open
24601 wants to merge 1 commit intogarrytan:masterfrom
24601:fix/embedding-config-api-key
Open

fix: use config API key for embeddings#182
24601 wants to merge 1 commit intogarrytan:masterfrom
24601:fix/embedding-config-api-key

Conversation

@24601
Copy link
Copy Markdown

@24601 24601 commented Apr 17, 2026

Summary

  • resolve the embedding client API key from either OPENAI_API_KEY or ~/.gbrain/config.json
  • rebuild the OpenAI client when the resolved key changes so tests can cover env/config precedence cleanly
  • add a focused regression test for config-backed embedding credentials

Why this matters

gbrain embed --stale currently assumes OPENAI_API_KEY is present in the shell environment. In real local installs, gbrain init persists openai_api_key in ~/.gbrain/config.json, and other commands already rely on config loading. That leaves embeddings in a broken state for users whose shell env is clean but whose saved config is valid.

Test plan

  • bun test test/embedding-config.test.ts test/embed.test.ts
  • bun test
  • bun run test:e2e (blocked locally: no reachable test Postgres at localhost:5434 in this environment, ideally CI checks will spin up/set up an env appropriate for this)

@24601 24601 marked this pull request as ready for review April 17, 2026 15:15
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