openinference

openinference-semantic-conventions (Go)

Attribute keys and value constants for OpenInference span kinds, messages, tools, embeddings, retrieval, cost/token counts, and prompts — the Go port of openinference-semantic-conventions (Python) / openinference-semantic-conventions (Java / JS).

Exported as plain string constants so they work directly with go.opentelemetry.io/otel/attribute helpers.

Install

go get github.com/Arize-ai/openinference/go/openinference-semantic-conventions@latest

Requires Go 1.25+.

Use

import (
    "go.opentelemetry.io/otel/attribute"

    semconv "github.com/Arize-ai/openinference/go/openinference-semantic-conventions"
)

span.SetAttributes(
    attribute.String(semconv.OpenInferenceSpanKind, semconv.SpanKindLLM),
    attribute.String(semconv.LLMModelName, "gpt-4o"),
    attribute.String(semconv.LLMProvider, semconv.LLMProviderOpenAI),
)

Indexed attributes (array-valued, like message lists) are produced by helper functions:

span.SetAttributes(
    attribute.String(semconv.LLMInputMessageRoleKey(0), "system"),
    attribute.String(semconv.LLMInputMessageContentKey(0), "You are a helpful assistant."),
    attribute.String(semconv.LLMInputMessageRoleKey(1), "user"),
    attribute.String(semconv.LLMInputMessageContentKey(1), userInput),
    attribute.Int(semconv.LLMTokenCountPrompt, 42),
)

Send the trace to Arize AX or Phoenix

This package is exporter-agnostic — pair it with whatever OTel exporter your runtime needs:

For LLM clients with first-party auto-instrumentation, use openinference-instrumentation-openai-go (when available) or openinference-instrumentation-anthropic-sdk-go (when available) — they call into this package automatically.

Drift policy

The Python package is the source of truth. New attribute keys MUST be added to python/openinference-semantic-conventions/ first, then ported here. Two layers catch drift in CI: