@kortyx/google
v0.6.11
Published
Google Gemini provider integration for Kortyx.
Maintainers
Readme
@kortyx/google
Google Gemini provider integration for Kortyx.
Install
pnpm add @kortyx/googlenpm install @kortyx/googleBasic usage
import { google } from "@kortyx/google";
import { useReason } from "kortyx";
export const answerNode = async ({ input }: { input: unknown }) => {
const result = await useReason({
id: "answer",
model: google("gemini-2.5-flash"),
input: String(input ?? ""),
stream: true,
emit: true,
});
return {
data: { text: result.text },
};
};The default google export reads one of these environment variables on first use:
GOOGLE_API_KEYGEMINI_API_KEYGOOGLE_GENERATIVE_AI_API_KEYKORTYX_GOOGLE_API_KEYKORTYX_GEMINI_API_KEY
If you want an app-local barrel, re-export it from a shared file:
// src/lib/providers.ts
export { google } from "@kortyx/google";Then import from that file where you use it.
Re-exporting
google("...")in that file, useimport { google } from "@kortyx/google".
Advanced usage
Use createGoogleGenerativeAI(...) when you want explicit app-owned setup or custom settings:
import { createGoogleGenerativeAI } from "@kortyx/google";
export const google = createGoogleGenerativeAI({
apiKey: process.env.GOOGLE_API_KEY,
});Reasoning, tools, and structured output
Model IDs accept arbitrary non-empty strings; MODELS supplies autocomplete suggestions. useReason preserves thought signatures and original function-call IDs across tool rounds and approval resumes. Thought summaries are kept separate from final text and JSON.
Compatible outputSchema calls use native JSON Schema enforcement. Tool schemas retain references and property names. Gemini 3 models receive reasoning.effort as a thinking level; Gemini 2.5 maps minimal/low/medium/high to budgets of 512/1,024/8,192/24,576 tokens, with a compatibility warning. Use reasoning.maxTokens for a specific budget, or providerOptions.google.thinkingConfig for native controls. Do not supply both generic effort and budget.
Behavior change: rejected reasoning settings now fail explicitly; Kortyx no longer retries without effort. none disables thinking on compatible Gemini 2.5 Flash models and fails on models that cannot disable thinking. No model is substituted automatically.
When combining tools with JSON output, useReason keeps output constraints off tool-selection turns. Gemini 2.x rejects the combined request, and live Gemini 3 generateContent tests repeatedly selected a tool instead of returning the final JSON. With only outputSchema, Kortyx reuses an answer that passes local validation and reports a compatibility warning. Otherwise it makes a separate JSON-only call, using the same model and reasoning and counting toward existing limits. An explicit responseFormat.schema always requires provider-enforced finalization. Direct Gemini 2.x requests combining tools and JSON fail with guidance.
See Google thought signatures and structured output.
Documentation
License
Apache-2.0. See LICENSE.
