feat(clients): models: Gemini on Vertex, Model Garden, Claude, endpoint models, media, VertexModel

One call table verified against Discovery (29 calls), live-verified read-only
with an express key and a service account token, /agent/models example routes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 04:40:00 +02:00
co-authored by Claude Sonnet 5.5
parent 6d744a433f
commit 6b731643bf
30 changed files with 3200 additions and 3 deletions
@@ -0,0 +1,29 @@
// Route: POST /agent/models/generate (hard caps: output tokens, prompt size, project requirement)
#include <cstdlib>
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
unsetenv("GOOGLE_CLOUD_PROJECT");
GoogleRig rig;
Fixture f(rig.client);
auto over = f.client->post("/agent/models/generate",
"{\"prompt\":\"hi\",\"max_tokens\":\"70000\"}", "application/json");
check(over.status == 422, "max_tokens over the 65536 cap is 422");
auto words = f.client->post("/agent/models/generate",
"{\"prompt\":\"hi\",\"max_tokens\":\"many\"}", "application/json");
check(words.status == 422, "non numeric max_tokens is 422");
std::string huge(1000001, 'x');
auto big = f.client->post("/agent/models/count", "{\"prompt\":\"" + huge + "\"}", "application/json");
check(big.status == 422, "prompt over the 1,000,000 char cap is 422");
auto id = f.client->post("/agent/models/generate",
"{\"prompt\":\"hi\",\"model\":\"a/b\"}", "application/json");
check(id.status == 422, "model id with a slash is 422");
auto claude = f.client->post("/agent/models/claude", "{\"prompt\":\"hi\"}", "application/json");
check(claude.status == 422 && contains(claude.body, "project"),
"Claude without GOOGLE_CLOUD_PROJECT is 422 naming the project");
check(rig.mock->send_count() == 0, "side effect: nothing reached Google");
return finish("agent/models/limits");
}
+45
View File
@@ -0,0 +1,45 @@
// Route: GET /agent/models (page, status and the declared call table; no credential needed)
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
{
Fixture f;
auto page = f.client->get("/agent/models");
check(page.status == 200, "page 200 without a credential");
check(contains(page.headers.get("Content-Type"), "text/html"), "html");
check(contains(page.body, "/embedded/agent_models.js"), "script referenced");
check(contains(page.body, "viewport") || contains(page.body, "<h1>Models</h1>"),
"page rendered");
check(contains(f.client->get("/").body, "/agent/models"), "matrix row present");
check(f.client->post("/agent/models").status == 405, "post on the page is 405");
}
{
GoogleRig none(false);
Fixture f(none.client);
auto st = f.client->get("/agent/models/status");
check(st.status == 200 && contains(st.body, "\"configured\":false"), "status: not configured");
check(contains(st.body, "\"mode\":\"express\""), "status: express mode without a project");
check(f.client->post("/agent/models/status").status == 405, "status post is 405");
check(none.mock->send_count() == 0, "side effect: no upstream traffic");
}
{
GoogleRig rig;
Fixture f(rig.client);
check(contains(f.client->get("/agent/models/status").body, "\"configured\":true"),
"status: configured with a key");
check(!contains(f.client->get("/agent/models/status").body, kTestKey), "credential never shown");
}
{
Fixture f;
auto calls = f.client->get("/agent/models/calls");
check(calls.status == 200, "calls 200");
check(contains(calls.body, "\"id\":\"gemini.generate\"") &&
contains(calls.body, "aiplatform.projects.locations.publishers.models.rawPredict") &&
contains(calls.body, "\"id\":\"media.predict_long_running\""),
"declared calls listed");
check(f.client->post("/agent/models/calls").status == 405, "calls post is 405");
}
return finish("agent/models/page");
}
@@ -0,0 +1,57 @@
// Routes: POST /agent/models/{generate,count,embed,claude,list,endpoint,image,music,video,video/status}
// Without a credential every one is 503 google_not_configured and sends
// nothing; with one, bad input is 422 before any network traffic; GET is 405.
#include <cstdlib>
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
namespace {
struct Route {
const char* path;
const char* valid; // well formed body
const char* bad; // rejected locally
};
const Route kRoutes[] = {
{"/agent/models/generate", "{\"prompt\":\"hi\"}", "{\"prompt\":\"\"}"},
{"/agent/models/count", "{\"prompt\":\"hi\"}", "{\"prompt\":\"\"}"},
{"/agent/models/embed", "{\"text\":\"hi\"}", "{\"text\":\"\"}"},
{"/agent/models/claude", "{\"prompt\":\"hi\"}", "{\"prompt\":\"\"}"},
{"/agent/models/list", "{\"publisher\":\"google\"}", "{\"publisher\":\"a/b\"}"},
{"/agent/models/endpoint", "{\"endpoint\":\"77\",\"prompt\":\"hi\"}",
"{\"endpoint\":\"7/7\",\"prompt\":\"hi\"}"},
{"/agent/models/image", "{\"prompt\":\"a cat\"}", "{\"prompt\":\"a cat\",\"count\":\"9\"}"},
{"/agent/models/music", "{\"prompt\":\"calm\"}", "{\"prompt\":\"\"}"},
{"/agent/models/video", "{\"prompt\":\"waves\"}", "{\"prompt\":\"waves\",\"duration_seconds\":\"99\"}"},
{"/agent/models/video/status", "{\"operation\":\"projects/p/locations/l/operations/1\"}",
"{\"operation\":\"../x\"}"},
};
} // namespace
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "demo-proj", 1);
{
GoogleRig none(false);
Fixture f(none.client);
for (const Route& r : kRoutes) {
auto res = f.client->post(r.path, r.valid, "application/json");
check(res.status == 503 && contains(res.body, "google_not_configured"),
std::string(r.path) + ": 503 google_not_configured without a credential");
check(f.client->get(r.path).status == 405, std::string(r.path) + ": GET is 405");
}
check(none.mock->send_count() == 0, "side effect: nothing sent without a credential");
}
{
GoogleRig rig;
Fixture f(rig.client);
for (const Route& r : kRoutes) {
auto res = f.client->post(r.path, r.bad, "application/json");
check(res.status == 422 && contains(res.body, "validation_error"),
std::string(r.path) + ": bad input is 422 (got " + std::to_string(res.status) + ")");
check(!contains(res.body, kTestKey), std::string(r.path) + ": credential never in a response");
}
check(rig.mock->send_count() == 0, "side effect: rejected input never reached Google");
}
return finish("agent/models/post");
}