Skip to content

Commit f146914

Browse files
aaronvgcursoragent
andauthored
Update vertex ai provider docs with api key info (#2519)
# Pull Request Template Thanks for taking the time to fill out this pull request! ## Issue Reference Please link to any related issues - [ ] This PR fixes/closes #[issue number] ## Changes This PR adds documentation for using Vertex AI API Keys (Express Mode) to the Vertex AI provider docs. This aims to simplify the initial setup for users by recommending a faster alternative to service account authentication. The changes include: - A new section detailing how to configure a Vertex AI client with an API key using `query_params`. - An `Info` note recommending Express Mode for quick starts and linking to Google's official guide. - Clarification on explicitly setting `project_id` and omitting `credentials` when using an API key. - An updated `ParamField` for `query_params` to include the API key example. ## Testing Please describe how you tested these changes - [ ] Unit tests added/updated - [X] Manual testing performed (verified documentation renders correctly) - [ ] Tested in [environment] ## Screenshots If applicable, add screenshots to help explain your changes [Add screenshots here...] ## PR Checklist Please ensure you've completed these items - [X] I have read and followed the contributing guidelines - [X] My code follows the style guidelines of this project - [X] I have performed a self-review of my own code - [X] I have commented my code, particularly in hard-to-understand areas - [X] I have made corresponding changes to the documentation - [X] My changes generate no new warnings ## Additional Notes This change directly addresses the user request to document the Vertex API Key (Express Mode) for faster onboarding, including a recommendation and a link to the official Google documentation. --- <a href="https://cursor.com/background-agent?bcId=bc-0bc51542-2ea0-491b-9712-6fa91f28ed99"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-0bc51542-2ea0-491b-9712-6fa91f28ed99"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web" src="https://cursor.com/open-in-web.svg"></picture></a> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent d3d6be6 commit f146914

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

  • fern/03-reference/baml/clients/providers

fern/03-reference/baml/clients/providers/vertex.mdx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,35 @@ can expect authentication to work out of the box.
4545
Setting [`options.credentials`](#credentials) will take precedence and force `vertex-ai` to load
4646
service account credentials from that file path.
4747

48+
### Using a Vertex API Key (Express Mode)
49+
50+
<Info>
51+
To get started quickly, we recommend using Express Mode with a Vertex API Key.
52+
This avoids service account setup and works well for prototyping.
53+
54+
See Google's guide: [Use Vertex API keys (Express Mode)](https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys?usertype=expressmode).
55+
</Info>
56+
57+
When using a Vertex API Key, set the `key` query parameter and specify your `project_id` and `location`:
58+
59+
```baml BAML
60+
client<llm> VertexApiKeyClient {
61+
provider vertex-ai
62+
options {
63+
model gemini-2.5-pro
64+
location us-central1
65+
project_id my-project-id
66+
query_params {
67+
key env.VERTEX_API_KEY
68+
}
69+
}
70+
}
71+
```
72+
73+
Notes:
74+
- `project_id` cannot be inferred when using an API key; set it explicitly.
75+
- Keep `credentials` unset when using an API key, so BAML does not prefer service account auth.
76+
4877
### Playground
4978
To use a `vertex-ai` client in the playground, all you need to do is run `gcloud
5079
auth application-default login` in the terminal. The playground will then use these
@@ -334,6 +363,27 @@ client<llm> MyClient {
334363
```
335364
</ParamField>
336365

366+
<ParamField path="query_params" type="object">
367+
Query string parameters appended to the request URL.
368+
369+
Example (use a Vertex API Key with Express Mode):
370+
```baml BAML
371+
client<llm> MyClient {
372+
provider vertex-ai
373+
options {
374+
model gemini-2.5-pro
375+
project_id my-project-id
376+
location us-central1
377+
query_params {
378+
key env.VERTEX_API_KEY
379+
}
380+
}
381+
}
382+
```
383+
384+
When using an API key, omit `credentials` and set `project_id` explicitly.
385+
</ParamField>
386+
337387
<Markdown src="/snippets/role-selection.mdx" />
338388

339389
<Markdown src="/snippets/allowed-role-metadata-basic.mdx" />

0 commit comments

Comments
 (0)