Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

feat(typescript): add Transformers.js local HuggingFace inference auto-instrumentation (#1299)

Goutham-Annemc0d425d081b6
diff --git a/docs/latest/sdk/integrations/huggingface.mdx b/docs/latest/sdk/integrations/huggingface.mdx
index fd4abe8b..93c43fdc 100644
--- a/docs/latest/sdk/integrations/huggingface.mdx
+++ b/docs/latest/sdk/integrations/huggingface.mdx
@@ -10,8 +10,54 @@ OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applicat
Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.
The integration is compatible with
-- HuggingFace Trasnformers Python SDK client `>= 4.48.0`
-- OpenLIT Typescript SDK `>= 1.0.0`
+- HuggingFace Transformers Python SDK client `>= 4.48.0`
+- HuggingFace Inference TypeScript SDK (`@huggingface/inference`) `>= 2.0.0`
+- Transformers.js (`@huggingface/transformers` `>= 3` or `@xenova/transformers`) for local inference
+
+## Supported APIs
+
+| SDK | Instrumented surface | Inference type |
+|-----|----------------------|----------------|
+| **Python** | `TextGenerationPipeline.__call__` | Local (transformers) |
+| **TypeScript** | `@huggingface/inference` chat completions | Remote (Inference API) |
+| **TypeScript** | Transformers.js pipeline calls (`@huggingface/transformers` / `@xenova/transformers`) | Local |
+
+Local text-generation is reported as the `chat` operation to match the Python SDK. Other local Transformers.js pipelines (summarization, translation, fill-mask, question-answering, classification) are reported as `text_completion`, and feature-extraction / sentence-similarity as `embeddings`.
+
+## Prerequisites
+
+- Install the HuggingFace SDK yourself. OpenLIT does not bundle it as a dependency.
+- For TypeScript, call `openlit.init()` **before** the HuggingFace module is first loaded so OpenTelemetry can hook into the SDK at runtime.
+
+## TypeScript example (local Transformers.js)
+
+```typescript
+import openlit from "openlit";
+
+openlit.init({ otlpEndpoint: "YOUR_OTEL_ENDPOINT" });
+
+import { pipeline } from "@huggingface/transformers";
+
+const generator = await pipeline("text-generation", "Xenova/distilgpt2");
+const output = await generator("OpenTelemetry makes observability", {
+ max_new_tokens: 32,
+ temperature: 0.7,
+});
+```
+
+## Configuration
+
+| Option | Behavior |
+|--------|----------|
+| `captureMessageContent` | Gates `gen_ai.input.messages` / `gen_ai.output.messages` on spans and in events |
+| `disableEvents` | Suppresses all inference events |
+| `disableMetrics` | Global — metrics instruments are not set up |
+| `disabledInstrumentors: ['transformers']` | Disables the local Transformers.js instrumentation |
+| `disabledInstrumentors: ['huggingface']` | Disables the remote Inference API instrumentation |
+
+<Note>
+On the Python SDK, inference events are only emitted when `capture_message_content` is enabled. On the TypeScript SDK, inference events are emitted when `disableEvents` is `false`, regardless of `captureMessageContent` (message fields within the event are still gated by content capture).
+</Note>
## Get started
@@ -27,7 +73,12 @@ The integration is compatible with
<Tab title="Typescript">
```shell
npm install openlit
+ # Remote Inference API
+ npm install @huggingface/inference
+ # or local inference with Transformers.js
+ npm install @huggingface/transformers
```
+ The older `@xenova/transformers` package is also supported for local inference.
</Tab>
</Tabs>
</Step>
diff --git a/sdk/typescript/README.md b/sdk/typescript/README.md
index 823e5125..786bd013 100644
--- a/sdk/typescript/README.md
+++ b/sdk/typescript/README.md
@@ -44,7 +44,7 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
| [✅ Together AI](https://docs.openlit.io/latest/integrations/together) |
| [✅ Ollama](https://docs.openlit.io/latest/integrations/ollama) |
| [✅ AWS Bedrock](https://docs.openlit.io/latest/integrations/bedrock) |
-| [✅ Hugging Face](https://docs.openlit.io/latest/integrations/huggingface) |
+| [✅ Hugging Face](https://docs.openlit.io/latest/integrations/huggingface) *(Inference API + local Transformers.js)* |
| [✅ Replicate](https://docs.openlit.io/latest/integrations/replicate) |
| [✅ Azure OpenAI](https://docs.openlit.io/latest/integrations/azure-openai) *(via OpenAI SDK)* |
diff --git a/sdk/typescript/src/instrumentation/__tests__/transformers-trace-comparison.test.ts b/sdk/typescript/src/instrumentation/__tests__/transformers-trace-comparison.test.ts
new file mode 100644
index 00000000..5cff54c5
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/__tests__/transformers-trace-comparison.test.ts
@@ -0,0 +1,284 @@
+/**
+ * Cross-Language Trace Comparison Tests for local HuggingFace inference
+ * (Transformers.js) instrumentation.
+ *
+ * Verifies that the TypeScript SDK produces traces consistent with the Python
+ * `transformers` instrumentation and the OTel GenAI semantic conventions:
+ * - text-generation reports the `chat` operation (Python parity)
+ * - other local pipelines map to the closest OTel operation
+ * - token usage, cache tokens, timing, and package version are stamped
+ */
+
+import TransformersWrapper from '../transformers/wrapper';
+import OpenlitConfig from '../../config';
+import OpenLitHelper from '../../helpers';
+import BaseWrapper from '../base-wrapper';
+import SemanticConvention from '../../semantic-convention';
+
+jest.mock('../../config');
+jest.mock('../../helpers');
+jest.mock('../base-wrapper');
+
+describe('Transformers.js Cross-Language Trace Comparison', () => {
+ let mockSpan: any;
+ let mockTracer: any;
+
+ const makeInstance = (task: string, model = 'Xenova/distilgpt2') => ({
+ task,
+ model: { config: { _name_or_path: model } },
+ });
+
+ beforeEach(() => {
+ mockSpan = {
+ setAttribute: jest.fn(),
+ addEvent: jest.fn(),
+ end: jest.fn(),
+ setStatus: jest.fn(),
+ };
+
+ mockTracer = {
+ startSpan: jest.fn().mockReturnValue(mockSpan),
+ };
+
+ (OpenlitConfig as any).environment = 'openlit-testing';
+ (OpenlitConfig as any).applicationName = 'openlit-test';
+ (OpenlitConfig as any).captureMessageContent = true;
+ (OpenlitConfig as any).pricingInfo = {};
+ (OpenlitConfig as any).disableEvents = false;
+
+ (OpenLitHelper as any).getChatModelCost = jest.fn().mockReturnValue(0.0);
+ (OpenLitHelper as any).generalTokens = jest.fn().mockReturnValue(7);
+ (OpenLitHelper as any).buildInputMessages = jest.fn().mockReturnValue('[{"role":"user"}]');
+ (OpenLitHelper as any).buildOutputMessages = jest.fn().mockReturnValue('[{"role":"assistant"}]');
+ (OpenLitHelper as any).handleException = jest.fn();
+ (OpenLitHelper as any).emitInferenceEvent = jest.fn();
+ (OpenLitHelper as any).computeAgentVersionHash = jest.fn().mockReturnValue('');
+
+ (BaseWrapper as any).recordMetrics = jest.fn();
+ (BaseWrapper as any).setBaseSpanAttributes = jest.fn().mockImplementation((span: any, attrs: any) => {
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL, attrs.aiSystem);
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MODEL, attrs.model);
+ if (attrs.cost !== undefined) span.setAttribute(SemanticConvention.GEN_AI_USAGE_COST, attrs.cost);
+ // setBaseSpanAttributes stamps OpenLIT's SDK version; the wrapper must
+ // override it with the transformers package version afterwards.
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, 'openlit-sdk-version');
+ });
+ });
+
+ afterEach(() => {
+ jest.clearAllMocks();
+ });
+
+ // ── Span creation ──────────────────────────────────────────────────────────
+
+ describe('Span creation', () => {
+ it('creates a "chat {model}" span for text-generation (Python parity)', async () => {
+ const patched = TransformersWrapper._patchPipelineCall(mockTracer, 'TextGenerationPipeline', '3.0.0');
+ const original = jest.fn().mockResolvedValue([{ generated_text: 'hello world' }]);
+ const wrapped = patched(original);
+
+ await wrapped.call(makeInstance('text-generation'), 'say hi', { temperature: 0.7 });
+
+ expect(mockTracer.startSpan).toHaveBeenCalledWith(
+ 'chat Xenova/distilgpt2',
+ expect.objectContaining({
+ attributes: expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE,
+ [SemanticConvention.SERVER_ADDRESS]: '127.0.0.1',
+ [SemanticConvention.SERVER_PORT]: 80,
+ }),
+ }),
+ expect.anything()
+ );
+ });
+
+ it('maps summarization to the text_completion operation', async () => {
+ const patched = TransformersWrapper._patchPipelineCall(mockTracer, 'SummarizationPipeline');
+ const original = jest.fn().mockResolvedValue([{ summary_text: 'short' }]);
+ const wrapped = patched(original);
+
+ await wrapped.call(makeInstance('summarization'), 'a long text', {});
+
+ expect(mockTracer.startSpan).toHaveBeenCalledWith(
+ 'text_completion Xenova/distilgpt2',
+ expect.objectContaining({
+ attributes: expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION,
+ }),
+ }),
+ expect.anything()
+ );
+ });
+
+ it('maps feature-extraction to the embeddings operation', async () => {
+ const patched = TransformersWrapper._patchPipelineCall(mockTracer, 'FeatureExtractionPipeline');
+ const original = jest.fn().mockResolvedValue({ data: [0.1, 0.2] });
+ const wrapped = patched(original);
+
+ await wrapped.call(makeInstance('feature-extraction'), 'embed me', {});
+
+ expect(mockTracer.startSpan).toHaveBeenCalledWith(
+ 'embeddings Xenova/distilgpt2',
+ expect.objectContaining({
+ attributes: expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ }),
+ }),
+ expect.anything()
+ );
+ });
+ });
+
+ // ── Attribute parity ─────────────────────────────────────────────────────────
+
+ describe('Span attributes (Python parity)', () => {
+ const callTextGen = async (sdkVersion?: string) => {
+ const patched = TransformersWrapper._patchPipelineCall(mockTracer, 'TextGenerationPipeline', sdkVersion);
+ const original = jest.fn().mockResolvedValue([{ generated_text: 'the answer is 42' }]);
+ const wrapped = patched(original);
+ await wrapped.call(makeInstance('text-generation'), 'question', {
+ temperature: 0.5,
+ top_k: 40,
+ top_p: 0.9,
+ max_new_tokens: 64,
+ });
+ };
+
+ it('stamps token usage including client.token.usage and cache tokens (0)', async () => {
+ await callTextGen();
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, 7);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 7);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, 14);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, 0);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, 0);
+ });
+
+ it('always stamps TTFT and TBT', async () => {
+ await callTextGen();
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_SERVER_TTFT, expect.any(Number));
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_SERVER_TBT, 0);
+ });
+
+ it('stamps gen_ai.system and request params', async () => {
+ await callTextGen();
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_PROVIDER_NAME, 'huggingface');
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 0.5);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TOP_K, 40);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_TOP_P, 0.9);
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 64);
+ });
+
+ it('overrides gen_ai.sdk.version with the transformers package version', async () => {
+ await callTextGen('3.2.1');
+ // The last write to GEN_AI_SDK_VERSION must be the package version, not OpenLIT's.
+ const versionCalls = mockSpan.setAttribute.mock.calls.filter(
+ (c: any[]) => c[0] === SemanticConvention.GEN_AI_SDK_VERSION
+ );
+ expect(versionCalls[versionCalls.length - 1][1]).toBe('3.2.1');
+ });
+
+ it('sets text output type and finish reason for generative tasks', async () => {
+ await callTextGen();
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_OUTPUT_TYPE,
+ SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT
+ );
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
+ });
+ });
+
+ describe('Embedding tasks', () => {
+ it('does not set output messages or finish reason and reports 0 output tokens', async () => {
+ const patched = TransformersWrapper._patchPipelineCall(mockTracer, 'FeatureExtractionPipeline');
+ const original = jest.fn().mockResolvedValue({ data: [0.1, 0.2, 0.3] });
+ const wrapped = patched(original);
+
+ await wrapped.call(makeInstance('feature-extraction'), 'embed me', {});
+
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, 0);
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
+ expect.anything()
+ );
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_OUTPUT_MESSAGES,
+ expect.anything()
+ );
+ });
+ });
+
+ // ── Content capture & events ─────────────────────────────────────────────────
+
+ describe('Content capture and events', () => {
+ it('captures input/output messages only when enabled', async () => {
+ (OpenlitConfig as any).captureMessageContent = false;
+ const patched = TransformersWrapper._patchPipelineCall(mockTracer, 'TextGenerationPipeline');
+ const original = jest.fn().mockResolvedValue([{ generated_text: 'hi' }]);
+ await patched(original).call(makeInstance('text-generation'), 'in', {});
+
+ expect(mockSpan.setAttribute).not.toHaveBeenCalledWith(
+ SemanticConvention.GEN_AI_INPUT_MESSAGES,
+ expect.anything()
+ );
+ });
+
+ it('emits an inference event when events are enabled', async () => {
+ const patched = TransformersWrapper._patchPipelineCall(mockTracer, 'TextGenerationPipeline');
+ const original = jest.fn().mockResolvedValue([{ generated_text: 'hi' }]);
+ await patched(original).call(makeInstance('text-generation'), 'in', {});
+
+ expect(OpenLitHelper.emitInferenceEvent).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({
+ [SemanticConvention.GEN_AI_OPERATION]: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: 'Xenova/distilgpt2',
+ })
+ );
+ });
+ });
+
+ // ── Error path ───────────────────────────────────────────────────────────────
+
+ describe('Error handling', () => {
+ it('records error metrics once, ends the span, and rethrows', async () => {
+ const patched = TransformersWrapper._patchPipelineCall(mockTracer, 'TextGenerationPipeline');
+ const err = new Error('inference failed');
+ const original = jest.fn().mockRejectedValue(err);
+ const wrapped = patched(original);
+
+ await expect(wrapped.call(makeInstance('text-generation'), 'in', {})).rejects.toThrow('inference failed');
+
+ expect(OpenLitHelper.handleException).toHaveBeenCalledWith(mockSpan, err);
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledTimes(1);
+ expect(BaseWrapper.recordMetrics).toHaveBeenCalledWith(
+ mockSpan,
+ expect.objectContaining({ errorType: 'Error' })
+ );
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
+ });
+ });
+
+ // ── Response parsing per task ─────────────────────────────────────────────────
+
+ describe('Response parsing', () => {
+ it('extracts nested chat-message generated_text (text-generation)', async () => {
+ const patched = TransformersWrapper._patchPipelineCall(mockTracer, 'TextGenerationPipeline');
+ const original = jest.fn().mockResolvedValue([
+ { generated_text: [{ role: 'user', content: 'hi' }, { role: 'assistant', content: 'hello there' }] },
+ ]);
+ await patched(original).call(makeInstance('text-generation'), 'hi', {});
+
+ expect(OpenLitHelper.buildOutputMessages).toHaveBeenCalledWith('hello there', 'stop');
+ });
+
+ it('extracts translation_text (translation)', async () => {
+ const patched = TransformersWrapper._patchPipelineCall(mockTracer, 'TranslationPipeline');
+ const original = jest.fn().mockResolvedValue([{ translation_text: 'bonjour' }]);
+ await patched(original).call(makeInstance('translation'), 'hello', {});
+
+ expect(OpenLitHelper.buildOutputMessages).toHaveBeenCalledWith('bonjour', 'stop');
+ });
+ });
+});
diff --git a/sdk/typescript/src/instrumentation/index.ts b/sdk/typescript/src/instrumentation/index.ts
index 8b3cf7f1..74802051 100644
--- a/sdk/typescript/src/instrumentation/index.ts
+++ b/sdk/typescript/src/instrumentation/index.ts
@@ -34,6 +34,7 @@ import AstraInstrumentation from './astra';
import MCPInstrumentation from './mcp';
import Mem0Instrumentation from './mem0';
import ElevenLabsInstrumentation from './elevenlabs';
+import TransformersInstrumentation from './transformers';
/**
* OTel community instrumentations loaded dynamically (like Python SDK).
@@ -110,6 +111,7 @@ export default class Instrumentations {
mcp: new MCPInstrumentation(),
mem0: new Mem0Instrumentation(),
elevenlabs: new ElevenLabsInstrumentation(),
+ transformers: new TransformersInstrumentation(),
};
static setup(
diff --git a/sdk/typescript/src/instrumentation/transformers/index.ts b/sdk/typescript/src/instrumentation/transformers/index.ts
new file mode 100644
index 00000000..2902d95d
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/transformers/index.ts
@@ -0,0 +1,130 @@
+import {
+ InstrumentationBase,
+ InstrumentationModuleDefinition,
+ InstrumentationNodeModuleDefinition,
+ isWrapped,
+} from '@opentelemetry/instrumentation';
+import { InstrumentationConfig } from '@opentelemetry/instrumentation';
+import { diag } from '@opentelemetry/api';
+import { INSTRUMENTATION_PREFIX } from '../../constant';
+import TransformersWrapper from './wrapper';
+
+export interface TransformersInstrumentationConfig extends InstrumentationConfig {}
+
+/**
+ * Instruments local HuggingFace inference via the Transformers.js SDK.
+ *
+ * Supported packages (registered as separate module definitions so either
+ * package name triggers instrumentation):
+ * - `@huggingface/transformers` (current name, v3+)
+ * - `@xenova/transformers` (older name)
+ *
+ * Parity: the Python SDK instruments `transformers.TextGenerationPipeline.__call__`
+ * and reports it as the `chat` operation. Transformers.js implements each
+ * pipeline as a subclass whose `_call` method runs the inference, so we patch
+ * the `_call` of every known pipeline subclass (and the base `Pipeline` as a
+ * final catch). The operation type is resolved at runtime from the pipeline's
+ * `task`, so text-generation matches Python while other local pipelines
+ * (summarization, translation, feature-extraction, …) get the closest OTel
+ * operation.
+ */
+export default class OpenlitTransformersInstrumentation extends InstrumentationBase {
+ constructor(config: TransformersInstrumentationConfig = {}) {
+ super(`${INSTRUMENTATION_PREFIX}/instrumentation-transformers`, '1.0.0', config);
+ }
+
+ protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[] {
+ const makeDef = (packageName: string) =>
+ new InstrumentationNodeModuleDefinition(
+ packageName,
+ ['>=2.0.0'],
+ (moduleExports, moduleVersion) => {
+ this._patch(moduleExports, moduleVersion);
+ return moduleExports;
+ },
+ (moduleExports) => {
+ if (moduleExports !== undefined) {
+ this._unpatch(moduleExports);
+ }
+ }
+ );
+
+ return [makeDef('@huggingface/transformers'), makeDef('@xenova/transformers')];
+ }
+
+ public manualPatch(transformers: any): void {
+ this._patch(transformers);
+ }
+
+ /**
+ * Pipeline subclasses whose `_call` we patch. Most specific first; the base
+ * `Pipeline` is the final fallback. Subclasses that inherit `_call` from an
+ * ancestor in this list are covered by that ancestor's patch (the operation
+ * is resolved from the live instance's `task`, so the span stays correct).
+ */
+ private static readonly PIPELINE_CLASSES = [
+ 'TextGenerationPipeline',
+ 'Text2TextGenerationPipeline',
+ 'SummarizationPipeline',
+ 'TranslationPipeline',
+ 'FillMaskPipeline',
+ 'QuestionAnsweringPipeline',
+ 'TextClassificationPipeline',
+ 'TokenClassificationPipeline',
+ 'ZeroShotClassificationPipeline',
+ 'FeatureExtractionPipeline',
+ 'Pipeline',
+ ];
+
+ protected _patch(moduleExports: any, moduleVersion?: string) {
+ try {
+ const tracer = this.tracer;
+ const sdkVersion = moduleVersion ? String(moduleVersion) : undefined;
+ let patched = false;
+
+ for (const className of OpenlitTransformersInstrumentation.PIPELINE_CLASSES) {
+ const PipelineClass = moduleExports[className];
+ const proto = PipelineClass?.prototype;
+ if (!proto) continue;
+
+ // Only patch a class that defines its OWN `_call`, so each distinct
+ // implementation is wrapped exactly once. Subclasses that inherit
+ // `_call` reuse the ancestor's wrapped method.
+ if (!Object.prototype.hasOwnProperty.call(proto, '_call')) continue;
+ if (typeof proto._call !== 'function') continue;
+ if (isWrapped(proto._call)) {
+ this._unwrap(proto, '_call');
+ }
+ this._wrap(proto, '_call', TransformersWrapper._patchPipelineCall(tracer, className, sdkVersion));
+ patched = true;
+ }
+
+ // Fallback: if no Pipeline subclass exposed `_call` (very old or very new
+ // SDK internals), wrap the `pipeline()` factory instead.
+ if (!patched && typeof moduleExports.pipeline === 'function') {
+ if (!isWrapped(moduleExports.pipeline)) {
+ this._wrap(moduleExports, 'pipeline', TransformersWrapper._patchPipelineFactory(tracer, sdkVersion));
+ }
+ }
+ } catch (e) {
+ diag.error('transformers instrumentation: error in _patch method', e);
+ }
+ }
+
+ protected _unpatch(moduleExports: any) {
+ try {
+ for (const className of OpenlitTransformersInstrumentation.PIPELINE_CLASSES) {
+ const proto = moduleExports[className]?.prototype;
+ if (!proto) continue;
+ if (Object.prototype.hasOwnProperty.call(proto, '_call') && isWrapped(proto._call)) {
+ this._unwrap(proto, '_call');
+ }
+ }
+ if (isWrapped(moduleExports.pipeline)) {
+ this._unwrap(moduleExports, 'pipeline');
+ }
+ } catch (e) {
+ diag.error('transformers instrumentation: error in _unpatch method', e);
+ }
+ }
+}
diff --git a/sdk/typescript/src/instrumentation/transformers/wrapper.ts b/sdk/typescript/src/instrumentation/transformers/wrapper.ts
new file mode 100644
index 00000000..c4109201
--- /dev/null
+++ b/sdk/typescript/src/instrumentation/transformers/wrapper.ts
@@ -0,0 +1,528 @@
+import { Span, SpanKind, Tracer, context, trace, Attributes } from '@opentelemetry/api';
+import OpenlitConfig from '../../config';
+import OpenLitHelper, {
+ isFrameworkLlmActive,
+ getFrameworkParentContext,
+ getCurrentAgentVersion,
+} from '../../helpers';
+import SemanticConvention from '../../semantic-convention';
+import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
+
+/**
+ * Classification of a Transformers.js task into an OTel GenAI operation.
+ *
+ * Parity note: the Python SDK instruments only `TextGenerationPipeline` and
+ * reports it as the `chat` operation. We keep that exact mapping for
+ * text-generation and extend the TS SDK to the remaining local pipeline
+ * types (Option B) using the closest OTel operation for each.
+ */
+interface TaskClass {
+ operation: string;
+ isEmbedding: boolean;
+}
+
+const TASK_OPERATION: Record<string, TaskClass> = {
+ // Generative chat-style (Python parity)
+ 'text-generation': { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, isEmbedding: false },
+ // Sequence-to-sequence / extractive text producers
+ 'text2text-generation': { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
+ summarization: { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
+ translation: { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
+ 'fill-mask': { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
+ 'question-answering': { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
+ 'text-classification': { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
+ 'token-classification': { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
+ 'zero-shot-classification': { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
+ // Embedding producers
+ 'feature-extraction': { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING, isEmbedding: true },
+ 'sentence-similarity': { operation: SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING, isEmbedding: true },
+};
+
+/** Map a Pipeline subclass name to its canonical Transformers.js task string. */
+const CLASS_TASK: Record<string, string> = {
+ TextGenerationPipeline: 'text-generation',
+ Text2TextGenerationPipeline: 'text2text-generation',
+ SummarizationPipeline: 'summarization',
+ TranslationPipeline: 'translation',
+ FillMaskPipeline: 'fill-mask',
+ QuestionAnsweringPipeline: 'question-answering',
+ TextClassificationPipeline: 'text-classification',
+ TokenClassificationPipeline: 'token-classification',
+ ZeroShotClassificationPipeline: 'zero-shot-classification',
+ FeatureExtractionPipeline: 'feature-extraction',
+};
+
+function resolveTask(instance: any, className: string): string {
+ return (
+ (typeof instance?.task === 'string' && instance.task) ||
+ CLASS_TASK[className] ||
+ 'text-generation'
+ );
+}
+
+function classifyTask(task: string): TaskClass {
+ return (
+ TASK_OPERATION[task] || {
+ operation: SemanticConvention.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION,
+ isEmbedding: false,
+ }
+ );
+}
+
+/**
+ * Resolve the model identifier from a pipeline instance, mirroring Python's
+ * `instance.model.config.name_or_path`. HF configs expose the path under a few
+ * keys across versions, so we probe the common ones before falling back.
+ */
+function resolveModel(instance: any): string {
+ const config = instance?.model?.config ?? {};
+ return (
+ config._name_or_path ||
+ config.name_or_path ||
+ config.model_type ||
+ instance?.model?.name_or_path ||
+ (typeof instance?.task === 'string' ? instance.task : '') ||
+ 'unknown'
+ );
+}
+
+/**
+ * Extract the generation parameters for a call, mirroring Python which reads
+ * `instance._forward_params` (set at pipeline construction) merged with the
+ * call-time options object.
+ */
+function resolveGenerationParams(instance: any, options: any): {
+ temperature: number | null;
+ topK: number | null;
+ topP: number | null;
+ maxTokens: number | null;
+} {
+ const forward = instance?._forward_params ?? {};
+ const opts = options ?? {};
+ const pick = (key: string, altKey?: string) =>
+ opts[key] ?? (altKey ? opts[altKey] : undefined) ?? forward[key] ?? (altKey ? forward[altKey] : undefined) ?? null;
+
+ return {
+ temperature: pick('temperature'),
+ topK: pick('top_k'),
+ topP: pick('top_p'),
+ maxTokens: pick('max_new_tokens', 'max_length'),
+ };
+}
+
+/**
+ * Convert a Transformers.js pipeline result into a flat text string per task,
+ * mirroring the task branches in Python's `process_chat_response`.
+ */
+function extractCompletion(task: string, response: any): string {
+ const first = Array.isArray(response) ? response[0] : response;
+
+ const fromEntry = (entry: any): string => {
+ if (entry === null || entry === undefined) return '';
+ if (typeof entry !== 'object') return String(entry);
+ // text-generation may nest a chat-message list under generated_text
+ if (Array.isArray(entry.generated_text)) {
+ const last = entry.generated_text[entry.generated_text.length - 1];
+ return last?.content ?? String(last ?? '');
+ }
+ return (
+ entry.generated_text ??
+ entry.summary_text ??
+ entry.translation_text ??
+ entry.answer ??
+ entry.sequence ??
+ entry.token_str ??
+ entry.label ??
+ entry.text ??
+ ''
+ );
+ };
+
+ switch (task) {
+ case 'automatic-speech-recognition':
+ return typeof response === 'object' && response !== null ? response.text ?? '' : '';
+ case 'feature-extraction':
+ case 'sentence-similarity':
+ return '';
+ default: {
+ const out = fromEntry(first);
+ if (out) return out;
+ // Fall back to a stable serialization for unknown shapes.
+ try {
+ return typeof response === 'string' ? response : JSON.stringify(response);
+ } catch {
+ return String(response ?? '');
+ }
+ }
+ }
+}
+
+function stringifyInputs(inputs: any): string {
+ if (typeof inputs === 'string') return inputs;
+ if (Array.isArray(inputs)) {
+ return inputs
+ .map((i) => (typeof i === 'string' ? i : i?.content ?? JSON.stringify(i)))
+ .join('\n');
+ }
+ if (inputs && typeof inputs === 'object') {
+ // question-answering style { question, context }
+ if (typeof inputs.question === 'string') {
+ return inputs.context
+ ? `question: ${inputs.question} context: ${inputs.context}`
+ : inputs.question;
+ }
+ try {
+ return JSON.stringify(inputs);
+ } catch {
+ return String(inputs);
+ }
+ }
+ return String(inputs ?? '');
+}
+
+class TransformersWrapper extends BaseWrapper {
+ static aiSystem = SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE;
+ static serverAddress = '127.0.0.1';
+ static serverPort = 80;
+
+ /**
+ * Stamp `openlit.agent.version_hash` (auto) and `gen_ai.agent.version`
+ * (user override) on the span and return them so the caller can merge them
+ * into the inference-event extras.
+ */
+ static _stampAgentVersion(
+ span: Span,
+ args: {
+ systemInstructionsJson?: string | null;
+ primaryModel?: string;
+ temperature?: number | null;
+ top_p?: number | null;
+ max_tokens?: number | null;
+ }
+ ): Record<string, string> {
+ const out: Record<string, string> = {};
+ try {
+ const versionHash = OpenLitHelper.computeAgentVersionHash({
+ systemInstructions: args.systemInstructionsJson ?? null,
+ toolDefinitions: null,
+ primaryModel: args.primaryModel ?? null,
+ runtimeConfig: {
+ temperature: args.temperature ?? null,
+ top_p: args.top_p ?? null,
+ max_tokens: args.max_tokens ?? null,
+ provider: SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE,
+ },
+ providers: [SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE],
+ });
+ if (versionHash) {
+ out[SemanticConvention.OPENLIT_AGENT_VERSION_HASH] = versionHash;
+ span.setAttribute(SemanticConvention.OPENLIT_AGENT_VERSION_HASH, versionHash);
+ }
+ } catch {
+ /* Hash computation must never fail the wrapped call. */
+ }
+ const versionLabel = getCurrentAgentVersion();
+ if (versionLabel) {
+ out[SemanticConvention.GEN_AI_AGENT_VERSION] = versionLabel;
+ span.setAttribute(SemanticConvention.GEN_AI_AGENT_VERSION, versionLabel);
+ }
+ return out;
+ }
+
+ /**
+ * Patch a Pipeline subclass `_call` (the method invoked when the pipeline
+ * object is used as a function). `this` is the pipeline instance.
+ * args[0] = inputs, args[1] = generation options.
+ */
+ static _patchPipelineCall(tracer: Tracer, className: string, sdkVersion?: string): any {
+ return (originalMethod: (...args: any[]) => any) => {
+ return async function (this: any, ...args: any[]) {
+ if (isFrameworkLlmActive()) return originalMethod.apply(this, args);
+
+ const task = resolveTask(this, className);
+ const requestModel = resolveModel(this);
+ const { operation } = classifyTask(task);
+ const genAIEndpoint = `transformers.${task}`;
+ const spanName = `${operation} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(
+ spanName,
+ { kind: SpanKind.CLIENT, attributes: spanCreationAttrs(operation, requestModel) },
+ effectiveCtx
+ );
+
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
+ let metricParams: BaseSpanAttributes | undefined;
+ const startTime = Date.now();
+ try {
+ const response = await originalMethod.apply(this, args);
+ metricParams = TransformersWrapper._handleResponse({
+ instance: this,
+ args,
+ response,
+ span,
+ requestModel,
+ task,
+ operation,
+ genAIEndpoint,
+ ttft: (Date.now() - startTime) / 1000,
+ sdkVersion,
+ });
+ return response;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: TransformersWrapper.aiSystem,
+ serverAddress: TransformersWrapper.serverAddress,
+ serverPort: TransformersWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
+ throw e;
+ } finally {
+ span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
+ }
+ });
+ };
+ };
+ }
+
+ /**
+ * Patch the `pipeline()` factory as a fallback when no Pipeline subclass
+ * prototype is exported. Wraps the returned callable so each invocation
+ * emits a span. The original callable is invoked directly (not via the
+ * wrapper) so we never lose its prototype behavior.
+ */
+ static _patchPipelineFactory(tracer: Tracer, sdkVersion?: string): any {
+ return (originalFactory: (...args: any[]) => any) => {
+ return async function (this: any, ...factoryArgs: any[]) {
+ const pipe = await originalFactory.apply(this, factoryArgs);
+ if (typeof pipe !== 'function') return pipe;
+
+ const task: string =
+ (typeof factoryArgs[0] === 'string' && factoryArgs[0]) ||
+ (typeof pipe.task === 'string' && pipe.task) ||
+ 'text-generation';
+ const { operation } = classifyTask(task);
+ const genAIEndpoint = `transformers.${task}`;
+
+ const wrappedPipe: any = async function (this: any, ...callArgs: any[]) {
+ if (isFrameworkLlmActive()) return pipe.apply(this, callArgs);
+
+ const requestModel =
+ resolveModel(pipe) ||
+ (typeof factoryArgs[1] === 'string' ? factoryArgs[1] : 'unknown');
+ const spanName = `${operation} ${requestModel}`;
+ const effectiveCtx = getFrameworkParentContext() ?? context.active();
+ const span = tracer.startSpan(
+ spanName,
+ { kind: SpanKind.CLIENT, attributes: spanCreationAttrs(operation, requestModel) },
+ effectiveCtx
+ );
+
+ return context.with(trace.setSpan(effectiveCtx, span), async () => {
+ let metricParams: BaseSpanAttributes | undefined;
+ const startTime = Date.now();
+ try {
+ const response = await pipe.apply(this, callArgs);
+ metricParams = TransformersWrapper._handleResponse({
+ instance: pipe,
+ args: callArgs,
+ response,
+ span,
+ requestModel,
+ task,
+ operation,
+ genAIEndpoint,
+ ttft: (Date.now() - startTime) / 1000,
+ sdkVersion,
+ });
+ return response;
+ } catch (e: any) {
+ OpenLitHelper.handleException(span, e);
+ BaseWrapper.recordMetrics(span, {
+ genAIEndpoint,
+ model: requestModel,
+ aiSystem: TransformersWrapper.aiSystem,
+ serverAddress: TransformersWrapper.serverAddress,
+ serverPort: TransformersWrapper.serverPort,
+ errorType: e?.constructor?.name || '_OTHER',
+ });
+ throw e;
+ } finally {
+ span.end();
+ if (metricParams) {
+ BaseWrapper.recordMetrics(span, metricParams);
+ }
+ }
+ });
+ };
+
+ // Preserve callable identity so the wrapped pipe behaves like the original.
+ Object.setPrototypeOf(wrappedPipe, Object.getPrototypeOf(pipe));
+ Object.assign(wrappedPipe, pipe);
+ return wrappedPipe;
+ };
+ };
+ }
+
+ /**
+ * Synchronous attribute setter shared by the class- and factory-patch paths.
+ * Returns the metric params so the caller can record metrics in `finally`.
+ */
+ static _handleResponse({
+ instance,
+ args,
+ response,
+ span,
+ requestModel,
+ task,
+ operation,
+ genAIEndpoint,
+ ttft,
+ sdkVersion,
+ }: {
+ instance: any;
+ args: any[];
+ response: any;
+ span: Span;
+ requestModel: string;
+ task: string;
+ operation: string;
+ genAIEndpoint: string;
+ ttft: number;
+ sdkVersion?: string;
+ }): BaseSpanAttributes {
+ const captureContent = OpenlitConfig.captureMessageContent;
+ const { isEmbedding } = classifyTask(task);
+
+ const inputs = args[0];
+ const options = args[1] || {};
+ const { temperature, topK, topP, maxTokens } = resolveGenerationParams(instance, options);
+
+ const inputStr = stringifyInputs(inputs);
+ const completion = extractCompletion(task, response);
+
+ const inputTokens = OpenLitHelper.generalTokens(inputStr) ?? 0;
+ const outputTokens = isEmbedding ? 0 : OpenLitHelper.generalTokens(completion) ?? 0;
+
+ const pricingInfo = OpenlitConfig.pricingInfo || {};
+ const cost = OpenLitHelper.getChatModelCost(requestModel, pricingInfo, inputTokens, outputTokens);
+
+ // Common attributes (telemetry sdk, env, app, request model, cost, server).
+ TransformersWrapper.setBaseSpanAttributes(span, {
+ genAIEndpoint,
+ model: requestModel,
+ cost,
+ aiSystem: TransformersWrapper.aiSystem,
+ serverAddress: TransformersWrapper.serverAddress,
+ serverPort: TransformersWrapper.serverPort,
+ });
+
+ // Parity: Python stamps gen_ai.system and the transformers package version
+ // (setBaseSpanAttributes uses OpenLIT's SDK version).
+ span.setAttribute(SemanticConvention.GEN_AI_PROVIDER_NAME, TransformersWrapper.aiSystem);
+ if (sdkVersion) {
+ span.setAttribute(SemanticConvention.GEN_AI_SDK_VERSION, sdkVersion);
+ }
+
+ // Request parameters (only when present, matching Python).
+ if (temperature !== null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, temperature);
+ }
+ if (topK !== null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, topK);
+ }
+ if (topP !== null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, topP);
+ }
+ if (maxTokens !== null) {
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, maxTokens);
+ }
+ span.setAttribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, false);
+
+ // Response parameters.
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, requestModel);
+ if (!isEmbedding) {
+ span.setAttribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT);
+ }
+
+ // Tokens, cost, cache (cache stamped as 0 even when unused, like Python).
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, inputTokens + outputTokens);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, 0);
+ span.setAttribute(SemanticConvention.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, 0);
+
+ // Timing (Python always sets these; tbt is 0 for non-streaming pipelines).
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft);
+ span.setAttribute(SemanticConvention.GEN_AI_SERVER_TBT, 0);
+
+ const versionExtras = TransformersWrapper._stampAgentVersion(span, {
+ systemInstructionsJson: null,
+ primaryModel: requestModel,
+ temperature,
+ top_p: topP,
+ max_tokens: maxTokens,
+ });
+
+ let inputMessagesJson: string | undefined;
+ let outputMessagesJson: string | undefined;
+ if (captureContent) {
+ inputMessagesJson = OpenLitHelper.buildInputMessages([{ role: 'user', content: inputStr }]);
+ span.setAttribute(SemanticConvention.GEN_AI_INPUT_MESSAGES, inputMessagesJson);
+ if (!isEmbedding) {
+ outputMessagesJson = OpenLitHelper.buildOutputMessages(completion, 'stop');
+ span.setAttribute(SemanticConvention.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
+ }
+ }
+
+ if (!OpenlitConfig.disableEvents) {
+ const eventAttrs: Attributes = {
+ [SemanticConvention.GEN_AI_OPERATION]: operation,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.GEN_AI_RESPONSE_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: TransformersWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: TransformersWrapper.serverPort,
+ [SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
+ [SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
+ ...versionExtras,
+ };
+ if (!isEmbedding) {
+ eventAttrs[SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON] = ['stop'];
+ eventAttrs[SemanticConvention.GEN_AI_OUTPUT_TYPE] = SemanticConvention.GEN_AI_OUTPUT_TYPE_TEXT;
+ }
+ if (captureContent) {
+ if (inputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
+ if (outputMessagesJson) eventAttrs[SemanticConvention.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
+ }
+ OpenLitHelper.emitInferenceEvent(span, eventAttrs);
+ }
+
+ return {
+ genAIEndpoint,
+ model: requestModel,
+ cost,
+ aiSystem: TransformersWrapper.aiSystem,
+ serverAddress: TransformersWrapper.serverAddress,
+ serverPort: TransformersWrapper.serverPort,
+ };
+ }
+}
+
+function spanCreationAttrs(operationName: string, requestModel: string): Attributes {
+ return {
+ [SemanticConvention.GEN_AI_OPERATION]: operationName,
+ [SemanticConvention.GEN_AI_PROVIDER_NAME_OTEL]: SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE,
+ [SemanticConvention.GEN_AI_REQUEST_MODEL]: requestModel,
+ [SemanticConvention.SERVER_ADDRESS]: TransformersWrapper.serverAddress,
+ [SemanticConvention.SERVER_PORT]: TransformersWrapper.serverPort,
+ };
+}
+
+export default TransformersWrapper;
diff --git a/sdk/typescript/src/types.ts b/sdk/typescript/src/types.ts
index a5807a31..3ca33794 100644
--- a/sdk/typescript/src/types.ts
+++ b/sdk/typescript/src/types.ts
@@ -3,7 +3,7 @@ import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { metrics } from '@opentelemetry/api';
import type { Guard } from './guard/base';
-export type InstrumentationType = 'openai' | 'anthropic' | 'cohere' | 'groq' | 'mistral' | 'google-ai' | 'vertexai' | 'together' | 'ollama' | 'vercel-ai' | 'langchain' | 'langgraph' | 'pinecone' | 'bedrock' | 'llamaindex' | 'huggingface' | 'replicate' | 'chroma' | 'qdrant' | 'milvus' | 'astra' | 'azure-ai-inference' | 'openai-agents' | 'strands' | 'google-adk' | 'claude-agent-sdk' | 'cursor-sdk' | 'ai21' | 'gradient' | 'mcp' | 'mem0' | 'elevenlabs';
+export type InstrumentationType = 'openai' | 'anthropic' | 'cohere' | 'groq' | 'mistral' | 'google-ai' | 'vertexai' | 'together' | 'ollama' | 'vercel-ai' | 'langchain' | 'langgraph' | 'pinecone' | 'bedrock' | 'llamaindex' | 'huggingface' | 'replicate' | 'chroma' | 'qdrant' | 'milvus' | 'astra' | 'azure-ai-inference' | 'openai-agents' | 'strands' | 'google-adk' | 'claude-agent-sdk' | 'cursor-sdk' | 'ai21' | 'gradient' | 'mcp' | 'mem0' | 'elevenlabs' | 'transformers';
export type OpenlitInstrumentations = Partial<Record<InstrumentationType, any>>;