You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: splunklib/ai/README.md
+83Lines changed: 83 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,7 @@ We support following predefined models:
47
47
48
48
-`OpenAIModel` - works with OpenAI and any [OpenAI-compatible API](https://platform.openai.com/docs/api-reference).
49
49
-`AnthropicModel` - works with Anthropic and any [Anthropic-compatible API](https://docs.anthropic.com/en/api).
50
+
-`GoogleModel` - works with Google's Gemini models via the [Gemini API](https://ai.google.dev/gemini-api/docs) or [Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/overview).
50
51
51
52
### OpenAI
52
53
@@ -76,6 +77,88 @@ model = AnthropicModel(
76
77
asyncwith Agent(model=model) as agent: ....
77
78
```
78
79
80
+
### Google
81
+
82
+
`GoogleModel` supports two backends: the [Gemini API](https://ai.google.dev/gemini-api/docs) and [Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/overview).
83
+
The backend is selected automatically based on the parameters you provide, or you can
84
+
force it with the `vertexai` flag.
85
+
86
+
Requires the `google` optional extra:
87
+
88
+
```sh
89
+
pip install "splunk-sdk[google]"
90
+
# or with uv:
91
+
uv add splunk-sdk[google]
92
+
```
93
+
94
+
#### Gemini API
95
+
96
+
Use this when you have a Google AI Studio API key and do not need Vertex AI infrastructure.
97
+
Only `model` and `api_key` are required.
98
+
99
+
```py
100
+
from splunklib.ai import Agent, GoogleModel
101
+
102
+
model = GoogleModel(
103
+
model="gemini-2.0-flash",
104
+
api_key="YOUR_GOOGLE_API_KEY",
105
+
)
106
+
107
+
asyncwith Agent(model=model) as agent: ...
108
+
```
109
+
110
+
#### Vertex AI - API key
111
+
112
+
Use this to route requests through Vertex AI with an API key. Providing `project` is enough
113
+
for the SDK to switch to the Vertex AI backend automatically.
114
+
115
+
```py
116
+
from splunklib.ai import Agent, GoogleModel
117
+
118
+
model = GoogleModel(
119
+
model="gemini-2.0-flash",
120
+
api_key="YOUR_VERTEX_API_KEY",
121
+
project="your-gcp-project-id",
122
+
# location="us-central1", # optional, defaults to us-central1
123
+
)
124
+
125
+
asyncwith Agent(model=model) as agent: ...
126
+
```
127
+
128
+
#### Vertex AI - service account credentials
129
+
130
+
Use this when authenticating with a service account key file (or any
131
+
`google.auth.credentials.Credentials`-compatible object). No `api_key` is needed.
0 commit comments