Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel committed Sep 27, 2024
1 parent 7076218 commit 7c48d90
Showing 1 changed file with 49 additions and 6 deletions.
55 changes: 49 additions & 6 deletions content/providers/01-ai-sdk-providers/11-google-vertex.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ const model = vertex('gemini-1.5-pro', {

The following optional settings are available for Google Vertex models:

- **structuredOutputs** _boolean_

Optional. Enable structured output. Default is true.

This is useful when the JSON Schema contains elements that are
not supported by the OpenAPI schema version that
Google Vertex uses. You can use this to disable
structured outputs if you need to.

See [Troubleshooting: Schema Limitations](#troubleshooting-schema-limitations) for more details.

- **safetySettings** _Array\<\{ category: string; threshold: string \}\>_

Optional. Safety settings for the model.
Expand Down Expand Up @@ -207,14 +218,46 @@ const { text } = await generateText({
});
```

### Troubleshooting: Schema Limitations

The Google Vertex API uses a subset of the OpenAPI 3.0 schema,
which does not support features such as unions.
The errors that you get in this case look like this:

`GenerateContentRequest.generation_config.response_schema.properties[occupation].type: must be specified`

By default, structured outputs are enabled (and for tool calling they are required).
You can disable structured outputs for object generation as a workaround:

```ts highlight="3,8"
const result = await generateObject({
model: vertex('gemini-1.5-pro', {
structuredOutputs: false,
}),
schema: z.object({
name: z.string(),
age: z.number(),
contact: z.union([
z.object({
type: z.literal('email'),
value: z.string(),
}),
z.object({
type: z.literal('phone'),
value: z.string(),
}),
]),
}),
prompt: 'Generate an example person for testing.',
});
```

### Model Capabilities

| Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
| ----------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
| `gemini-1.5-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gemini-1.5-pro` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gemini-1.0-pro-vision` | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
| `gemini-1.0-pro` | <Cross size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
| Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
| ------------------ | ------------------- | ------------------- | ------------------- | ------------------- |
| `gemini-1.5-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gemini-1.5-pro` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |

<Note>
The table above lists popular models. You can also pass any available provider
Expand Down

0 comments on commit 7c48d90

Please sign in to comment.