//#region src/semconv.d.ts /** * OpenTelemetry GenAI semantic conventions — canonical constants. * * Source of truth for `gen_ai.*` attribute keys, operation names, provider * names, and span-naming rules, aligned to the OpenTelemetry semantic * conventions. * * Everything here is the canonical underscore namespace (`gen_ai.*`). There is * no legacy `gen.ai.*` / `prompt_tokens` / `completion_tokens` surface — this * package is canonical-only by design. * * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/ */ /** * Canonical `gen_ai.*` attribute keys. * * Grouped by the spec's registry sections. Use these constants instead of * string literals so a future spec rename is a one-line change here. */ declare const GEN_AI: { readonly SERVER_ADDRESS: 'server.address'; readonly SERVER_PORT: 'server.port'; readonly OPERATION_NAME: 'gen_ai.operation.name'; readonly PROVIDER_NAME: 'gen_ai.provider.name'; readonly CONVERSATION_ID: 'gen_ai.conversation.id'; readonly DATA_SOURCE_ID: 'gen_ai.data_source.id'; readonly OUTPUT_TYPE: 'gen_ai.output.type'; readonly REQUEST_MODEL: 'gen_ai.request.model'; readonly REQUEST_MAX_TOKENS: 'gen_ai.request.max_tokens'; readonly REQUEST_TEMPERATURE: 'gen_ai.request.temperature'; readonly REQUEST_TOP_P: 'gen_ai.request.top_p'; readonly REQUEST_TOP_K: 'gen_ai.request.top_k'; readonly REQUEST_FREQUENCY_PENALTY: 'gen_ai.request.frequency_penalty'; readonly REQUEST_PRESENCE_PENALTY: 'gen_ai.request.presence_penalty'; readonly REQUEST_STOP_SEQUENCES: 'gen_ai.request.stop_sequences'; readonly REQUEST_SEED: 'gen_ai.request.seed'; readonly REQUEST_STREAM: 'gen_ai.request.stream'; readonly REQUEST_CHOICE_COUNT: 'gen_ai.request.choice.count'; readonly REQUEST_ENCODING_FORMATS: 'gen_ai.request.encoding_formats'; readonly RESPONSE_MODEL: 'gen_ai.response.model'; readonly RESPONSE_ID: 'gen_ai.response.id'; readonly RESPONSE_FINISH_REASONS: 'gen_ai.response.finish_reasons'; readonly RESPONSE_TIME_TO_FIRST_CHUNK: 'gen_ai.response.time_to_first_chunk'; readonly USAGE_INPUT_TOKENS: 'gen_ai.usage.input_tokens'; readonly USAGE_OUTPUT_TOKENS: 'gen_ai.usage.output_tokens'; readonly USAGE_REASONING_OUTPUT_TOKENS: 'gen_ai.usage.reasoning.output_tokens'; readonly USAGE_CACHE_READ_INPUT_TOKENS: 'gen_ai.usage.cache_read.input_tokens'; readonly USAGE_CACHE_WRITE_INPUT_TOKENS: 'gen_ai.usage.cache_write.input_tokens'; readonly TOKEN_TYPE: 'gen_ai.token.type'; readonly INPUT_MESSAGES: 'gen_ai.input.messages'; readonly OUTPUT_MESSAGES: 'gen_ai.output.messages'; readonly SYSTEM_INSTRUCTIONS: 'gen_ai.system_instructions'; readonly AGENT_ID: 'gen_ai.agent.id'; readonly AGENT_NAME: 'gen_ai.agent.name'; readonly AGENT_VERSION: 'gen_ai.agent.version'; readonly AGENT_DESCRIPTION: 'gen_ai.agent.description'; readonly TOOL_NAME: 'gen_ai.tool.name'; readonly TOOL_TYPE: 'gen_ai.tool.type'; readonly TOOL_DESCRIPTION: 'gen_ai.tool.description'; readonly TOOL_CALL_ID: 'gen_ai.tool.call.id'; readonly TOOL_CALL_ARGUMENTS: 'gen_ai.tool.call.arguments'; readonly TOOL_CALL_RESULT: 'gen_ai.tool.call.result'; readonly TOOL_DEFINITIONS: 'gen_ai.tool.definitions'; readonly WORKFLOW_NAME: 'gen_ai.workflow.name'; readonly PROMPT_NAME: 'gen_ai.prompt.name'; /** * Version of the named prompt this call ran (autotel extension). Without it a * change in cost, latency or evaluation score cannot be attributed to the * prompt edit that caused it — the whole point of naming the prompt. */ readonly PROMPT_VERSION: 'gen_ai.prompt.version'; /** Moving label the version was resolved through, e.g. `production` (autotel extension). */ readonly PROMPT_LABEL: 'gen_ai.prompt.label'; /** * Digest of the rendered prompt template (autotel extension). Identifies the * exact text where there is no registry to give it a version. */ readonly PROMPT_HASH: 'gen_ai.prompt.hash'; readonly EMBEDDINGS_DIMENSION_COUNT: 'gen_ai.embeddings.dimension.count'; readonly RETRIEVAL_TOP_K: 'gen_ai.retrieval.top_k'; readonly RETRIEVAL_QUERY_TEXT: 'gen_ai.retrieval.query.text'; readonly RETRIEVAL_DOCUMENTS: 'gen_ai.retrieval.documents'; readonly MEMORY_STORE_ID: 'gen_ai.memory.store.id'; readonly MEMORY_RECORD_ID: 'gen_ai.memory.record.id'; readonly MEMORY_RECORD_COUNT: 'gen_ai.memory.record.count'; readonly MEMORY_QUERY_TEXT: 'gen_ai.memory.query.text'; readonly MEMORY_RECORDS: 'gen_ai.memory.records'; readonly EVALUATION_NAME: 'gen_ai.evaluation.name'; readonly EVALUATION_SCORE_VALUE: 'gen_ai.evaluation.score.value'; readonly EVALUATION_SCORE_LABEL: 'gen_ai.evaluation.score.label'; readonly EVALUATION_EXPLANATION: 'gen_ai.evaluation.explanation'; /** * Estimated USD cost for the call. NOT an OpenTelemetry attribute; an autotel * convenience derived from token usage and the prices the caller registered. Kept under * the `gen_ai.usage.*` prefix so it sits beside the spec usage attributes. */ readonly USAGE_COST_USD: 'gen_ai.usage.cost.usd'; /** * The model id no pricing entry matched, set instead of a cost. An absent * cost and a zero cost look the same to a dashboard and to a cost ceiling; * this says which model needs a price before either can be trusted. */ readonly USAGE_COST_UNPRICED_MODEL: 'gen_ai.usage.cost.unpriced_model'; /** * The `asOf` date of the price that produced {@link GEN_AI.USAGE_COST_USD}, * when the caller's price carries one. A cost from a stale price looks like * any other without it. */ readonly USAGE_COST_PRICE_AS_OF: 'gen_ai.usage.cost.price_as_of'; /** * Server-side tools the call used that no price table covers, so their charge * is missing from the cost. A web search or code-interpreter session is real * money billed outside the token counts; without this a cost that excludes * them is indistinguishable from one that has nothing to exclude. */ readonly USAGE_COST_UNPRICED_TOOLS: 'gen_ai.usage.cost.unpriced_tools'; /** * The same number under the name the ecosystem converged on before the spec * covered cost at all. OpenLLMetry writes it, and Langfuse, among others, * reads it to populate its cost column. Emitted alongside * {@link GEN_AI.USAGE_COST_USD} so a backend finds the cost under whichever * name it knows, and neither is load-bearing for the other. */ readonly USAGE_COST: 'gen_ai.usage.cost'; readonly SESSION_COST_USD: 'gen_ai.session.cost.usd'; readonly SESSION_INPUT_TOKENS: 'gen_ai.session.input_tokens'; readonly SESSION_OUTPUT_TOKENS: 'gen_ai.session.output_tokens'; readonly SESSION_STEP_COUNT: 'gen_ai.session.step.count'; readonly SESSION_TOOL_CALL_COUNT: 'gen_ai.session.tool_call.count'; readonly SESSION_ERROR_COUNT: 'gen_ai.session.error.count'; readonly GUARD_RULE: 'gen_ai.guard.rule'; readonly GUARD_ACTION: 'gen_ai.guard.action'; readonly GUARD_MESSAGE: 'gen_ai.guard.message'; readonly GUARD_OBSERVED: 'gen_ai.guard.observed'; readonly GUARD_LIMIT: 'gen_ai.guard.limit'; readonly GUARD_STOPPED: 'gen_ai.guard.stopped'; /** Seconds from request start to the final streamed chunk. */ readonly RESPONSE_TIME_TO_FINISH: 'gen_ai.response.time_to_finish'; /** Output tokens divided by total response time (tokens/second). */ readonly RESPONSE_OUTPUT_TOKENS_PER_SECOND: 'gen_ai.response.output_tokens_per_second'; /** Mean seconds between streamed output chunks. */ readonly RESPONSE_TIME_PER_OUTPUT_CHUNK: 'gen_ai.response.time_per_output_chunk'; }; /** * Suffix on a content attribute naming its UTF-8 byte size before truncation * (autotel extension). Set only when content was actually cut, so its presence * is the signal: `gen_ai.output.messages.original_size = 4_100_000` says the * span holds a prefix, and how much of one. */ declare const CONTENT_ORIGINAL_SIZE_SUFFIX = ".original_size"; /** Union of every canonical `gen_ai.*` attribute key. */ type GenAiAttributeKey = (typeof GEN_AI)[keyof typeof GEN_AI]; /** * `gen_ai.operation.name` values. Determines span name and which attributes are * required. The `*_memory*` set is included for completeness with v1.42.0. */ declare const GEN_AI_OPERATION: { readonly CHAT: 'chat'; readonly GENERATE_CONTENT: 'generate_content'; readonly TEXT_COMPLETION: 'text_completion'; readonly EMBEDDINGS: 'embeddings'; readonly RETRIEVAL: 'retrieval'; readonly CREATE_AGENT: 'create_agent'; readonly INVOKE_AGENT: 'invoke_agent'; readonly EXECUTE_TOOL: 'execute_tool'; readonly INVOKE_WORKFLOW: 'invoke_workflow'; readonly PLAN: 'plan'; readonly SEARCH_MEMORY: 'search_memory'; readonly CREATE_MEMORY: 'create_memory'; readonly UPDATE_MEMORY: 'update_memory'; readonly UPSERT_MEMORY: 'upsert_memory'; readonly DELETE_MEMORY: 'delete_memory'; readonly CREATE_MEMORY_STORE: 'create_memory_store'; readonly DELETE_MEMORY_STORE: 'delete_memory_store'; }; type GenAiOperationName = (typeof GEN_AI_OPERATION)[keyof typeof GEN_AI_OPERATION]; /** * Well-known `gen_ai.provider.name` values (v1.42.0). The attribute is an open * enum — any string is valid — but prefer these for the listed vendors so * dashboards group consistently. */ declare const GEN_AI_PROVIDER: { readonly OPENAI: 'openai'; readonly ANTHROPIC: 'anthropic'; readonly AWS_BEDROCK: 'aws.bedrock'; readonly AZURE_AI_INFERENCE: 'azure.ai.inference'; readonly AZURE_AI_OPENAI: 'azure.ai.openai'; readonly COHERE: 'cohere'; readonly DEEPSEEK: 'deepseek'; readonly GCP_GEMINI: 'gcp.gemini'; readonly GCP_GEN_AI: 'gcp.gen_ai'; readonly GCP_VERTEX_AI: 'gcp.vertex_ai'; readonly GROQ: 'groq'; readonly IBM_WATSONX_AI: 'ibm.watsonx.ai'; readonly MISTRAL_AI: 'mistral_ai'; readonly MOONSHOT_AI: 'moonshot_ai'; readonly PERPLEXITY: 'perplexity'; readonly X_AI: 'x_ai'; }; /** A well-known provider value, or any other vendor string. */ type GenAiProviderName = (typeof GEN_AI_PROVIDER)[keyof typeof GEN_AI_PROVIDER] | (string & {}); /** `gen_ai.token.type` values (metric dimension). */ declare const GEN_AI_TOKEN_TYPE: { readonly INPUT: 'input'; readonly OUTPUT: 'output'; }; type GenAiTokenType = (typeof GEN_AI_TOKEN_TYPE)[keyof typeof GEN_AI_TOKEN_TYPE]; /** `gen_ai.output.type` values. */ declare const GEN_AI_OUTPUT_TYPE: { readonly TEXT: 'text'; readonly JSON: 'json'; readonly IMAGE: 'image'; readonly SPEECH: 'speech'; }; type GenAiOutputType = (typeof GEN_AI_OUTPUT_TYPE)[keyof typeof GEN_AI_OUTPUT_TYPE]; /** `gen_ai.tool.type` values. */ declare const GEN_AI_TOOL_TYPE: { readonly FUNCTION: 'function'; readonly EXTENSION: 'extension'; readonly DATASTORE: 'datastore'; }; type GenAiToolType = (typeof GEN_AI_TOOL_TYPE)[keyof typeof GEN_AI_TOOL_TYPE]; /** Canonical client metric instrument names (histograms). */ declare const GEN_AI_METRIC: { readonly TOKEN_USAGE: 'gen_ai.client.token.usage'; readonly OPERATION_DURATION: 'gen_ai.client.operation.duration'; readonly TIME_TO_FIRST_CHUNK: 'gen_ai.client.operation.time_to_first_chunk'; readonly TIME_PER_OUTPUT_CHUNK: 'gen_ai.client.operation.time_per_output_chunk'; readonly INVOKE_WORKFLOW_DURATION: 'gen_ai.invoke_workflow.duration'; /** Autotel extension — the spec publishes no cost metric. */ readonly COST_USD: 'gen_ai.client.cost.usd'; }; /** Canonical event names from the GenAI semantic conventions snapshot. */ declare const GEN_AI_EVENT: { readonly INFERENCE_OPERATION_DETAILS: 'gen_ai.client.inference.operation.details'; readonly EVALUATION_RESULT: 'gen_ai.evaluation.result'; readonly CLIENT_OPERATION_EXCEPTION: 'gen_ai.client.operation.exception'; }; /** * Guard / budget event names (autotel extension — not part of the published * GenAI spec). Emitted by the `./guard` runtime when a rule crosses a warn or * stop threshold during an in-process agent run. */ declare const GEN_AI_GUARD_EVENT: { /** A `warn`-action rule crossed its threshold; the run continues. */ readonly WARNING: 'gen_ai.guard.warning'; /** A `stop`-action rule crossed its threshold; the run is halted. */ readonly STOP: 'gen_ai.guard.stop'; }; /** * Event names that are autotel extensions (not in the published GenAI spec). */ declare const GEN_AI_EXT_EVENT: { /** * Provider warnings surfaced for a call (e.g. an unsupported setting silently * dropped). Vendors and the AI SDK only log these; recording them keeps the * signal in your traces. */ readonly CLIENT_WARNINGS: 'gen_ai.client.warnings'; }; /** * Compute the span name once you've already picked the canonical identifier for * the operation. Upstream rules vary by operation: inference uses * `request.model`, retrieval uses `data_source.id`, tools use `tool.name`, * agents use `agent.name`, workflows use `workflow.name`, and memory spans * often have no trailing identifier at all. * * @example * ```ts * genAiSpanName('chat', 'gpt-4o'); // 'chat gpt-4o' * genAiSpanName('execute_tool', 'get_weather'); // 'execute_tool get_weather' * genAiSpanName('invoke_agent'); // 'invoke_agent' * ``` */ declare function genAiSpanName(operation: GenAiOperationName | (string & {}), identifier?: string | undefined): string; //#endregion export { GenAiToolType as _, GEN_AI_GUARD_EVENT as a, GEN_AI_OUTPUT_TYPE as c, GEN_AI_TOOL_TYPE as d, GenAiAttributeKey as f, GenAiTokenType as g, GenAiProviderName as h, GEN_AI_EXT_EVENT as i, GEN_AI_PROVIDER as l, GenAiOutputType as m, GEN_AI as n, GEN_AI_METRIC as o, GenAiOperationName as p, GEN_AI_EVENT as r, GEN_AI_OPERATION as s, CONTENT_ORIGINAL_SIZE_SUFFIX as t, GEN_AI_TOKEN_TYPE as u, genAiSpanName as v };