riffer 0.53.0 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/rules/rbs-inline.md +8 -8
  3. data/.release-please-manifest.json +1 -1
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +43 -0
  6. data/README.md +24 -0
  7. data/Steepfile +19 -0
  8. data/docs/AGENTS.md +101 -14
  9. data/docs/CATALOG.md +8 -8
  10. data/docs/CONFIGURATION.md +47 -16
  11. data/docs/MCP.md +3 -4
  12. data/docs/OVERVIEW.md +1 -1
  13. data/docs/STREAM_EVENTS.md +1 -1
  14. data/docs/TOOLS.md +15 -12
  15. data/docs/TRACING.md +1 -1
  16. data/docs/providers/AMAZON_BEDROCK.md +2 -0
  17. data/docs/providers/ANTHROPIC.md +32 -36
  18. data/docs/providers/CUSTOM_PROVIDERS.md +35 -0
  19. data/docs/providers/GEMINI.md +76 -25
  20. data/docs/providers/GOOGLE_CLOUD.md +363 -0
  21. data/docs/providers/PROVIDERS.md +30 -18
  22. data/docs-site/manifest.yml +3 -0
  23. data/lib/riffer/agent/structured_output.rb +28 -3
  24. data/lib/riffer/config/anthropic.rb +9 -0
  25. data/lib/riffer/config/gemini.rb +9 -0
  26. data/lib/riffer/config/google_cloud.rb +38 -0
  27. data/lib/riffer/config.rb +3 -0
  28. data/lib/riffer/http/client.rb +141 -0
  29. data/lib/riffer/http.rb +5 -0
  30. data/lib/riffer/mcp/client.rb +0 -1
  31. data/lib/riffer/params/any_of.rb +50 -0
  32. data/lib/riffer/params/format.rb +73 -0
  33. data/lib/riffer/params/param.rb +143 -19
  34. data/lib/riffer/params.rb +156 -30
  35. data/lib/riffer/providers/amazon_bedrock.rb +38 -5
  36. data/lib/riffer/providers/anthropic/client.rb +49 -0
  37. data/lib/riffer/providers/anthropic.rb +19 -452
  38. data/lib/riffer/providers/anthropic_compatible/messages_api/stream.rb +195 -0
  39. data/lib/riffer/providers/anthropic_compatible/messages_api.rb +293 -0
  40. data/lib/riffer/providers/anthropic_compatible.rb +5 -0
  41. data/lib/riffer/providers/anthropic_vertex.rb +66 -0
  42. data/lib/riffer/providers/base.rb +13 -16
  43. data/lib/riffer/providers/gemini/client.rb +17 -85
  44. data/lib/riffer/providers/gemini.rb +213 -80
  45. data/lib/riffer/providers/google_cloud/client.rb +106 -0
  46. data/lib/riffer/providers/google_cloud.rb +99 -0
  47. data/lib/riffer/providers/repository.rb +2 -0
  48. data/lib/riffer/version.rb +1 -1
  49. data/lib/riffer/wire/sse.rb +51 -0
  50. data/lib/riffer/wire.rb +31 -0
  51. data/lib/riffer.rb +18 -0
  52. data/rbs_collection.lock.yaml +32 -4
  53. data/rbs_collection.yaml +2 -0
  54. data/sig/_private/faraday.rbs +8 -0
  55. data/sig/_private/googleauth.rbs +7 -0
  56. data/sig/generated/riffer/agent/structured_output.rbs +6 -0
  57. data/sig/generated/riffer/config/anthropic.rbs +6 -0
  58. data/sig/generated/riffer/config/gemini.rbs +6 -0
  59. data/sig/generated/riffer/config/google_cloud.rbs +28 -0
  60. data/sig/generated/riffer/config.rbs +2 -0
  61. data/sig/generated/riffer/http/client.rbs +59 -0
  62. data/sig/generated/riffer/http.rbs +4 -0
  63. data/sig/generated/riffer/params/any_of.rbs +21 -0
  64. data/sig/generated/riffer/params/format.rbs +39 -0
  65. data/sig/generated/riffer/params/param.rbs +27 -4
  66. data/sig/generated/riffer/params.rbs +38 -8
  67. data/sig/generated/riffer/providers/amazon_bedrock.rbs +14 -2
  68. data/sig/generated/riffer/providers/anthropic/client.rbs +34 -0
  69. data/sig/generated/riffer/providers/anthropic.rbs +5 -124
  70. data/sig/generated/riffer/providers/anthropic_compatible/messages_api/stream.rbs +71 -0
  71. data/sig/generated/riffer/providers/anthropic_compatible/messages_api.rbs +99 -0
  72. data/sig/generated/riffer/providers/anthropic_compatible.rbs +4 -0
  73. data/sig/generated/riffer/providers/anthropic_vertex.rbs +45 -0
  74. data/sig/generated/riffer/providers/gemini/client.rbs +11 -34
  75. data/sig/generated/riffer/providers/gemini.rbs +66 -4
  76. data/sig/generated/riffer/providers/google_cloud/client.rbs +71 -0
  77. data/sig/generated/riffer/providers/google_cloud.rbs +64 -0
  78. data/sig/generated/riffer/wire/sse.rbs +23 -0
  79. data/sig/generated/riffer/wire.rbs +17 -0
  80. data/sig/generated/riffer.rbs +12 -0
  81. data/sig/manifest.yaml +2 -1
  82. data/sig/manual/riffer/params/format.rbs +5 -0
  83. data/sig/manual/riffer/providers/anthropic_compatible/messages_api.rbs +8 -0
  84. data/sig/manual/riffer/providers/gemini.rbs +8 -0
  85. data/sig/manual/riffer/providers/google_cloud.rbs +8 -0
  86. data/sig/manual/riffer/wire.rbs +5 -0
  87. metadata +66 -5
  88. data/sig/_private/anthropic.rbs +0 -17
  89. data/sig/_private/riffer/providers/anthropic.rbs +0 -6
  90. data/sig/_private/riffer/providers/gemini.rbs +0 -7
@@ -0,0 +1,363 @@
1
+ # Google Cloud Providers
2
+
3
+ Two providers connect to models hosted on Gemini Enterprise Agent Platform (formerly Vertex AI), authenticating with Google Cloud credentials instead of an API key:
4
+
5
+ | Provider | Identifier | Models |
6
+ | ------------------------------------ | ------------------ | ------ |
7
+ | `Riffer::Providers::GoogleCloud` | `google_cloud` | Gemini |
8
+ | `Riffer::Providers::AnthropicVertex` | `anthropic_vertex` | Claude |
9
+
10
+ Both read `config.google_cloud` and send requests through the same client, `Riffer::Providers::GoogleCloud::Client`.
11
+
12
+ ## Installation
13
+
14
+ Add the `googleauth` gem to your Gemfile:
15
+
16
+ ```ruby
17
+ gem 'googleauth'
18
+ ```
19
+
20
+ ## Configuration
21
+
22
+ ```ruby
23
+ Riffer.configure do |config|
24
+ config.google_cloud.project_id = 'my-project'
25
+ config.google_cloud.location = 'us-central1' # Optional, defaults to "global"
26
+ end
27
+ ```
28
+
29
+ | Setting | Default | Description |
30
+ | ------------- | --------------------------------------- | -------------------------------------------------------------------------------- |
31
+ | `project_id` | `nil` (required) | The Google Cloud project that owns the Agent Platform quota and billing |
32
+ | `location` | `"global"` | The Agent Platform location requests are sent to; picks the endpoint (see below) |
33
+ | `credentials` | `nil` (Application Default Credentials) | A `googleauth` credentials object |
34
+ | `client` | `nil` | A client instance or no-argument `Proc` (see [HTTP Client](#http-client)) |
35
+
36
+ `project_id` and `location` accept a `String` or `nil` and raise `Riffer::ArgumentError` naming the setting for anything else. Setting `location` to `nil` restores `"global"`. Without a `project_id` (and no `client`), the first request raises `Riffer::ArgumentError`.
37
+
38
+ ### Credentials
39
+
40
+ With `credentials` unset, riffer uses [Application Default Credentials](https://cloud.google.com/docs/authentication/application-default-credentials). `googleauth` checks, in order:
41
+
42
+ 1. The service account key file named by `GOOGLE_APPLICATION_CREDENTIALS`.
43
+ 2. Your own Google account, after you run `gcloud auth application-default login` (local development).
44
+ 3. The service account attached to the machine on Compute Engine, Cloud Run, or GKE.
45
+
46
+ To use a specific identity, pass any `googleauth` credentials object:
47
+
48
+ ```ruby
49
+ Riffer.configure do |config|
50
+ config.google_cloud.project_id = 'my-project'
51
+ config.google_cloud.credentials = Google::Auth::ServiceAccountCredentials.make_creds(
52
+ json_key_io: File.open(ENV.fetch('GOOGLE_CLOUD_SERVICE_ACCOUNT_KEY')),
53
+ scope: Riffer::Providers::GoogleCloud::Client::SCOPE
54
+ )
55
+ end
56
+ ```
57
+
58
+ Riffer caches the access token and refreshes it shortly before it expires.
59
+
60
+ ## Locations and Data Residency
61
+
62
+ The location decides the endpoint a request is sent to:
63
+
64
+ | `location` | Endpoint |
65
+ | ------------------------------ | ----------------------------------------------- |
66
+ | `global` | `https://aiplatform.googleapis.com` |
67
+ | `us`, `eu` (multi-region) | `https://aiplatform.{us,eu}.rep.googleapis.com` |
68
+ | Any region, e.g. `us-central1` | `https://{location}-aiplatform.googleapis.com` |
69
+
70
+ **The default `"global"` location offers no data-residency guarantee.** Google may serve a global request from any region. If your data must stay in a region or jurisdiction, set an explicit regional or multi-region `location`, and check that the model you use is available there.
71
+
72
+ A single `location` applies to every `google_cloud/...` and `anthropic_vertex/...` model. To bind one location explicitly, or to reach several locations from one process, use either approach below.
73
+
74
+ ### Binding the client
75
+
76
+ `config.google_cloud.client` takes a client instance or a no-argument `Proc` resolved on every LLM call (see [Configuration → Provider Clients](../CONFIGURATION.md#provider-clients)). Both providers use it, and it wins over `project_id`, `location`, and `credentials`:
77
+
78
+ ```ruby
79
+ Riffer.configure do |config|
80
+ config.google_cloud.client = Riffer::Providers::GoogleCloud::Client.new(
81
+ project_id: 'my-project',
82
+ location: 'europe-west4'
83
+ )
84
+ end
85
+ ```
86
+
87
+ ### One provider per location
88
+
89
+ To route different agents to different locations, register a provider subclass per location. Riffer constructs providers with no arguments, so the location lives on the class:
90
+
91
+ ```ruby
92
+ class GoogleCloudEurope < Riffer::Providers::GoogleCloud
93
+ private
94
+
95
+ # Ignore config.google_cloud.client, so this class always uses its own location.
96
+ def global_client = nil
97
+
98
+ def build_client
99
+ Riffer::Providers::GoogleCloud::Client.new(
100
+ project_id: Riffer.config.google_cloud.project_id,
101
+ location: 'europe-west4',
102
+ credentials: Riffer.config.google_cloud.credentials
103
+ )
104
+ end
105
+ end
106
+
107
+ Riffer::Providers::Repository.register(:google_cloud_eu) { GoogleCloudEurope }
108
+ ```
109
+
110
+ A subclass of `Riffer::Providers::AnthropicVertex` binds a location for Claude models the same way.
111
+
112
+ Agents then pick the location by model prefix (`model 'google_cloud_eu/gemini-3.5-flash-lite'`). Register each subclass once, at boot, and return the same class from the block every time: riffer maps a provider class back to its registry key, and the [catalog](../CATALOG.md) looks up pricing and reasoning entries under that key (`google_cloud_eu/gemini-3.5-flash-lite`).
113
+
114
+ ## HTTP Client
115
+
116
+ Riffer ships its own Agent Platform transport, `Riffer::Providers::GoogleCloud::Client`, built on `Riffer::HTTP::Client`. The provider builds one from the configured settings by default.
117
+
118
+ | Option | Default | Description |
119
+ | ------------- | -------------------------------------- | -------------------------------------------------------------- |
120
+ | `project_id` | required | Project segment of the resource path |
121
+ | `location` | required | Location segment of the resource path; also picks the endpoint |
122
+ | `credentials` | `nil` | A `googleauth` credentials object; `nil` resolves ADC |
123
+ | `base_url` | derived from `location` | API origin (Private Service Connect, proxies) |
124
+ | `headers` | `{}` | Sent on every request; replaces riffer's same-name headers |
125
+ | `connection` | Faraday defaults, 10s open / 600s read | Your own `Faraday::Connection`; see [Connections][connections] |
126
+
127
+ Timeouts, retries, proxies and errors are covered in [Configuration → Connections][connections]. Errors are labelled `Google Cloud API error (<status>): <message>`.
128
+
129
+ The class is a default implementation, not a required base: any object implementing the two-method contract works. Paths are relative to `v1/projects/{project_id}/locations/{location}/`.
130
+
131
+ | Method | Contract |
132
+ | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
133
+ | `post(path, body)` | POST `body` as JSON to `path`; return the parsed response `Hash` (symbol keys); raise `Riffer::APIError` on a non-success status |
134
+ | `post_stream(path, body) { \|chunk\| }` | POST `body` as JSON to `path`; yield raw response body chunks; raise `Riffer::APIError` on a non-success status |
135
+
136
+ [connections]: ../CONFIGURATION.md#connections
137
+
138
+ ## Supported Models
139
+
140
+ Use Agent Platform model IDs, prefixed with the provider for the model family:
141
+
142
+ ```ruby
143
+ model 'google_cloud/gemini-3.5-flash-lite'
144
+ model 'google_cloud/gemini-3.8-flash'
145
+ model 'anthropic_vertex/claude-haiku-5-5'
146
+ model 'anthropic_vertex/claude-haiku-4-5@20251001'
147
+ ```
148
+
149
+ Model IDs may carry an `@version` suffix, as Agent Platform's dated Claude snapshots do; use the ID Model Garden shows.
150
+
151
+ ## Gemini Models (`google_cloud`)
152
+
153
+ ### Model Options
154
+
155
+ #### temperature
156
+
157
+ Controls randomness:
158
+
159
+ ```ruby
160
+ model_options temperature: 0.7
161
+ ```
162
+
163
+ #### maxOutputTokens
164
+
165
+ Maximum tokens in response:
166
+
167
+ ```ruby
168
+ model_options maxOutputTokens: 4096
169
+ ```
170
+
171
+ #### topP
172
+
173
+ Nucleus sampling:
174
+
175
+ ```ruby
176
+ model_options topP: 0.9
177
+ ```
178
+
179
+ #### thinkingConfig
180
+
181
+ Controls thinking, passed through as Agent Platform expects:
182
+
183
+ ```ruby
184
+ model_options thinkingConfig: {thinkingLevel: "low"}
185
+ ```
186
+
187
+ The agent-level [`reasoning`](../AGENTS.md#reasoning) setting writes `thinkingConfig: {thinkingLevel: "<level>"}` by default. To map a model differently, add a [catalog](../CATALOG.md#reasoning) entry under its `google_cloud/...` key.
188
+
189
+ #### web_search
190
+
191
+ Enable grounding with Google Search. Pass `true` to use defaults or a hash to merge into the `googleSearch` tool:
192
+
193
+ ```ruby
194
+ model_options web_search: true
195
+ model_options web_search: {excludeDomains: ["example.com"]}
196
+ ```
197
+
198
+ ### Basic Generation
199
+
200
+ ```ruby
201
+ provider = Riffer::Providers::GoogleCloud.new
202
+
203
+ response = provider.generate_text(
204
+ prompt: "Hello!",
205
+ model: "gemini-3.5-flash-lite"
206
+ )
207
+ puts response.content
208
+ ```
209
+
210
+ ### Streaming
211
+
212
+ ```ruby
213
+ provider.stream_text(prompt: "Tell me a story", model: "gemini-3.5-flash-lite").each do |event|
214
+ case event
215
+ when Riffer::StreamEvents::TextDelta
216
+ print event.content
217
+ when Riffer::StreamEvents::TextDone
218
+ puts "\n---"
219
+ end
220
+ end
221
+ ```
222
+
223
+ ### Structured Output
224
+
225
+ ```ruby
226
+ params = Riffer::Params.new
227
+ params.required(:sentiment, String)
228
+ params.required(:score, Float)
229
+ structured_output = Riffer::Agent::StructuredOutput.new(params)
230
+
231
+ response = provider.generate_text(
232
+ prompt: "Analyze: 'This is great!'",
233
+ model: "gemini-3.5-flash-lite",
234
+ structured_output: structured_output
235
+ )
236
+ puts response.structured_output
237
+ ```
238
+
239
+ The schema is sent in strict form: every field is listed as required, and an optional field is nullable, so the model can return `null` for a value it doesn't know instead of making one up. A `Hash` param needs a block and an `Array` param a block or `of:` (see [Structured Output Limitations](../AGENTS.md#limitations)).
240
+
241
+ ### Tool Calling
242
+
243
+ ```ruby
244
+ class WeatherTool < Riffer::Tool
245
+ description "Gets weather"
246
+ params do
247
+ required :city, String
248
+ end
249
+ def call(context:, city:)
250
+ text("Sunny in #{city}")
251
+ end
252
+ end
253
+
254
+ response = provider.generate_text(
255
+ prompt: "What's the weather in Tokyo?",
256
+ model: "gemini-3.5-flash-lite",
257
+ tools: [WeatherTool]
258
+ )
259
+ ```
260
+
261
+ Riffer gives each tool call its own `call_id` (`gemini_call_<hex>`) and appends the model's id when there is one. On later turns riffer sends that id back on the function call and its result, so the model can match results to parallel calls of the same tool.
262
+
263
+ ### Thought Signatures
264
+
265
+ Gemini 3 models attach an opaque `thoughtSignature` to the first function call of each step, and to the last text part of an answer. A later request that sends a function call back without its signature is rejected with a 400.
266
+
267
+ Riffer keeps each signature on the assistant message as the `data` of an `:encrypted` [reasoning part](../MESSAGES.md#reasoning) tagged `format: "google-cloud-generate-content-v1"` (`Riffer::Providers::GoogleCloud::REASONING_FORMAT`). A signature from a function call carries that tool call's `call_id` as its `id`; the text signature has no `id`. Streams emit them as `ReasoningDone` events. On later turns riffer puts each signature back on the part it came from. You don't have to do anything as long as the assistant messages stay in the history.
268
+
269
+ A function call without an Agent Platform signature goes out with Google's placeholder signature (`skip_thought_signature_validator`), which Agent Platform accepts in place of a real one. That happens when the call came from another provider, or from the Gemini Developer API, whose signatures Agent Platform rejects. It covers the first call of each step when that call has no signature for this provider. Google warns that a call without its real signature may degrade the model's answer, so if you persist sessions, keep the `reasoning` key when you store messages.
270
+
271
+ ### Web Search
272
+
273
+ With `web_search` set, riffer adds the `googleSearch` tool and turns on `toolConfig.includeServerSideToolInvocations`, which is required when Google Search and function tools are used together.
274
+
275
+ ```ruby
276
+ provider.stream_text(
277
+ prompt: "What is the latest Ruby version?",
278
+ model: "gemini-3.5-flash-lite",
279
+ web_search: true
280
+ ).each do |event|
281
+ case event
282
+ when Riffer::StreamEvents::WebSearchDone
283
+ puts "[search complete: #{event.query}]"
284
+ event.sources.each { |s| puts " - #{s[:title]}: #{s[:url]}" }
285
+ when Riffer::StreamEvents::TextDelta
286
+ print event.content
287
+ end
288
+ end
289
+ ```
290
+
291
+ - No `WebSearchStatus` events are streamed. The queries and sources of a response arrive together, at the end, without saying which query found which source. Riffer emits them as one `WebSearchDone`, after the text, with the queries joined by `", "`.
292
+ - Source `title`s are domains (`"ruby-lang.org"`) and `url`s are Google redirect links (`https://vertexaisearch.cloud.google.com/grounding-api-redirect/...`).
293
+ - After a tool call, the model searches again if it still needs results.
294
+
295
+ ### File Support
296
+
297
+ Files are sent inline as base64 (images and documents):
298
+
299
+ ```ruby
300
+ file = Riffer::Messages::User::FilePart.new(data: base64_data, media_type: "image/png")
301
+ response = provider.generate_text(
302
+ prompt: "Describe this image",
303
+ model: "gemini-3.5-flash-lite",
304
+ files: [file]
305
+ )
306
+ ```
307
+
308
+ A `FilePart.from_url` source works too: riffer downloads and base64-encodes it before sending, subject to the `allow_downloads` policy in [File Downloads](../CONFIGURATION.md#file-downloads).
309
+
310
+ ### Tags
311
+
312
+ Per-call [tags](../AGENTS.md#per-call-tags) are sent as request `labels`, which show up in Google Cloud billing reports. Riffer rewrites each tag into a valid label: downcased, any character other than a letter, digit, `_` or `-` replaced with `_`, and cut to 63 characters. Tags whose key doesn't start with a letter are dropped. `agent: "support/triage_agent"` goes out as `agent: "support_triage_agent"`.
313
+
314
+ To send fixed labels, set them as a model option; tags are merged over them:
315
+
316
+ ```ruby
317
+ model_options labels: {cost_center: "cc_1234"}
318
+ ```
319
+
320
+ ## Claude Models (`anthropic_vertex`)
321
+
322
+ Claude models use Agent Platform's Anthropic endpoints (`rawPredict` and `streamRawPredict`), which take the Anthropic Messages API body. Riffer builds the same body as the [Anthropic provider](ANTHROPIC.md), so the same [model options](ANTHROPIC.md#model-options) apply (`max_tokens`, defaulting to `4096`, `thinking`, `output_config`, `web_search`, ...). The model goes in the URL, and `anthropic_version: "2026-10-21"`, the Anthropic provider's API version, goes in the body in place of the `anthropic-version` header. That version rejects `temperature`, `top_p` and `top_k`. Enable each Claude model for your project in Model Garden before calling it.
323
+
324
+ To send another version, subclass the provider, override `anthropic_version`, and register the subclass under `anthropic_vertex`. A registration replaces the built-in under the same identifier, so models and [catalog](../CATALOG.md) entries keep their `anthropic_vertex/...` names:
325
+
326
+ ```ruby
327
+ class LegacyAnthropicVertex < Riffer::Providers::AnthropicVertex
328
+ private
329
+
330
+ def anthropic_version = "vertex-2023-10-16"
331
+ end
332
+
333
+ Riffer::Providers::Repository.register(:anthropic_vertex) { LegacyAnthropicVertex }
334
+ ```
335
+
336
+ ```ruby
337
+ provider = Riffer::Providers::AnthropicVertex.new
338
+
339
+ response = provider.generate_text(
340
+ prompt: "Hello!",
341
+ model: "claude-haiku-5-5",
342
+ thinking: { type: "adaptive", display: "summarized" },
343
+ output_config: { effort: "high" }
344
+ )
345
+ ```
346
+
347
+ Claude models on Agent Platform behave as they do on the Anthropic provider:
348
+
349
+ - **Reasoning** is captured as [reasoning parts](../MESSAGES.md#reasoning) tagged `format: "anthropic-messages-v1"` and sent back on later turns, as described in [Anthropic → Reasoning Replay](ANTHROPIC.md#reasoning-replay). Thinking signatures are accepted by both APIs, so a conversation can move between `anthropic` and `anthropic_vertex`. The agent-level [`reasoning`](../AGENTS.md#reasoning) setting uses the Anthropic default; [catalog](../CATALOG.md#reasoning) entries go under `anthropic_vertex/...` keys.
350
+ - **Web search:** `web_search: true` (or a hash of options) adds the `web_search_20250305` server tool and streams `WebSearchStatus` / `WebSearchDone` events.
351
+ - **Structured output** is sent as a strict `output_config.format` JSON schema.
352
+ - **Skills** are rendered with the XML skills adapter.
353
+ - **Tags:** only the reserved `user_id` tag is sent, as `metadata.user_id`.
354
+ - **Incomplete streams:** a stream that ends without a `message_stop` event raises `Riffer::IncompleteStreamError`.
355
+
356
+ `anthropic_vertex` never reads `config.anthropic` or `ANTHROPIC_API_KEY`. Files are sent inline as base64.
357
+
358
+ Web search and structured output are partner-model features that an organization policy can turn off. If a request fails with a `constraints/vertexai.allowedPartnerModelFeatures` violation, an organization policy administrator must allow `publishers/anthropic/models/MODEL:web_search` or `:structured_outputs` (or `publishers/anthropic` for every feature); see [Control access to Model Garden models](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/control-model-access).
359
+
360
+ ## Limitations
361
+
362
+ - **No `gs://` file references** - files are always sent inline
363
+ - **Tool call IDs** - Gemini does not return unique call IDs for tool invocations; IDs are generated client-side
@@ -4,15 +4,17 @@ Providers are adapters that connect Riffer to LLM services. They implement a com
4
4
 
5
5
  ## Available Providers
6
6
 
7
- | Provider | Identifier | Gem Required |
8
- | -------------- | ---------------- | ------------------------ |
9
- | OpenAI | `openai` | `openai` |
10
- | Azure OpenAI | `azure_openai` | `openai` |
11
- | Amazon Bedrock | `amazon_bedrock` | `aws-sdk-bedrockruntime` |
12
- | Anthropic | `anthropic` | `anthropic` |
13
- | Gemini | `gemini` | None |
14
- | OpenRouter | `openrouter` | `openai` |
15
- | Mock | `mock` | None |
7
+ | Provider | Identifier | Gem Required |
8
+ | --------------------- | ------------------ | ------------------------ |
9
+ | OpenAI | `openai` | `openai` |
10
+ | Azure OpenAI | `azure_openai` | `openai` |
11
+ | Amazon Bedrock | `amazon_bedrock` | `aws-sdk-bedrockruntime` |
12
+ | Anthropic | `anthropic` | None |
13
+ | Gemini | `gemini` | None |
14
+ | Google Cloud (Gemini) | `google_cloud` | `googleauth` |
15
+ | Google Cloud (Claude) | `anthropic_vertex` | `googleauth` |
16
+ | OpenRouter | `openrouter` | `openai` |
17
+ | Mock | `mock` | None |
16
18
 
17
19
  ## Model String Format
18
20
 
@@ -24,7 +26,9 @@ class MyAgent < Riffer::Agent
24
26
  model 'azure_openai/gpt-5-mini' # Azure OpenAI
25
27
  model 'amazon_bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0' # Bedrock
26
28
  model 'anthropic/claude-haiku-4-5-20251001' # Anthropic
27
- model 'gemini/gemini-2.5-flash-lite' # Gemini
29
+ model 'gemini/gemini-3.5-flash-lite' # Gemini
30
+ model 'google_cloud/gemini-3.5-flash-lite' # Google Cloud (Gemini)
31
+ model 'anthropic_vertex/claude-haiku-5-5' # Google Cloud (Claude)
28
32
  model 'openrouter/anthropic/claude-sonnet-4.6' # OpenRouter
29
33
  model 'mock/any' # Mock provider
30
34
  end
@@ -34,14 +38,15 @@ end
34
38
 
35
39
  Every credential comes from configuration: `Riffer::Providers::OpenAI.new` takes no arguments.
36
40
 
37
- | Provider | Configured credentials |
38
- | -------------- | ----------------------------------------------------------------- |
39
- | OpenAI | `config.openai.api_key`, `config.openai.base_url` |
40
- | Azure OpenAI | `config.azure_openai.api_key`, `config.azure_openai.endpoint` |
41
- | Anthropic | `config.anthropic.api_key` |
42
- | Amazon Bedrock | `config.amazon_bedrock.api_token`, `config.amazon_bedrock.region` |
43
- | Gemini | `config.gemini.api_key` |
44
- | OpenRouter | `config.openrouter.api_key` |
41
+ | Provider | Configured credentials |
42
+ | ------------------------------ | ----------------------------------------------------------------- |
43
+ | OpenAI | `config.openai.api_key`, `config.openai.base_url` |
44
+ | Azure OpenAI | `config.azure_openai.api_key`, `config.azure_openai.endpoint` |
45
+ | Anthropic | `config.anthropic.api_key`, `config.anthropic.base_url` |
46
+ | Amazon Bedrock | `config.amazon_bedrock.api_token`, `config.amazon_bedrock.region` |
47
+ | Gemini | `config.gemini.api_key`, `config.gemini.base_url` |
48
+ | Google Cloud (Gemini, Claude) | `config.google_cloud.project_id`, `.location`, `.credentials` |
49
+ | OpenRouter | `config.openrouter.api_key` |
45
50
 
46
51
  Out of the box, each provider builds an SDK client from these credentials. Everything else — timeouts, retries, proxies, custom auth — is configured by assigning your own client (an instance, or a `Proc` resolved on every LLM call) to `Riffer.config.<provider>.client`. See [Configuration → Provider Clients](../CONFIGURATION.md#provider-clients).
47
52
 
@@ -182,6 +187,12 @@ Riffer::Providers::Repository.find(:anthropic)
182
187
  Riffer::Providers::Repository.find(:gemini)
183
188
  # => Riffer::Providers::Gemini
184
189
 
190
+ Riffer::Providers::Repository.find(:google_cloud)
191
+ # => Riffer::Providers::GoogleCloud
192
+
193
+ Riffer::Providers::Repository.find(:anthropic_vertex)
194
+ # => Riffer::Providers::AnthropicVertex
195
+
185
196
  Riffer::Providers::Repository.find(:openrouter)
186
197
  # => Riffer::Providers::OpenRouter
187
198
 
@@ -198,4 +209,5 @@ Riffer::Providers::Repository.find(:mock)
198
209
  - [Mock](MOCK_PROVIDER.md) - Mock provider for testing
199
210
  - [Custom Providers](CUSTOM_PROVIDERS.md) - Creating your own provider
200
211
  - [Gemini](GEMINI.md) - Gemini models via Google GenAI API
212
+ - [Google Cloud](GOOGLE_CLOUD.md) - Gemini and Claude models on Agent Platform (formerly Vertex AI)
201
213
  - [OpenRouter](OPENROUTER.md) - Unified gateway across many vendors
@@ -91,6 +91,9 @@ groups:
91
91
  - source: providers/GEMINI.md
92
92
  slug: providers/gemini
93
93
  description: Google Gemini models
94
+ - source: providers/GOOGLE_CLOUD.md
95
+ slug: providers/google-cloud
96
+ description: Gemini and Claude on Agent Platform
94
97
  - source: providers/OPENROUTER.md
95
98
  slug: providers/openrouter
96
99
  description: Hundreds of models, one API
@@ -30,9 +30,14 @@ class Riffer::Agent::StructuredOutput
30
30
  #--
31
31
  #: () -> String
32
32
  def prompt_instructions
33
- "When you give your final answer, respond with only a JSON object that conforms to " \
34
- "the following JSON Schema, with no other text before or after it:\n\n" \
35
- "#{JSON.generate(json_schema)}"
33
+ schema = json_schema
34
+ [
35
+ "When you give your final answer, respond with only a JSON object that conforms to " \
36
+ "the following JSON Schema, with no other text before or after it:",
37
+ JSON.generate(schema),
38
+ "Example of the shape (placeholder values):\n#{JSON.generate(placeholder(schema))}",
39
+ "Only call tools when the request needs them. If you can answer directly, reply with the JSON object right away.",
40
+ ].join("\n\n")
36
41
  end
37
42
 
38
43
  #--
@@ -46,4 +51,24 @@ class Riffer::Agent::StructuredOutput
46
51
  rescue Riffer::ValidationError => e
47
52
  Result.new(error: "Validation error: #{e.message}")
48
53
  end
54
+
55
+ private
56
+
57
+ #--
58
+ #: (Hash[Symbol, untyped]) -> untyped
59
+ def placeholder(schema)
60
+ return schema[:enum].join(" | ") if schema[:enum]
61
+
62
+ if schema[:anyOf]
63
+ examples = schema[:anyOf].map { |branch| placeholder(branch) }
64
+ # Showing one primitive branch would steer the model to that type only.
65
+ return examples.all?(String) ? examples.join(" | ") : examples.first
66
+ end
67
+
68
+ case schema[:type]
69
+ when "object" then (schema[:properties] || {}).transform_values { |property| placeholder(property) }
70
+ when "array" then schema[:items] ? [placeholder(schema[:items])] : []
71
+ else "<#{schema[:type]}>"
72
+ end
73
+ end
49
74
  end
@@ -4,12 +4,15 @@
4
4
  class Riffer::Config::Anthropic
5
5
  attr_reader :api_key #: String? # @dynamic api_key
6
6
 
7
+ attr_reader :base_url #: String? # @dynamic base_url
8
+
7
9
  attr_accessor :client #: untyped # @dynamic client, client=
8
10
 
9
11
  #--
10
12
  #: () -> void
11
13
  def initialize
12
14
  @api_key = nil
15
+ @base_url = nil
13
16
  @client = nil
14
17
  end
15
18
 
@@ -18,4 +21,10 @@ class Riffer::Config::Anthropic
18
21
  def api_key=(value)
19
22
  @api_key = Riffer::Helpers::Validate.optional_string(value, attribute: "api_key")
20
23
  end
24
+
25
+ #--
26
+ #: (untyped) -> void
27
+ def base_url=(value)
28
+ @base_url = Riffer::Helpers::Validate.optional_string(value, attribute: "base_url")
29
+ end
21
30
  end
@@ -4,12 +4,15 @@
4
4
  class Riffer::Config::Gemini
5
5
  attr_reader :api_key #: String? # @dynamic api_key
6
6
 
7
+ attr_reader :base_url #: String? # @dynamic base_url
8
+
7
9
  attr_accessor :client #: untyped # @dynamic client, client=
8
10
 
9
11
  #--
10
12
  #: () -> void
11
13
  def initialize
12
14
  @api_key = nil
15
+ @base_url = nil
13
16
  @client = nil
14
17
  end
15
18
 
@@ -18,4 +21,10 @@ class Riffer::Config::Gemini
18
21
  def api_key=(value)
19
22
  @api_key = Riffer::Helpers::Validate.optional_string(value, attribute: "api_key")
20
23
  end
24
+
25
+ #--
26
+ #: (untyped) -> void
27
+ def base_url=(value)
28
+ @base_url = Riffer::Helpers::Validate.optional_string(value, attribute: "base_url")
29
+ end
21
30
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ class Riffer::Config::GoogleCloud
5
+ attr_reader :project_id #: String? # @dynamic project_id
6
+
7
+ # The default +"global"+ endpoint routes requests to any region, so it
8
+ # carries no data-residency guarantee.
9
+ attr_reader :location #: String # @dynamic location
10
+
11
+ # A googleauth credentials object; +nil+ resolves Application Default
12
+ # Credentials.
13
+ attr_accessor :credentials #: untyped # @dynamic credentials, credentials=
14
+
15
+ attr_accessor :client #: untyped # @dynamic client, client=
16
+
17
+ #--
18
+ #: () -> void
19
+ def initialize
20
+ @project_id = nil
21
+ @location = "global"
22
+ @credentials = nil
23
+ @client = nil
24
+ end
25
+
26
+ #--
27
+ #: (untyped) -> void
28
+ def project_id=(value)
29
+ @project_id = Riffer::Helpers::Validate.optional_string(value, attribute: "project_id")
30
+ end
31
+
32
+ # +nil+ restores the +"global"+ default.
33
+ #--
34
+ #: (untyped) -> void
35
+ def location=(value)
36
+ @location = Riffer::Helpers::Validate.optional_string(value, attribute: "location") || "global"
37
+ end
38
+ end
data/lib/riffer/config.rb CHANGED
@@ -14,6 +14,8 @@ class Riffer::Config
14
14
 
15
15
  attr_reader :gemini #: Riffer::Config::Gemini # @dynamic gemini
16
16
 
17
+ attr_reader :google_cloud #: Riffer::Config::GoogleCloud # @dynamic google_cloud
18
+
17
19
  attr_reader :openai #: Riffer::Config::OpenAI # @dynamic openai
18
20
 
19
21
  attr_reader :openrouter #: Riffer::Config::OpenRouter # @dynamic openrouter
@@ -91,6 +93,7 @@ class Riffer::Config
91
93
  @anthropic = Anthropic.new
92
94
  @azure_openai = AzureOpenAI.new
93
95
  @gemini = Gemini.new
96
+ @google_cloud = GoogleCloud.new
94
97
  @openai = OpenAI.new
95
98
  @openrouter = OpenRouter.new
96
99
  @evals = Evals.new