Generative AI & ML
Bedrock, SageMaker, and Vertex AI control planes plus deterministic runtime inference, driven by the real cloud SDKs
aws Bedrock + SageMakergcp Vertex AI
Emulates the managed AI/ML services — the model catalogs, endpoints, and training jobs of Bedrock and SageMaker (AWS) and Vertex AI (GCP), plus a runtime that answers inference calls. Each ships a control plane you provision against and a deterministic runtime that echoes your prompt back inside the model-native response envelope, so there are no GPUs, accounts, or per-token costs involved.
Reach for it in tests when your code invokes a model, manages endpoints, or orchestrates training/tuning jobs — so you can exercise wiring, retries, streaming setup, and error handling without a live model. Because responses are deterministic, assertions stay stable across runs.
| Provider | Service | SDK-compat | Driver |
|---|---|---|---|
| AWS | Bedrock (control plane + bedrock-runtime) | ✓ Live | aws.Bedrock |
| AWS | SageMaker (control plane + sagemaker-runtime) | ✓ Live | aws.SageMaker |
| GCP | Vertex AI (control plane + runtime) | ✓ Live | gcp.VertexAI |
Invoke a model with the real SDK#
Wire the drivers into the server and point the real runtime client at it — this exercises the actual invoke path, request signing, and response parsing your production code uses:
import (
"github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
"github.com/stackshy/cloudemu/v2"
awsserver "github.com/stackshy/cloudemu/v2/server/aws"
)
cloud := cloudemu.NewAWS()
ts := httptest.NewServer(awsserver.New(awsserver.Drivers{
Bedrock: cloud.Bedrock,
SageMaker: cloud.SageMaker,
}))
rt := bedrockruntime.NewFromConfig(cfg, func(o *bedrockruntime.Options) {
o.BaseEndpoint = aws.String(ts.URL)
})
rt.InvokeModel(ctx, &bedrockruntime.InvokeModelInput{
ModelId: aws.String("anthropic.claude-3-sonnet-20240229-v1:0"),
Body: []byte(`{"messages":[{"role":"user","content":"hello"}]}`),
})Vertex AI speaks the aiplatform REST API (generateContent, predict). See the SDK-Compat Server page.
Invoke with the Portable Go API#
When you don't need the SDK round-trip, call the driver directly — ListFoundationModels reads the seeded catalog and InvokeModel runs the deterministic runtime over a model-native body:
import bedrockdriver "github.com/stackshy/cloudemu/v2/services/bedrock/driver"
models, _ := aws.Bedrock.ListFoundationModels(ctx)
out, _ := aws.Bedrock.InvokeModel(ctx, bedrockdriver.InvokeModelInput{
ModelID: "anthropic.claude-3-sonnet-20240229-v1:0",
Body: []byte(`{"prompt":"hello"}`),
})Behavior & fidelity#
- Deterministic runtime, not real output.
InvokeModel/Converse/GenerateContent/InvokeEndpointecho the input inside model-family-specific response envelopes with whitespace-based token counts, so assertions are stable across runs. Bedrock embedding models return fixed-dimension vectors seeded by input length. - Jobs complete synchronously. Training, tuning, batch-prediction, and customization jobs are driven straight to terminal success — no polling loops in tests — and Vertex AI long-running operations return
done: truewith the result inlined.InvokeEndpointvalidates that the endpoint exists and isInService. - SDK-compat status — Live. Real Bedrock (control plane: ListFoundationModels/GetFoundationModel, customization jobs, custom models, guardrails, provisioned throughput, invocation logging; runtime: InvokeModel, Converse), SageMaker (
SageMaker.*control plane covering models, endpoint configs/endpoints, inference components, training/processing/transform/tuning/AutoML/labeling/compilation jobs, model registry, Studio, notebooks, HyperPod, Feature Store, pipelines, tagging; runtime: InvokeEndpoint, InvokeEndpointAsync), and Vertex AI (REST control plane for models, endpoints, datasets, the job families, Feature Store, Vector Search, metadata; runtime: GenerateContent, CountTokens, Predict, RawPredict) clients point at the SDK-compat server. Seeded Bedrock model families: Anthropic Claude, Amazon Titan, Meta Llama, Cohere Command, plus Titan embeddings.