Skip to content

Conversation

@ruudandriessen
Copy link
Contributor

@ruudandriessen ruudandriessen commented Jan 23, 2026

🎯 Changes

Allows passing in properties into openAI configuration like dangerouslyAllowBrowser.
Resolved the discussion here #197

Note: may want to consider if we want to expose all options all at once or limit to a smaller subset

✅ Checklist

  • I have followed the steps in the Contributing guide.
    --> contribution guidelines are no longer part of the repo?
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • New Features

    • OpenAI client accepts additional configuration options for more flexible initialization.
    • New exported model type names (chat, image, video, TTS, transcription) available for consumers.
  • Refactor

    • Model and client types reorganized and re-exported from a centralized module for clearer type usage across the package.
  • Chores

    • Added a changeset entry documenting the minor version bump.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

Model name unions moved into model-meta; OpenAI client config and helpers relocated to utils/client; utils/index re-exports removed; adapters updated to import model types and client utilities from new locations; index exports extended to include new model and client types. No runtime behavior changes.

Changes

Cohort / File(s) Summary
Changeset entry
\.changeset/olive-wolves-love\.md
New changeset bump for @tanstack/ai-openai documenting expanded client configuration options.
Client utils
packages/typescript/ai-openai/src/utils/client.ts, packages/typescript/ai-openai/src/utils/index.ts
OpenAIClientConfig now extends ClientOptions from openai; createOpenAIClient forwards full config to the SDK. utils/index.ts no longer re-exports client and schema-converter symbols.
Model metadata & public exports
packages/typescript/ai-openai/src/model-meta.ts, packages/typescript/ai-openai/src/index.ts
Added exported union types: OpenAIChatModel, OpenAIImageModel, OpenAIVideoModel, OpenAITTSModel, OpenAITranscriptionModel. Index now exports these and OpenAIClientConfig from ./utils/client.
Adapters — types/imports updated
packages/typescript/ai-openai/src/adapters/*
.../adapters/image.ts, .../adapters/summarize.ts, .../adapters/text.ts, .../adapters/transcription.ts, .../adapters/tts.ts, .../adapters/video.ts
Removed in-file model type aliases; adapters now import model types from ../model-meta. Import paths updated to use ../utils/client for OpenAIClientConfig, createOpenAIClient, and getOpenAIApiKeyFromEnv. Generic constraints updated (e.g., adapters now use OpenAIChatModel).

Sequence Diagram(s)

(omitted — changes are type/import refactors without new multi-component control flow)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • AlemTuzlak

Poem

🐰
I hopped through types and tidy imports bright,
Moved model names to meta, snug and right,
Client options stretched to carry more,
Adapters fetch types from a shared store,
A small hop forward — code feels light. 🌷

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: allowing all OpenAI configuration options to be passed through, which aligns with the refactoring shown across multiple adapter files.
Description check ✅ Passed The PR description addresses the key motivation and references the related discussion, but several checklist items are incomplete or marked as not applicable, and the description lacks detail about the technical approach.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ruudandriessen ruudandriessen changed the title feat: allow passing all open ai configuration options feat(ai-openai): allow passing all open ai configuration options Jan 23, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.changeset/olive-wolves-love.md:
- Line 5: Update the changeset copy that currently reads "allows additional
configuration options when creating an openAI client" to use the correct brand
casing "OpenAI" (i.e., change "openAI" → "OpenAI"), and scan the same .changeset
entry for any other occurrences of "openAI" to correct them for consistency.

In `@packages/typescript/ai-openai/src/utils/client.ts`:
- Around line 2-6: OpenAIClientConfig currently forces apiKey as required which
conflicts with openai's ClientOptions where apiKey is optional; change
OpenAIClientConfig to make apiKey optional (apiKey?: string) so it extends
ClientOptions' fallback behavior, or alternatively document why a required
apiKey is intentional—update the OpenAIClientConfig interface declaration
(symbol: OpenAIClientConfig) and ensure it aligns with ClientOptions from the
openai SDK (symbol: ClientOptions) so callers can rely on
process.env.OPENAI_API_KEY when not supplying a key.

'@tanstack/ai-openai': minor
---

allows additional configuration options when creating an openAI client
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Capitalize “OpenAI” in the changeset text.
Minor copy edit for brand casing.

✏️ Suggested fix
-allows additional configuration options when creating an openAI client
+allows additional configuration options when creating an OpenAI client
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
allows additional configuration options when creating an openAI client
allows additional configuration options when creating an OpenAI client
🤖 Prompt for AI Agents
In @.changeset/olive-wolves-love.md at line 5, Update the changeset copy that
currently reads "allows additional configuration options when creating an openAI
client" to use the correct brand casing "OpenAI" (i.e., change "openAI" →
"OpenAI"), and scan the same .changeset entry for any other occurrences of
"openAI" to correct them for consistency.

Comment on lines 2 to 6
import type { ClientOptions } from 'openai';

export interface OpenAIClientConfig {
apiKey: string
organization?: string
baseURL?: string
export interface OpenAIClientConfig extends ClientOptions {
apiKey: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -path "*/packages/typescript/ai-openai/package.json" -o -path "*/packages/typescript/ai-openai/**/package.json" | head -5

Repository: TanStack/ai

Length of output: 155


🏁 Script executed:

cat packages/typescript/ai-openai/package.json | grep -A 5 -B 5 "openai"

Repository: TanStack/ai

Length of output: 743


🌐 Web query:

OpenAI JavaScript SDK ClientOptions interface apiKey required github.com/openai/openai-node

💡 Result:

In openai/openai-node, ClientOptions.apiKey is not required in the TypeScript type—it’s declared as optional (apiKey?: string). [1]

However, the SDK still needs an API key at runtime: if you don’t pass apiKey, it will use process.env.OPENAI_API_KEY (so you can omit apiKey only if that env var is set). [2]

Sources: [1] [2]


Remove apiKey requirement from OpenAIClientConfig to match SDK flexibility.

The OpenAI SDK v6.9.1+ declares ClientOptions.apiKey as optional (apiKey?: string), allowing the SDK to fall back to process.env.OPENAI_API_KEY if the key is not explicitly passed. Making apiKey: string required in OpenAIClientConfig adds an unnecessary constraint and prevents developers from leveraging the SDK's environment variable fallback. Either make apiKey optional in the interface or document why this stricter requirement is intentional for your use case.

🤖 Prompt for AI Agents
In `@packages/typescript/ai-openai/src/utils/client.ts` around lines 2 - 6,
OpenAIClientConfig currently forces apiKey as required which conflicts with
openai's ClientOptions where apiKey is optional; change OpenAIClientConfig to
make apiKey optional (apiKey?: string) so it extends ClientOptions' fallback
behavior, or alternatively document why a required apiKey is intentional—update
the OpenAIClientConfig interface declaration (symbol: OpenAIClientConfig) and
ensure it aligns with ClientOptions from the openai SDK (symbol: ClientOptions)
so callers can rely on process.env.OPENAI_API_KEY when not supplying a key.

@nx-cloud
Copy link

nx-cloud bot commented Jan 23, 2026

View your CI Pipeline Execution ↗ for commit b9d43a0

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 6s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 37s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-23 14:49:59 UTC

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/typescript/ai-openai/src/adapters/summarize.ts`:
- Around line 4-10: You removed the backwards-compatible type alias
OpenAISummarizeModel by constraining generics to OpenAIChatModel; restore a
compatibility export by reintroducing a deprecated alias such as "export type
OpenAISummarizeModel = OpenAIChatModel" (add a JSDoc `@deprecated` note) near the
imports or the top of summarize.ts and replicate the same alias in the other
modules where the alias was removed so existing consumer imports keep working
(look for places referencing OpenAIChatModel generics around the summarize
adapter and the other spots mentioned).

Copy link
Contributor

@AlemTuzlak AlemTuzlak left a comment

Choose a reason for hiding this comment

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

Thank you for this!

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 23, 2026

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@245

@tanstack/ai-anthropic

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@245

@tanstack/ai-client

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@245

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@245

@tanstack/ai-gemini

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@245

@tanstack/ai-grok

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@245

@tanstack/ai-ollama

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@245

@tanstack/ai-openai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@245

@tanstack/ai-openrouter

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openrouter@245

@tanstack/ai-preact

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@245

@tanstack/ai-react

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@245

@tanstack/ai-react-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@245

@tanstack/ai-solid

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@245

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@245

@tanstack/ai-svelte

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@245

@tanstack/ai-vue

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@245

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue-ui@245

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/preact-ai-devtools@245

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@245

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@245

commit: b9d43a0

@AlemTuzlak AlemTuzlak merged commit 356df1a into TanStack:main Jan 23, 2026
6 checks passed
@github-actions github-actions bot mentioned this pull request Jan 23, 2026
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.

2 participants