runLocal() method lets you execute prompts directly against OpenAI, Anthropic, or Google 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 callrunLocal(), the SDK:
- Calls the provider SDK directly - Your request goes straight to OpenAI, Anthropic, or Google using their native SDK. Tracia is not in the request path.
- 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.
prompts.run() | runLocal() | |
|---|---|---|
| Prompts stored in | Tracia dashboard | Your codebase |
| LLM call routed through | Tracia API | Direct to provider SDK |
| Trace creation | Automatic (server-side) | Async, non-blocking |
When to Use runLocal() vs prompts.run()
UserunLocal() 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
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
| Use Case | Recommended Method |
|---|---|
| Prompts managed in Tracia dashboard | prompts.run() |
| Prompts defined in code | runLocal() |
| Prompts reviewed in PRs | runLocal() |
| Quick prototyping | runLocal() |
| A/B testing prompt versions | prompts.run() |
| Programmatically constructed prompts | runLocal() |
| Non-technical prompt editors | prompts.run() |
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 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
Whenstream: true is set, runLocal() returns a LocalStream:

