Skip to content

feat(js/plugins/compat-oai): allow passing api key at runtime instead of config time#3946

Merged
pavelgj merged 8 commits intomainfrom
pj/oai-runtime-key
Dec 16, 2025
Merged

feat(js/plugins/compat-oai): allow passing api key at runtime instead of config time#3946
pavelgj merged 8 commits intomainfrom
pj/oai-runtime-key

Conversation

@pavelgj
Copy link
Copy Markdown
Member

@pavelgj pavelgj commented Dec 16, 2025

const ai = genkit({
  plugins: [openAI({apiKey: false})],
});


await ai.generate({
  prompt: 'tell me why...',
  model: openAI.model('gpt-4o'),
  config: {
    apiKey: '...'
  }
});

Checklist (if applicable):

Copy link
Copy Markdown
Contributor

@ssbushi ssbushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of supporting per-request API keys?

Comment thread js/plugins/compat-oai/tests/compat_oai_test.ts
@pavelgj
Copy link
Copy Markdown
Member Author

pavelgj commented Dec 16, 2025

What is the point of supporting per-request API keys?

Folks build apps where user provides the API key. The key is dynamically fetched from a DB.

@pavelgj pavelgj requested a review from ssbushi December 16, 2025 13:15
Comment thread js/plugins/compat-oai/tests/compat_oai_test.ts Outdated
Copy link
Copy Markdown
Contributor

@ssbushi ssbushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, save for 1 small comment.

@pavelgj pavelgj merged commit 2c6539e into main Dec 16, 2025
5 checks passed
@pavelgj pavelgj deleted the pj/oai-runtime-key branch December 16, 2025 16:15
hugoaguirre pushed a commit that referenced this pull request Jan 16, 2026
@yesudeep yesudeep mentioned this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants