Metadata
Governed model calls are traced automatically. Metadata adds application labels and groups related calls into sessions. User attribution has an authenticated default; you can also supply your application's end-user ID.
What metadata is
Metadata is a set of your own key-value pairs, attached to a call at the time it is made. Forgebench does not interpret most of what you send; it is recorded and made available for filtering exactly as sent. A small number of keys are treated specially because they drive a particular view in Forgebench rather than acting as a plain filter.
What is already attached, without you sending anything
Alongside anything you send yourself, Forgebench writes a further set of information onto governed-call traces automatically. Authenticated agent, actor, key, and audit IDs come from the server. Your application labels and end-user IDs do not change those identities or grant access to trace content:
| Field | What it is |
|---|---|
agent_id | Which agent made the call, when it was made by an agent rather than a direct API call. |
actor | The identity of the person or service account that authenticated the call. |
audit_id | The entry in the audit log for this exact call. |
api_key_prefix | The non-secret, displayable prefix of the API key used to make the call (for example, sk_ab12...), never the key itself, which Forgebench never stores in a recoverable form. |
requested_model | The model requested, useful when a fallback model ended up serving the call instead. |
latency_ms | The true time the call took at the gateway. |
user_id | The Users grouping. By default, your account email, identity ID, or key prefix identifies the caller. Deployments with agent attribution group agent calls by agent ID. An explicit end-user ID can replace this grouping without changing the authenticated actor. |
Sending metadata
Metadata is sent as a metadata.dimensions object alongside the rest of the
call. Each entry in it becomes both a filter you can search on later and part
of the permanent record of that call.
from forgebench import Forgebench
client = Forgebench(api_key="sk_...", base_url="https://api.forgebench.ai")
resp = client.chat.completions.create(
model="mock-gpt",
messages=[{"role": "user", "content": "Hello"}],
extra_body={
"metadata": {
"dimensions": {
"feature": "checkout-assistant",
"session": "conv_8f21",
"customer": "acct_4471",
}
}
},
)import { Forgebench } from "@seedlinglabs/forgebench-sdk";
const forgebench = new Forgebench({ apiKey: "sk_...", baseUrl: "https://api.forgebench.ai" });
const res = await forgebench.chat.create({
model: "mock-gpt",
messages: [{ role: "user", content: "Hello" }],
metadata: {
dimensions: {
feature: "checkout-assistant",
session: "conv_8f21",
customer: "acct_4471",
},
},
});import ai.forgebench.ChatCompletionRequest;
import ai.forgebench.ChatMessage;
import ai.forgebench.Forgebench;
import ai.forgebench.types.ChatCompletion;
import java.util.Map;
Forgebench client = Forgebench.builder().apiKey("sk_...").baseUrl("https://api.forgebench.ai").build();
ChatCompletion resp = client.chat().completions().create(ChatCompletionRequest.builder()
.model("mock-gpt")
.addMessage(ChatMessage.user("Hello"))
.extraBody(Map.of(
"metadata", Map.of(
"dimensions", Map.of(
"feature", "checkout-assistant",
"session", "conv_8f21",
"customer", "acct_4471"))))
.build());curl -X POST https://api.forgebench.ai/v1/chat/completions \
-H "Authorization: Bearer sk_..." \
-H "Content-Type: application/json" \
-d '{
"model": "mock-gpt",
"messages": [{"role": "user", "content": "Hello"}],
"metadata": {
"dimensions": {
"feature": "checkout-assistant",
"session": "conv_8f21",
"customer": "acct_4471"
}
}
}'The TypeScript SDK declares metadata, dimensions, user, session_id, and
tags on ChatCompletionRequest. Its dimensions convenience field is merged
into metadata.dimensions. The API also accepts top-level user for your
end-user ID and session_id for a conversation. SDK trace-level user and session
fields can be set with the tracing helpers.
Dimensions with special meaning
| Key | What it does |
|---|---|
dimensions.feature | Names the call, in place of the generic default. Use this to tell apart different kinds of calls your application makes, such as checkout-assistant versus order-lookup. |
dimensions.session | Groups every call sharing the same value into one session. See Sessions for the full picture. |
dimensions.school | Also sets the trace's environment field, after environment-name validation. |
Any other key is your own choice, and is recorded as a plain, searchable
filter, for example dimensions.customer. Reserved attribution keys are ignored.
Limits
| Limit | Value |
|---|---|
| Keys per call | 8 |
| Key format | 1–40 characters, starting with a letter, followed by lowercase letters, numbers, underscores, or hyphens. Keys are trimmed and lowercased. |
| Reserved keys | tenant, agent, key, run, tenant_id, agent_feature, server_feature |
| Value length | 128 characters, beyond which the value is shortened |
Only the first eight valid, nonempty dimensions are kept. Null and empty values are ignored. Dimensions are retained as identifiers for filtering, so use opaque IDs rather than secrets or personal data.

