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
52 changes: 49 additions & 3 deletions packages/ai-semantic-conventions/src/SemanticAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,68 @@
*/

export const SpanAttributes = {
// OpenTelemetry GenAI Semantic Conventions (Current)
// Required attributes
GEN_AI_OPERATION_NAME: "gen_ai.operation.name",
GEN_AI_PROVIDER_NAME: "gen_ai.provider.name",

// Request attributes
GEN_AI_REQUEST_MODEL: "gen_ai.request.model",
GEN_AI_REQUEST_TEMPERATURE: "gen_ai.request.temperature",
GEN_AI_REQUEST_TOP_P: "gen_ai.request.top_p",
GEN_AI_REQUEST_TOP_K: "gen_ai.request.top_k",
GEN_AI_REQUEST_MAX_TOKENS: "gen_ai.request.max_tokens",
GEN_AI_REQUEST_FREQUENCY_PENALTY: "gen_ai.request.frequency_penalty",
GEN_AI_REQUEST_PRESENCE_PENALTY: "gen_ai.request.presence_penalty",
GEN_AI_REQUEST_STOP_SEQUENCES: "gen_ai.request.stop_sequences",

// Response attributes
GEN_AI_RESPONSE_ID: "gen_ai.response.id",
GEN_AI_RESPONSE_MODEL: "gen_ai.response.model",
GEN_AI_RESPONSE_FINISH_REASONS: "gen_ai.response.finish_reasons",

// Token usage (Current OTel naming)
GEN_AI_USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens",
GEN_AI_USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens",

// Messages
GEN_AI_INPUT_MESSAGES: "gen_ai.input.messages",
GEN_AI_OUTPUT_MESSAGES: "gen_ai.output.messages",
GEN_AI_SYSTEM_INSTRUCTIONS: "gen_ai.system_instructions",

// Tool definitions
GEN_AI_TOOL_DEFINITIONS: "gen_ai.tool.definitions",

// Agent attributes
GEN_AI_AGENT_NAME: "gen_ai.agent.name",

// Deprecated attributes (kept for backward compatibility)
/** @deprecated Use GEN_AI_PROVIDER_NAME instead */
LLM_SYSTEM: "gen_ai.system",
/** @deprecated Use GEN_AI_REQUEST_MODEL instead */
LLM_REQUEST_MODEL: "gen_ai.request.model",
/** @deprecated Use GEN_AI_REQUEST_MAX_TOKENS instead */
LLM_REQUEST_MAX_TOKENS: "gen_ai.request.max_tokens",
/** @deprecated Use GEN_AI_REQUEST_TEMPERATURE instead */
LLM_REQUEST_TEMPERATURE: "gen_ai.request.temperature",
/** @deprecated Use GEN_AI_REQUEST_TOP_P instead */
LLM_REQUEST_TOP_P: "gen_ai.request.top_p",
/** @deprecated Use GEN_AI_INPUT_MESSAGES and events instead */
LLM_PROMPTS: "gen_ai.prompt",
/** @deprecated Use GEN_AI_OUTPUT_MESSAGES and events instead */
LLM_COMPLETIONS: "gen_ai.completion",
/** @deprecated Use GEN_AI_INPUT_MESSAGES instead */
LLM_INPUT_MESSAGES: "gen_ai.input.messages",
/** @deprecated Use GEN_AI_OUTPUT_MESSAGES instead */
LLM_OUTPUT_MESSAGES: "gen_ai.output.messages",
/** @deprecated Use GEN_AI_RESPONSE_MODEL instead */
LLM_RESPONSE_MODEL: "gen_ai.response.model",
/** @deprecated Use GEN_AI_USAGE_INPUT_TOKENS instead */
LLM_USAGE_PROMPT_TOKENS: "gen_ai.usage.prompt_tokens",
/** @deprecated Use GEN_AI_USAGE_OUTPUT_TOKENS instead */
LLM_USAGE_COMPLETION_TOKENS: "gen_ai.usage.completion_tokens",

GEN_AI_AGENT_NAME: "gen_ai.agent.name",

// LLM
// LLM (Non-standard attributes)
LLM_REQUEST_TYPE: "llm.request.type",
LLM_USAGE_TOTAL_TOKENS: "llm.usage.total_tokens",
LLM_TOP_K: "llm.top_k",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{
"log": {
"_recordingName": "AI SDK OTel GenAI Semantic Conventions/Backward compatibility/should maintain all deprecated attributes alongside new ones",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.6"
},
"entries": [
{
"_id": "df289a7f0d80329eff9ec2fc92f65890",
"_order": 0,
"cache": {},
"request": {
"bodySize": 146,
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 165,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"model\":\"gpt-3.5-turbo\",\"input\":[{\"role\":\"system\",\"content\":\"You are helpful\"},{\"role\":\"user\",\"content\":[{\"type\":\"input_text\",\"text\":\"Hello\"}]}]}"
},
"queryString": [],
"url": "https://api.openai.com/v1/responses"
},
"response": {
"bodySize": 1473,
"content": {
"mimeType": "application/json",
"size": 1473,
"text": "{\n \"id\": \"resp_0faf8f16567bd63e00691dfb1e71a08195aded450e62456fe5\",\n \"object\": \"response\",\n \"created_at\": 1763572510,\n \"status\": \"completed\",\n \"background\": false,\n \"billing\": {\n \"payer\": \"developer\"\n },\n \"error\": null,\n \"incomplete_details\": null,\n \"instructions\": null,\n \"max_output_tokens\": null,\n \"max_tool_calls\": null,\n \"model\": \"gpt-3.5-turbo-0125\",\n \"output\": [\n {\n \"id\": \"msg_0faf8f16567bd63e00691dfb1eabc88195845a609342cf410b\",\n \"type\": \"message\",\n \"status\": \"completed\",\n \"content\": [\n {\n \"type\": \"output_text\",\n \"annotations\": [],\n \"logprobs\": [],\n \"text\": \"Hello! How can I assist you today?\"\n }\n ],\n \"role\": \"assistant\"\n }\n ],\n \"parallel_tool_calls\": true,\n \"previous_response_id\": null,\n \"prompt_cache_key\": null,\n \"prompt_cache_retention\": null,\n \"reasoning\": {\n \"effort\": null,\n \"summary\": null\n },\n \"safety_identifier\": null,\n \"service_tier\": \"default\",\n \"store\": true,\n \"temperature\": 1.0,\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n },\n \"verbosity\": \"medium\"\n },\n \"tool_choice\": \"auto\",\n \"tools\": [],\n \"top_logprobs\": 0,\n \"top_p\": 1.0,\n \"truncation\": \"disabled\",\n \"usage\": {\n \"input_tokens\": 15,\n \"input_tokens_details\": {\n \"cached_tokens\": 0\n },\n \"output_tokens\": 10,\n \"output_tokens_details\": {\n \"reasoning_tokens\": 0\n },\n \"total_tokens\": 25\n },\n \"user\": null,\n \"metadata\": {}\n}"
},
"cookies": [
{
"domain": ".api.openai.com",
"httpOnly": true,
"name": "_cfuvid",
"path": "/",
"sameSite": "None",
"secure": true,
"value": "yjFQ1AZqezCnRWiCWX31Xdy0VPiTyaz1iSbwhB24PsU-1763572510963-0.0.1.1-604800000"
}
],
"headers": [
{
"name": "alt-svc",
"value": "h3=\":443\"; ma=86400"
},
{
"name": "cf-cache-status",
"value": "DYNAMIC"
},
{
"name": "cf-ray",
"value": "9a11591dab317d98-TLV"
},
{
"name": "connection",
"value": "keep-alive"
},
{
"name": "content-encoding",
"value": "br"
},
{
"name": "content-type",
"value": "application/json"
},
{
"name": "date",
"value": "Wed, 19 Nov 2025 17:15:10 GMT"
},
{
"name": "openai-organization",
"value": "traceloop"
},
{
"name": "openai-processing-ms",
"value": "441"
},
{
"name": "openai-project",
"value": "proj_tzz1TbPPOXaf6j9tEkVUBIAa"
},
{
"name": "openai-version",
"value": "2020-10-01"
},
{
"name": "server",
"value": "cloudflare"
},
{
"name": "set-cookie",
"value": "_cfuvid=yjFQ1AZqezCnRWiCWX31Xdy0VPiTyaz1iSbwhB24PsU-1763572510963-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None"
},
{
"name": "strict-transport-security",
"value": "max-age=31536000; includeSubDomains; preload"
},
{
"name": "transfer-encoding",
"value": "chunked"
},
{
"name": "x-content-type-options",
"value": "nosniff"
},
{
"name": "x-envoy-upstream-service-time",
"value": "445"
},
{
"name": "x-ratelimit-limit-requests",
"value": "10000"
},
{
"name": "x-ratelimit-limit-tokens",
"value": "50000000"
},
{
"name": "x-ratelimit-remaining-requests",
"value": "9999"
},
{
"name": "x-ratelimit-remaining-tokens",
"value": "49999980"
},
{
"name": "x-ratelimit-reset-requests",
"value": "6ms"
},
{
"name": "x-ratelimit-reset-tokens",
"value": "0s"
},
{
"name": "x-request-id",
"value": "req_2c9e9d910e1a4a148bab90e480e0b2d3"
}
],
"headersSize": 953,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2025-11-19T17:15:10.283Z",
"time": 634,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 634
}
}
],
"pages": [],
"version": "1.2"
}
}
Loading
Loading