new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

google/setup

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Google provider module installation

The Google provider is available in the `@ai-sdk/google` module and can be installed with the package manager.

Google provider instance import

The default provider instance `google` can be imported from `@ai-sdk/google` using `import { google } from '@ai-sdk/google'`.

Google provider customization with createGoogle

Custom Google provider instances can be created by importing `createGoogle` from `@ai-sdk/google` and calling it with custom settings: `import { createGoogle } from '@ai-sdk/google'; const google = createGoogle({ // custom settings });`

Google provider configuration options

The Google provider accepts the following optional settings: baseURL (string, default `https://generativelanguage.googleapis.com/v1beta`), apiKey (string, defaults to `GOOGLE_GENERATIVE_AI_API_KEY` environment variable), headers (Record<string,string>), fetch (custom fetch implementation), generateId (function to generate unique IDs), and name (custom provider name, defaults to 'google.generative-ai').

generateText basic usage with Gemini

The generateText function from the AI SDK accepts a model parameter (created via google()), a prompt parameter, and returns an object with a text property containing the generated response.

streamText with Gemini route handler

The streamText function accepts a model and messages parameter. Messages should be converted using convertToModelMessages(). The result stream is converted to UI stream using toUIMessageStream() and returned via createUIMessageStreamResponse().

Google provider installation

To use Gemini with the AI SDK, install the packages: 'ai' and '@ai-sdk/google'.

Import statement for Google provider

The Google provider is imported from '@ai-sdk/google' using: import { google } from '@ai-sdk/google'; Additional types like GoogleLanguageModelOptions can be imported from the same package.

Give your agent this brain