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
1 change: 1 addition & 0 deletions packages/instrumentation-openai/src/attrs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ATTR_GEN_AI_REQUEST_REASONING_EFFORT = "gen_ai.request.reasoning_effort";
8 changes: 8 additions & 0 deletions packages/instrumentation-openai/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { encodingForModel, TiktokenModel, Tiktoken } from "js-tiktoken";
type APIPromiseType<T> = Promise<T> & {
_thenUnwrap: <U>(onFulfilled: (value: T) => U) => APIPromiseType<U>;
};
import { ATTR_GEN_AI_REQUEST_REASONING_EFFORT } from "./attrs";
import {
wrapImageGeneration,
wrapImageEdit,
Expand Down Expand Up @@ -333,6 +334,13 @@ export class OpenAIInstrumentation extends InstrumentationBase {
attributes[SpanAttributes.LLM_PRESENCE_PENALTY] =
params.presence_penalty;
}
if ("reasoning_effort" in params) {
if (typeof params.reasoning_effort === "string") {
attributes[ATTR_GEN_AI_REQUEST_REASONING_EFFORT] = params.reasoning_effort;
} else {
attributes[ATTR_GEN_AI_REQUEST_REASONING_EFFORT] = JSON.stringify(params.reasoning_effort);
}
}

if (
params.extraAttributes !== undefined &&
Expand Down