Skip to content

Commit aa44ef1

Browse files
committed
docs: add google provider doc
1 parent b04fcd5 commit aa44ef1

File tree

2 files changed

+108
-1
lines changed

2 files changed

+108
-1
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: Google
3+
---
4+
5+
AISDK provides first-class support for Google with fully typed model APIs.
6+
Model capabilities are enforced at compile time using Rust’s type system.
7+
This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling).
8+
9+
10+
## Installation
11+
12+
Enable the Google provider feature:
13+
14+
```bash
15+
cargo add aisdk --features google
16+
```
17+
18+
This installs AISDK with the Google provider enabled.
19+
20+
Once you have enabled the Google provider, you can use all aisdk <Link href="/docs#core-features">features</Link> with it.
21+
22+
### Quick Start
23+
24+
Create a Google provider instance with default settings:
25+
26+
```rust
27+
use aisdk::providers::google::Google;
28+
29+
let google = Google::gemini_2_5_flash();
30+
```
31+
32+
This initializes the provider with:
33+
34+
* Model: `"gemini-2-5-flash"`
35+
* API key from environment (if set with `GOOGLE_API_KEY`)
36+
* Google’s default base URL
37+
38+
## Basic Text Generation
39+
40+
```rust
41+
use aisdk::{
42+
core::LanguageModelRequest,
43+
providers::google::Google,
44+
};
45+
46+
#[tokio::main]
47+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
48+
49+
// Initialize provider with default settings.
50+
let google = Google::gemini_2_5_flash();
51+
52+
let response = LanguageModelRequest::builder()
53+
.model(google)
54+
.prompt("Write a short poem about Rust.")
55+
.build()
56+
.generate_text()
57+
.await?
58+
.text()?;
59+
60+
println!("Model output: {}", response);
61+
Ok(())
62+
}
63+
```
64+
65+
## Provider Settings
66+
67+
You can customize provider configuration using `Google::builder()`
68+
69+
### API Key
70+
71+
```rust
72+
let google = Google::<Gemini25Flash>::builder()
73+
.api_key("your-api-key")
74+
.build()?;
75+
```
76+
77+
If not specified, AISDK uses the `GOOGLE_API_KEY` environment variable.
78+
79+
### Base URL
80+
81+
Useful when routing through a proxy, gateway, or self-hosted compatible endpoint.
82+
83+
```rust
84+
let google = Google::<Gemini25Flash>::builder()
85+
.base_url("https://generativelanguage.googleapis.com/v1beta")
86+
.build()?;
87+
```
88+
89+
### Provider Name
90+
91+
For logging, analytics, and observability.
92+
93+
```rust
94+
let google = Google::<Gemini25Flash>::builder()
95+
.provider_name("Google")
96+
.build()?;
97+
```
98+
99+
### Full Custom Configuration Example
100+
101+
```rust
102+
let google = Google::<Gemini25Flash>::builder()
103+
.api_key("your-api-key")
104+
.base_url("https://generativelanguage.googleapis.com/v1beta")
105+
.provider_name("Google")
106+
.build()?;
107+
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"title": "Providers",
33
"icon": "Workflow",
4-
"pages": ["index"]
4+
"pages": ["index","google"]
55
}

0 commit comments

Comments
 (0)