Skip to content

[upstream PR 933] f<!-- -->ix: prefer OPENAI_EMBEDDING_API_KEY over OPENAI_API_KEY for embeddings #381

@wbugitlab1

Description

@wbugitlab1

Source: Source pull request number: 933 in rohitg00/agentmemory (URL omitted to avoid GitHub cross-reference)
Title: fix: prefer OPENAI_EMBEDDING_API_KEY over OPENAI_API_KEY for embeddings
Author: w1ndcn
State: open
Draft: no
Merged: no
Head: w1ndcn/agentmemory:fix/863-embedding-key-priority @ 0908d6e
Base: main @ f6f9e3c
Labels: (none)
Changed files: 0
Commits: 0
Created: 2026-06-14T09:00:13Z
Updated: 2026-06-14T09:02:47Z
Closed: (not closed)
Merged at: (not merged)

Original PR body:

Fixes #863

Summary

When EMBEDDING_PROVIDER=openai, the factory passed OPENAI_API_KEY directly to OpenAIEmbeddingProvider, bypassing the provider's internal fallback chain that checks OPENAI_EMBEDDING_API_KEY first.

Fix

Remove the explicit argument from the factory call. The provider already resolves keys with the correct priority:

  1. constructor argument (if provided)
  2. OPENAI_EMBEDDING_API_KEY
  3. OPENAI_API_KEY

Before-After

// Before
new OpenAIEmbeddingProvider(getEnvVar("OPENAI_API_KEY")!)
// After
new OpenAIEmbeddingProvider()

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Refactor**
  * Improved internal initialization of the OpenAI embedding provider.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
<!-- upstream-pr-managed:end -->

<!-- fork-pr-workflow:start -->
Local branch: review/issue-863-pr-933-embedding-api-key
Fork PR: not created
Fork decision: adapted for this fork according to local review documentation. Local decision evidence: adjusted import.
Verification: see local task record docs/todos/2026-06-15-issue-863-pr-933-embedding-api-key/todo.md for recorded checks and evidence.
Notes: tracker updated from local review documentation on 2026-06-16; issue remains open until separately closed.
<!-- fork-pr-workflow:end -->

Metadata

Metadata

Assignees

No one assigned

    Labels

    decision-modifiedFork adopted a modified versionupstream-openUpstream pull request is openupstream-prTracks an upstream pull request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions