Google Generative AI Provider
Updated 19 days ago • May 3, 2026
@kortyx/google is the Google Gemini provider package for Kortyx.
It gives you two entry points:
google: a batteries-included default provider selectorcreateGoogleGenerativeAI(...): an explicit factory for custom setup
1. Install the package
2. What the package exports
What each export is for:
google: default provider selector for the fastest startcreateGoogleGenerativeAI(...): custom provider instance with explicit settingsMODELS: built-in Google model ids exposed by the packagePROVIDER_ID: the provider id string, currently"google"
3. Basic usage in the same file
If you want to use Google directly in the file where you call useReason(...), import google and call it there.
google is a provider selector, which means:
- it is callable:
google("gemini-2.5-flash") - it also exposes provider metadata:
google.id,google.models
Good to know:
google("gemini-2.5-flash")returns a model ref, not a live API client call. The actual provider-native model is resolved later when Kortyx executesuseReason(...).
4. Shared app bootstrap usage
If you want one shared import path across your app, re-export google from a bootstrap file such as src/lib/providers.ts.
Then import it from that file where you actually use it:
Good to know:
export { google } from "@kortyx/google"is only a re-export. It does not create a localgoogle("...")in that same file, import it normally.
5. Advanced usage with explicit settings
Use createGoogleGenerativeAI(...) when you want app-owned configuration instead of the default environment-based setup.
Use the factory when you need to:
- pass
apiKeyexplicitly - use a custom
baseUrl - provide a custom
fetch
6. Credentials and first-use behavior
The default google export resolves credentials on first use, not at import time.
Supported environment variables:
GOOGLE_API_KEYGEMINI_API_KEYGOOGLE_GENERATIVE_AI_API_KEYKORTYX_GOOGLE_API_KEYKORTYX_GEMINI_API_KEY
If none of them are set and you did not pass apiKey to createGoogleGenerativeAI(...), the provider throws a configuration error the first time a Google model is actually used.
7. Create model refs for workflow and node params
You can pass model refs through workflow or node params just like any other value.
You can also attach default model options to the ref itself:
Those become default options for later useReason(...) calls unless you override them at call time.
8. Use the model with useReason(...)
Good to know: Provider setup is not done on
createAgent(...). Model selection happens where you calluseReason(...)by passing a model ref.
9. Supported normalized call options
Google currently maps these generic Kortyx options:
temperaturestreamingmaxOutputTokensstopSequencesabortSignalreasoning.effortreasoning.maxTokensreasoning.includeThoughtsresponseFormat.type
Current Google mapping details:
responseFormat.type: "json"sets the Google response MIME type to JSONresponseFormat.type: "text"sets the Google response MIME type to plain textreasoning.*maps to Google thinking configuration
Current warning-backed gaps:
responseFormat.schemais not yet translated into GoogleresponseSchemaproviderOptionsis not yet mapped into Google request fields- unsupported
reasoning.effortvalues fall back to"medium"and add a compatibility warning
That means you should check result.warnings if you are relying on advanced generic options and want to confirm how the provider handled them.
10. Normalized metadata you get back
Google returns the normalized Kortyx result fields when the API provides them:
usagefinishReasonproviderMetadatawarningsraw
Google-specific metadata currently includes fields such as:
providerIdmodelIdresponseIdmodelVersionpromptFeedbackusageMetadata
Use providerMetadata when you need debugging or observability details without coupling your app code to the raw provider payload shape.
Supported scope
@kortyx/google currently supports text generation through useReason(...), including streaming and non-streaming invocation.
It does not currently expose provider-native embeddings, image generation, file APIs, Google-hosted tools, or multimodal output APIs. Check result.warnings when you rely on advanced generic options and want to verify how Google handled them.
Available built-in Google model ids
gemini-2.5-flashgemini-2.0-flashgemini-1.5-progemini-1.5-flash
Next steps
- See Hooks for
useReason(...)behavior and structured output - See Provider API for the shared normalized provider contract