Skip to main content
The runLocal() method lets you execute prompts directly against OpenAI, Anthropic, Google, or Amazon Bedrock while keeping your prompts in your codebase. You get full observability through Tracia without any added latency.

Why runLocal()?

Some teams prefer managing prompts in their codebase rather than in an external dashboard. This keeps prompts:
  • Version-controlled with your application code
  • Reviewed through your standard PR process
  • Deployed alongside the code that uses them
  • Constructed programmatically when needed
runLocal() gives you full Tracia observability while respecting this workflow.

How It Works

When you call runLocal(), the SDK:
  1. Calls the provider SDK directly - Your request goes straight to OpenAI, Anthropic, Google, or Amazon Bedrock using their native SDK. Tracia is not in the request path.
  2. Sends the trace asynchronously - After the LLM responds, trace data is sent to Tracia in the background. This is non-blocking and adds zero latency to your application.

When to Use runLocal() vs prompts.run()

Use runLocal() when you want to:
  • Keep prompts in your codebase, version-controlled with git
  • Build prompts programmatically (e.g., assembling messages based on context)
  • Prototype quickly without dashboard setup
  • Use Tracia purely for observability
Use prompts.run() when you want to:
  • Edit prompts without code deployments
  • A/B test prompt versions from the dashboard
  • Let non-engineers manage prompt content
  • Track prompt versions separately from code versions

Quick Examples

Available Methods

Basic Usage

Getting started with each provider

Streaming

Real-time streaming responses

Sessions

Automatic trace chaining for multi-turn

Parameters

Complete RunLocalInput reference

Response

RunLocalResult fields and usage

Providers

OpenAI, Anthropic, Google, Bedrock setup

Models

94+ supported models by provider

Variables

Template interpolation syntax

Tracing

Background traces, flush(), error handling

Responses API

OpenAI reasoning models (o1, o3-mini)

Advanced

Error handling, concurrent requests

Types

LLMProvider

RunLocalInput

RunLocalResult

LocalStream

When stream: true is set, runLocal() returns a LocalStream:

LocalPromptMessage