Factory for creating OpenAI runners (chat completion and agent).

A single factory shares one OpenAI client across all runners it produces so connection pooling and instrumentation are preserved.

Hierarchy

  • AIProvider
    • OpenAIRunnerFactory

Constructors

Properties

_client: OpenAI
_logger?: LDLogger

Methods

  • Create an agent runner from an agent AI configuration.

    The returned runner uses the OpenAI Agents SDK (@openai/agents) which manages its own OpenAI client internally.

    Parameters

    • config: LDAIAgentConfig

      The LaunchDarkly AI agent configuration. Tool definitions are sourced from config.tools.

    • Optional tools: ToolRegistry

      Registry mapping tool names to their callable implementations or pre-built openai-agents tool instances. Tool names referenced by the config that are not present here will be logged and skipped.

      Optional

    Returns Promise<OpenAIAgentRunner>

  • Create an AgentGraphRunner for an agent graph definition.

    Override in provider subclasses to return a configured AgentGraphRunner. Default implementation returns undefined.

    Parameters

    • _graphDef: AgentGraphDefinition
    • Optional _tools: ToolRegistry
      Optional

    Returns Promise<undefined | AgentGraphRunner>

    Promise resolving to an AgentGraphRunner, or undefined if this provider does not support graph execution.

  • Create a model runner from a completion AI configuration.

    Parameters

    • config: LDAICompletionConfig

      The completion (or judge) AI configuration.

    • multiTurn: boolean = true

      Whether the runner should accumulate conversation history across successive run() calls. Defaults to true (chat semantics). Pass false for stateless runners such as judges.

    Returns Promise<OpenAIModelRunner>

  • Automatically patches the ESM openai module for OpenTelemetry tracing when a TracerProvider is active and @traceloop/instrumentation-openai is installed.

    Parameters

    • Optional logger: LDLogger
      Optional

    Returns Promise<void>

Generated using TypeDoc