Generative AI
Bedrock and Azure OpenAI control planes plus Bedrock Agents, driven end-to-end by the real cloud SDKs with a deterministic runtime
aws Bedrockazr Azure OpenAI
Emulates the managed generative-AI services — the model catalogs, deployments, guardrails, and agents of AWS Bedrock and Azure OpenAI (Microsoft.CognitiveServices) — 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, deploys a model version, or orchestrates a retrieval-augmented agent — so you can exercise wiring, retries, and error handling without a live model. Because responses are deterministic, assertions stay stable across runs. For the training/endpoint/job side of AI — SageMaker, Vertex AI, and Azure ML — see Machine Learning.
| Provider | Service | SDK-compat | Driver |
|---|---|---|---|
| AWS | Bedrock (control plane + bedrock-runtime) | ✓ Live | aws.Bedrock |
| AWS | Bedrock Agents (bedrock-agent + bedrock-agent-runtime) | ✓ Live | aws.BedrockAgent / aws.BedrockAgentRuntime |
| Azure | Azure OpenAI / AI Services (Microsoft.CognitiveServices) | ✓ Live | azure.AI |
Drive it with the real SDK#
Drop the SDK-compat server in front of cloudemu 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,
BedrockAgent: cloud.BedrockAgent,
BedrockAgentRuntime: cloud.BedrockAgentRuntime,
}))
defer ts.Close()
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"}]}`),
})Azure OpenAI works the same way: register the mock as CognitiveServices (ARM) and AzureAIDataPlane (inference) on azureserver.Drivers, then point armcognitiveservices at the ARM endpoint and azopenai at the *.openai.azure.com data plane. See the SDK-Compat Server page for the Azure TLS setup.
Call the driver directly#
When you don't need the SDK round-trip, call the driver. ListFoundationModels reads the seeded catalog, InvokeModel runs the deterministic runtime over a model-native body, and the agent runtime answers RAG calls:
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"}`),
})
// Bedrock Agents: build a knowledge base + agent, then answer a RAG query.
kb, _ := aws.BedrockAgent.CreateKnowledgeBase(ctx, /* KnowledgeBaseConfig */)
ans, _ := aws.BedrockAgentRuntime.RetrieveAndGenerate(ctx, /* RetrieveAndGenerateInput */)On the Azure side, azure.AI provisions AI Services accounts and model deployments, then serves inference:
acct, _ := azure.AI.CreateAccount(ctx, /* AccountConfig */) // Microsoft.CognitiveServices/accounts
dep, _ := azure.AI.CreateDeployment(ctx, /* DeploymentConfig */) // gpt-4o, text-embedding-3-*, …Behavior & fidelity#
| Behavior | What happens |
|---|---|
| Deterministic runtime | Invoke and converse echo your input inside the model-family response envelope with whitespace-based token counts, so assertions stay stable across runs. |
| Deterministic embeddings | Bedrock embedding models return fixed-dimension vectors seeded by input length, and Azure OpenAI completions and embeddings behave the same way. |
| No streaming method | The Bedrock driver exposes synchronous invoke and converse plus async invocation, but no driver-level response-streaming call. |
| Streaming synthesized at the wire | The SDK-compat server serves the streaming endpoints by chunking the deterministic output — a real event stream over a non-token-by-token payload. |
| Agents are store-and-serve | Bedrock Agents persist agents, knowledge bases, and flows, and answer retrieval-augmented queries against that state. |
| Azure OpenAI is ARM-then-data-plane | An ARM create returns the resource inline with a terminal provisioning state, so the SDK LRO poller terminates on the first response. |
| Automatic metrics | Azure OpenAI usage pushes to Azure Monitor via SetMonitoring. |
| Seeded Bedrock model families | Anthropic Claude, Amazon Titan, Meta Llama, Cohere Command, plus Titan embeddings. |
SDK-compat — Live#
Real bedrock, bedrock-agent, and Azure OpenAI (armcognitiveservices + azopenai) clients drive it end-to-end:
| Provider | Coverage |
|---|---|
| AWS Bedrock | Foundation models, guardrails, provisioned throughput, invocation logging, invoke/converse runtime |
| AWS Bedrock Agents | Agents, knowledge bases, data sources, flows, prompts, retrieval runtime |
| Azure OpenAI | AI Services accounts, model deployments, AI Foundry projects, chat/completions/embeddings, Assistants |
See SDK-Compat for the full per-operation list.