Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strands-media-attachments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"braintrust": minor
---

feat(strands): Log inline document, image, and video bytes as Braintrust attachments.
5 changes: 5 additions & 0 deletions e2e/helpers/media-fixtures.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const MINIMAL_PNG_BASE64 =
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==";

export const MINIMAL_PDF_BASE64 =
"JVBERi0xLjAKMSAwIG9iago8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFI+PmVuZG9iagoyIDAgb2JqCjw8L1R5cGUvUGFnZXMvS2lkc1szIDAgUl0vQ291bnQgMT4+ZW5kb2JqCjMgMCBvYmoKPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCA2MTIgNzkyXT4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZg0KMDAwMDAwMDAxMCAwMDAwMCBuDQowMDAwMDAwMDUzIDAwMDAwIG4NCjAwMDAwMDAxMDIgMDAwMDAgbg0KdHJhaWxlcgo8PC9TaXplIDQvUm9vdCAxIDAgUj4+CnN0YXJ0eHJlZgoxNDkKJUVPRg==";
12 changes: 6 additions & 6 deletions e2e/scenarios/openai-instrumentation/scenario.impl.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
MINIMAL_PDF_BASE64,
MINIMAL_PNG_BASE64,
} from "../../helpers/media-fixtures.mjs";
import {
collectAsync,
runOperation,
Expand All @@ -9,10 +13,6 @@ const EMBEDDING_MODEL = "text-embedding-3-small";
const MODERATION_MODEL = "omni-moderation-2024-09-26";
const ROOT_NAME = "openai-instrumentation-root";
const SCENARIO_NAME = "openai-instrumentation";
const BASE64_IMAGE =
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==";
const BASE64_PDF =
"JVBERi0xLjAKMSAwIG9iago8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFI+PmVuZG9iagoyIDAgb2JqCjw8L1R5cGUvUGFnZXMvS2lkc1szIDAgUl0vQ291bnQgMT4+ZW5kb2JqCjMgMCBvYmoKPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCA2MTIgNzkyXT4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZg0KMDAwMDAwMDAxMCAwMDAwMCBuDQowMDAwMDAwMDUzIDAwMDAwIG4NCjAwMDAwMDAxMDIgMDAwMDAgbg0KdHJhaWxlcgo8PC9TaXplIDQvUm9vdCAxIDAgUj4+CnN0YXJ0eHJlZgoxNDkKJUVPRg==";
const CHAT_TOOLS = [
{
type: "function",
Expand Down Expand Up @@ -212,7 +212,7 @@ export async function runOpenAIInstrumentationScenario(options) {
{
type: "image_url",
image_url: {
url: `data:image/png;base64,${BASE64_IMAGE}`,
url: `data:image/png;base64,${MINIMAL_PNG_BASE64}`,
},
},
],
Expand Down Expand Up @@ -241,7 +241,7 @@ export async function runOpenAIInstrumentationScenario(options) {
{
type: "file",
file: {
file_data: `data:application/pdf;base64,${BASE64_PDF}`,
file_data: `data:application/pdf;base64,${MINIMAL_PDF_BASE64}`,
filename: "document.pdf",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,186 @@
},
{
"callIndex": 2,
"id": "c07157ac5ff242e3",
"matchKey": "POST api.openai.com/v1/chat/completions",
"recordedAt": "2026-07-13T20:21:32.098Z",
"request": {
"body": {
"kind": "json",
"value": {
"max_completion_tokens": 160,
"messages": [
{
"content": "Reply exactly STRANDS_DOCUMENT_OK.",
"role": "system"
},
{
"content": [
{
"file": {
"file_data": "data:application/pdf;base64,JVBERi0xLjAKMSAwIG9iago8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFI+PmVuZG9iagoyIDAgb2JqCjw8L1R5cGUvUGFnZXMvS2lkc1szIDAgUl0vQ291bnQgMT4+ZW5kb2JqCjMgMCBvYmoKPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCA2MTIgNzkyXT4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZg0KMDAwMDAwMDAxMCAwMDAwMCBuDQowMDAwMDAwMDUzIDAwMDAwIG4NCjAwMDAwMDAxMDIgMDAwMDAgbg0KdHJhaWxlcgo8PC9TaXplIDQvUm9vdCAxIDAgUj4+CnN0YXJ0eHJlZgoxNDkKJUVPRg==",
"filename": "strands-regression.pdf"
},
"type": "file"
},
{
"text": "Reply exactly STRANDS_DOCUMENT_OK.",
"type": "text"
}
],
"role": "user"
}
],
"model": "gpt-4o-mini-2024-07-18",
"stream": true,
"stream_options": {
"include_usage": true
},
"temperature": 0
}
},
"headers": {},
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions"
},
"response": {
"body": {
"chunks": [
"data: {\"id\":\"chatcmpl-E1HRbNm3TLJJtzCmkg21mrSv8eVB7\",\"object\":\"chat.completion.chunk\",\"created\":1783974091,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\",\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"hAJ7zY0Pc\"}",
"data: {\"id\":\"chatcmpl-E1HRbNm3TLJJtzCmkg21mrSv8eVB7\",\"object\":\"chat.completion.chunk\",\"created\":1783974091,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"STR\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"5OvUWL5U\"}",
"data: {\"id\":\"chatcmpl-E1HRbNm3TLJJtzCmkg21mrSv8eVB7\",\"object\":\"chat.completion.chunk\",\"created\":1783974091,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"ANDS\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"FReEmTU\"}",
"data: {\"id\":\"chatcmpl-E1HRbNm3TLJJtzCmkg21mrSv8eVB7\",\"object\":\"chat.completion.chunk\",\"created\":1783974091,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"_DOCUMENT\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"k1\"}",
"data: {\"id\":\"chatcmpl-E1HRbNm3TLJJtzCmkg21mrSv8eVB7\",\"object\":\"chat.completion.chunk\",\"created\":1783974091,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"_OK\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"0eg8ZOnh\"}",
"data: {\"id\":\"chatcmpl-E1HRbNm3TLJJtzCmkg21mrSv8eVB7\",\"object\":\"chat.completion.chunk\",\"created\":1783974091,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"ghLMrXZfdd\"}",
"data: {\"id\":\"chatcmpl-E1HRbNm3TLJJtzCmkg21mrSv8eVB7\",\"object\":\"chat.completion.chunk\",\"created\":1783974091,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}],\"usage\":null,\"obfuscation\":\"HwqVb\"}",
"data: {\"id\":\"chatcmpl-E1HRbNm3TLJJtzCmkg21mrSv8eVB7\",\"object\":\"chat.completion.chunk\",\"created\":1783974091,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[],\"usage\":{\"prompt_tokens\":247,\"completion_tokens\":5,\"total_tokens\":252,\"prompt_tokens_details\":{\"cached_tokens\":0,\"audio_tokens\":0},\"completion_tokens_details\":{\"reasoning_tokens\":0,\"audio_tokens\":0,\"accepted_prediction_tokens\":0,\"rejected_prediction_tokens\":0}},\"obfuscation\":\"ITw3NBS0a\"}",
"data: [DONE]"
],
"kind": "sse"
},
"headers": {
"access-control-expose-headers": "X-Request-ID, CF-Ray, CF-Ray",
"alt-svc": "h3=\":443\"; ma=86400",
"cf-cache-status": "DYNAMIC",
"cf-ray": "a1aafe97ee6dc45b-YYZ",
"connection": "keep-alive",
"content-type": "text/event-stream; charset=utf-8",
"date": "Mon, 13 Jul 2026 20:21:32 GMT",
"openai-organization": "braintrust-data",
"openai-processing-ms": "423",
"openai-project": "proj_vsCSXafhhByzWOThMrJcZiw9",
"openai-version": "2020-10-01",
"server": "cloudflare",
"set-cookie": "[REDACTED]",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-openai-proxy-wasm": "v0.1",
"x-ratelimit-limit-requests": "30000",
"x-ratelimit-limit-tokens": "150000000",
"x-ratelimit-remaining-requests": "29999",
"x-ratelimit-remaining-tokens": "149999215",
"x-ratelimit-reset-requests": "2ms",
"x-ratelimit-reset-tokens": "0s",
"x-request-id": "req_3c5f893b9d4f48df88f0b20dafe5b21b"
},
"status": 200,
"statusText": "OK"
}
},
{
"callIndex": 3,
"id": "ad37817153d52151",
"matchKey": "POST api.openai.com/v1/chat/completions",
"recordedAt": "2026-07-13T20:21:32.722Z",
"request": {
"body": {
"kind": "json",
"value": {
"max_completion_tokens": 160,
"messages": [
{
"content": "Reply exactly STRANDS_IMAGE_OK.",
"role": "system"
},
{
"content": [
{
"image_url": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg=="
},
"type": "image_url"
},
{
"text": "Reply exactly STRANDS_IMAGE_OK.",
"type": "text"
}
],
"role": "user"
}
],
"model": "gpt-4o-mini-2024-07-18",
"stream": true,
"stream_options": {
"include_usage": true
},
"temperature": 0
}
},
"headers": {},
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions"
},
"response": {
"body": {
"chunks": [
"data: {\"id\":\"chatcmpl-E1HRcrILLgMUPTLS9F8d4RCGqbUWw\",\"object\":\"chat.completion.chunk\",\"created\":1783974092,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\",\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"8ncoAeH8n\"}",
"data: {\"id\":\"chatcmpl-E1HRcrILLgMUPTLS9F8d4RCGqbUWw\",\"object\":\"chat.completion.chunk\",\"created\":1783974092,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"STR\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"X1oUdVnz\"}",
"data: {\"id\":\"chatcmpl-E1HRcrILLgMUPTLS9F8d4RCGqbUWw\",\"object\":\"chat.completion.chunk\",\"created\":1783974092,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"ANDS\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Essg5i5\"}",
"data: {\"id\":\"chatcmpl-E1HRcrILLgMUPTLS9F8d4RCGqbUWw\",\"object\":\"chat.completion.chunk\",\"created\":1783974092,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"_IMAGE\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"5Uffg\"}",
"data: {\"id\":\"chatcmpl-E1HRcrILLgMUPTLS9F8d4RCGqbUWw\",\"object\":\"chat.completion.chunk\",\"created\":1783974092,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"_OK\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"YZberS3E\"}",
"data: {\"id\":\"chatcmpl-E1HRcrILLgMUPTLS9F8d4RCGqbUWw\",\"object\":\"chat.completion.chunk\",\"created\":1783974092,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"IQjxpJsARl\"}",
"data: {\"id\":\"chatcmpl-E1HRcrILLgMUPTLS9F8d4RCGqbUWw\",\"object\":\"chat.completion.chunk\",\"created\":1783974092,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}],\"usage\":null,\"obfuscation\":\"N6B0z\"}",
"data: {\"id\":\"chatcmpl-E1HRcrILLgMUPTLS9F8d4RCGqbUWw\",\"object\":\"chat.completion.chunk\",\"created\":1783974092,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_844ddd95ff\",\"choices\":[],\"usage\":{\"prompt_tokens\":8525,\"completion_tokens\":5,\"total_tokens\":8530,\"prompt_tokens_details\":{\"cached_tokens\":0,\"audio_tokens\":0},\"completion_tokens_details\":{\"reasoning_tokens\":0,\"audio_tokens\":0,\"accepted_prediction_tokens\":0,\"rejected_prediction_tokens\":0}},\"obfuscation\":\"JW6tDUJ\"}",
"data: [DONE]"
],
"kind": "sse"
},
"headers": {
"access-control-expose-headers": "X-Request-ID, CF-Ray, CF-Ray",
"alt-svc": "h3=\":443\"; ma=86400",
"cf-cache-status": "DYNAMIC",
"cf-ray": "a1aafe9c2bd4c45b-YYZ",
"connection": "keep-alive",
"content-type": "text/event-stream; charset=utf-8",
"date": "Mon, 13 Jul 2026 20:21:32 GMT",
"openai-organization": "braintrust-data",
"openai-processing-ms": "452",
"openai-project": "proj_vsCSXafhhByzWOThMrJcZiw9",
"openai-version": "2020-10-01",
"server": "cloudflare",
"set-cookie": "[REDACTED]",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-openai-proxy-wasm": "v0.1",
"x-ratelimit-limit-input-images": "50000",
"x-ratelimit-limit-requests": "30000",
"x-ratelimit-limit-tokens": "150000000",
"x-ratelimit-remaining-input-images": "49999",
"x-ratelimit-remaining-requests": "29999",
"x-ratelimit-remaining-tokens": "149999217",
"x-ratelimit-reset-input-images": "1ms",
"x-ratelimit-reset-requests": "2ms",
"x-ratelimit-reset-tokens": "0s",
"x-request-id": "req_68698c61c0e24e598828c1b4b51d7792"
},
"status": 200,
"statusText": "OK"
}
},
{
"callIndex": 4,
"id": "7f682068be947c96",
"matchKey": "POST api.openai.com/v1/chat/completions",
"recordedAt": "2026-06-18T14:20:00.867Z",
Expand Down Expand Up @@ -304,7 +484,7 @@
}
},
{
"callIndex": 3,
"callIndex": 5,
"id": "f1affedbdb5d1da0",
"matchKey": "POST api.openai.com/v1/chat/completions",
"recordedAt": "2026-06-18T14:20:01.798Z",
Expand Down Expand Up @@ -385,7 +565,7 @@
}
},
{
"callIndex": 4,
"callIndex": 6,
"id": "da2ccaeedff7ef8b",
"matchKey": "POST api.openai.com/v1/chat/completions",
"recordedAt": "2026-06-18T14:20:02.321Z",
Expand Down Expand Up @@ -474,7 +654,7 @@
}
},
{
"callIndex": 5,
"callIndex": 7,
"id": "bb7637a47f479eeb",
"matchKey": "POST api.openai.com/v1/chat/completions",
"recordedAt": "2026-06-18T14:20:03.435Z",
Expand Down Expand Up @@ -604,7 +784,7 @@
}
},
{
"callIndex": 6,
"callIndex": 8,
"id": "85b37d48b99f35cb",
"matchKey": "POST api.openai.com/v1/chat/completions",
"recordedAt": "2026-06-18T14:20:04.202Z",
Expand Down
Loading
Loading