feat(ai-openai): accept token-provider apiKey on openaiCompatible - #1322
feat(ai-openai): accept token-provider apiKey on openaiCompatible#1322harshlocham wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe compatible OpenAI configuration types now accept OpenAI SDK token-provider functions for ChangesOpenAI-compatible API key typing
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to The compatible OpenAI configuration update is ready to merge with no identified current risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
View your CI Pipeline Execution ↗ for commit 020c735
☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-claude-code
@tanstack/ai-client
@tanstack/ai-cloudflare
@tanstack/ai-code-mode
@tanstack/ai-code-mode-snippets
@tanstack/ai-codex
@tanstack/ai-cohere
@tanstack/ai-compaction
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-grok-build
@tanstack/ai-groq
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-daytona
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-isolate-quickjs-bun
@tanstack/ai-llmgateway
@tanstack/ai-lovable
@tanstack/ai-mcp
@tanstack/ai-memory
@tanstack/ai-mistral
@tanstack/ai-octane
@tanstack/ai-ollama
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-remix
@tanstack/ai-sandbox
@tanstack/ai-sandbox-cloudflare
@tanstack/ai-sandbox-daytona
@tanstack/ai-sandbox-docker
@tanstack/ai-sandbox-local-process
@tanstack/ai-sandbox-sprites
@tanstack/ai-sandbox-upstash-box
@tanstack/ai-sandbox-vercel
@tanstack/ai-skills
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-utils
@tanstack/ai-vercel-gateway
@tanstack/ai-vertex
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
@tanstack/svelte-ai-devtools
commit: |
Added support for `openaiCompatible` and `openaiCompatibleText` to accept a token-provider function for the `apiKey`, allowing for better type-checking with Azure Entra and rotating keys. Updated type definitions to use `NonNullable` for `apiKey` in configuration interfaces. Added tests to verify the new functionality.
020c735 to
8738246
Compare
openaiCompatibleandopenaiCompatibleTextnow accept an OpenAI SDK token-providerapiKey(() => Promise<string>). String keys still work. Azure EntragetBearerTokenProvidertype-checks.Changes
OpenAICompatibleConfigandOpenAICompatibleTextConfigtypedapiKeyasstring. The OpenAI client already acceptsstring | (() => Promise<string>). This PR widens the public type toNonNullable<ClientOptions['apiKey']>so the two match.Docs are unchanged. Existing string samples stay valid. An Azure Entra recipe is a follow-up.
Checklist
pnpm run test:pr, or these tests do not apply to this pull request.docs/for this change, or this change is not user-facing.pnpm changeset), or this PR does not change a published package.Release Impact
Testing
Commands run
pnpm --filter @tanstack/ai-openai test:lib— 261 passedpnpm --filter @tanstack/ai-openai test:types— passedpnpm test:prwas not run. This is a type-only change in@tanstack/ai-openai.Manual test
openaiCompatible.apiKey: async () => 'token'. Confirm TypeScript accepts it.apiKey: 'sk-test'. Confirm TypeScript still accepts it.apiKey. Confirm TypeScript errors.How this PR makes testing easy
packages/ai-openai/tests/compatible-types.test.tscalls both factories with a token-provider function.tscincludes that file.Public API change
Before
After
Risk / rollback
Low. Types only. Revert the PR to restore
apiKey: string.Summary by CodeRabbit