Skip to content
cloudemu
Services

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.

ProviderServiceSDK-compatDriver
AWSBedrock (control plane + bedrock-runtime)✓ Liveaws.Bedrock
AWSBedrock Agents (bedrock-agent + bedrock-agent-runtime)✓ Liveaws.BedrockAgent / aws.BedrockAgentRuntime
AzureAzure OpenAI / AI Services (Microsoft.CognitiveServices)✓ Liveazure.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#

BehaviorWhat happens
Deterministic runtimeInvoke and converse echo your input inside the model-family response envelope with whitespace-based token counts, so assertions stay stable across runs.
Deterministic embeddingsBedrock embedding models return fixed-dimension vectors seeded by input length, and Azure OpenAI completions and embeddings behave the same way.
No streaming methodThe Bedrock driver exposes synchronous invoke and converse plus async invocation, but no driver-level response-streaming call.
Streaming synthesized at the wireThe 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-serveBedrock Agents persist agents, knowledge bases, and flows, and answer retrieval-augmented queries against that state.
Azure OpenAI is ARM-then-data-planeAn ARM create returns the resource inline with a terminal provisioning state, so the SDK LRO poller terminates on the first response.
Automatic metricsAzure OpenAI usage pushes to Azure Monitor via SetMonitoring.
Seeded Bedrock model familiesAnthropic 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:

ProviderCoverage
AWS BedrockFoundation models, guardrails, provisioned throughput, invocation logging, invoke/converse runtime
AWS Bedrock AgentsAgents, knowledge bases, data sources, flows, prompts, retrieval runtime
Azure OpenAIAI Services accounts, model deployments, AI Foundry projects, chat/completions/embeddings, Assistants

See SDK-Compat for the full per-operation list.

On this page

On this page