Hello all. I'm just getting started with Arize tracing, using Bedrock models. I have a little script to try things out, mostly copied from the the doc at https://arize.com/docs/ax/integrations/llm-providers/amazon-bedrock/amazon-bedrock-tracing. I find that calling Bedrock's converse, the input and output are logged as expected. But calling Bedrock's invoke_model, only the input is captured. (Both calls are succeeding -- my script prints out the responses.) What am I missing? I'll paste the script in a thread.
import os
import json
from pprint import pprint
import boto3
use_arize = True
if use_arize:
import arize.otel
from openinference.instrumentation.bedrock import BedrockInstrumentor
arize_space_id = os.getenv("ARIZE_SPACE_ID")
arize_api_key = os.getenv("ARIZE_API_KEY")
tracer_provider = arize.otel.register(
space_id=arize_space_id,
api_key=arize_api_key,
project_name="tom-local",
)
BedrockInstrumentor().instrument(tracer_provider=tracer_provider)
session = boto3.session.Session()
client = session.client("bedrock-runtime")
print("\n\n=== invoke_model with llama-4 ===")
prompt = b'{"prompt": "Human: Tell me about the AWS Bedrock invoke_model method in one sentence. Assistant:"}'
invoke_response = client.invoke_model(
body=prompt,
contentType="application/json",
modelId="us.meta.llama4-maverick-17b-instruct-v1:0",
)
pprint(invoke_response)
invoke_body = json.loads(invoke_response.get("body").read())
pprint(invoke_body)
print("\n\n=== converse with sonnet-4.5 ===")
converse_request = {
"modelId": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
"messages": [
{
"role": "user",
"content": [
{
"text": "Tell me about the AWS Bedrock converse method in one sentence."
}
],
}
],
"inferenceConfig": {"maxTokens": 100},
}
converse_response = client.converse(**converse_request)
pprint(converse_response)And here's what I see at app.arize.com.
Ah, so on first look (I haven't tried it myself yet, but it seems like in the instrumentor code, when it checks for the model type so that it can extract the correct response info, it looks for meta in the first part of the modelId string. However, for meta models, the first part is a region (e.g. us.meta.llama4-maverick-17b-instruct-v1:0). I'll file a ticket for this the openinference library. In the mean time, I think if you try a cohere or anthropic model, it should generate the correct response.
Actually, I think you can just remove the us. from the prefix if you're okay having the model inference run in the region in which you're invoking the call.
Let me know if that unblocks you for now! 馃槃 we can update the documentation to remove the region prefix for now until we make the model response parsing more robust (it varies widely depending on the model provider)
Thanks for looking! No luck though. Without the us. prefix I get this:
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the InvokeModel operation: Invocation of model ID meta.llama4-maverick-17b-instruct-v1:0 with on-demand throughput isn't supported. Retry your request with the ID or ARN of an inference profile that contains this model.I'm not sure if there's an ID that will satisfy both Amazon and the instrumentor here. But this was just meant as a quick test. In production we aioboto3 not boto3, and I've learned that auto-instrumentation doesn't support that, so we'll have to do things manually anyway.
Ah gotcha! looks like you'd have to do a little bit extra or use a different model. But sounds like it won't matter anyway. Using aioboto3 sounds like an interesting possible enhancement. Let me know if I can be of any other help!
