-
-
Notifications
You must be signed in to change notification settings - Fork 87
Description
TanStack AI version
@tanstack/ai v^0.0.1
Framework/Library version
React v18.2.0
Describe the bug and the steps to reproduce it
Bug Report: Unable to Pass API Key Directly to Gemini Adapter
Description
When attempting to pass the apiKey directly to the gemini() adapter function as shown in the documentation, TypeScript throws an error indicating that apiKey is not a valid property.
Error Message
Object literal may only specify known properties, and 'apiKey' does not exist in type 'Omit<GeminiAdapterConfig, "apiKey">'.(2353)
(property) apiKey: string
Code Example
import { chat } from '@tanstack/ai';
import { gemini } from '@tanstack/ai-gemini';
import { NextResponse } from 'next/server';
const adapter = gemini({
apiKey: process.env.GEMINI_API_KEY!, // Error occurs here
});
export async function POST() {
return NextResponse.json({ message: 'success' }, { status: 200 });
}Expected Behavior
According to the documentation, I should be able to pass the apiKey directly to the gemini() adapter configuration object.
Actual Behavior
TypeScript reports that apiKey does not exist in the type definition, specifically showing it's excluded via Omit<GeminiAdapterConfig, "apiKey">.
Environment
- Package:
@tanstack/ai-gemini
Additional Context
The type definition appears to explicitly exclude apiKey from the configuration object using TypeScript's Omit utility type, which contradicts the documented usage pattern.
Possible Solutions
- Update the type definitions to include
apiKeyas a valid property - Update the documentation to reflect the correct way to pass API credentials
- Clarify if there's an alternative authentication method that should be used instead
Request
Could you please clarify:
- Is this a bug in the type definitions?
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://stackblitz.com/edit/nextjs-qytakwmv?file=app%2Fapi%2Fchat%2Froute.ts
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Maybe, I'll investigate and start debugging
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.