Send your first trace

Send your first LLM call into Future AGI with traceAI and see the trace in minutes

Sending traces to Future AGI is as simple as running a single python script. This page guides you on how to get started with the traceAI library to send your traces and start observing your agent

We recommend starting with Auto instrumentation for your agent as it’s the quickest way to get set up, gives you full coverage, and avoids manually adding custom events

You can add custom spans, too.

Prerequisites

  • A Future AGI account and your FI_API_KEY and FI_SECRET_KEY (Dashboard → Build → Keys)
  • Python 3.10–3.13 for the Python example (traceAI-openai requires Python below 3.14)
  • Node.js 22 or newer for the TypeScript example (the openai npm package requires Node.js 22)
  • An OpenAI API key

Open Dashboard → Build → Keys → Add API Key and create a key. Copy both the API Key (FI_API_KEY) and Secret Key (FI_SECRET_KEY) from the one-time creation dialog before closing it. Existing entries in the Keys list cannot reveal these values again.

Future AGI Keys page

1. Install traceAI

pip install traceAI-openai openai
npm install @traceai/openai @traceai/fi-core openai

2. Set your keys

Environment variables are the same regardless of language. Enter them in your terminal:

export FI_API_KEY="your-futureagi-api-key"
export FI_SECRET_KEY="your-futureagi-secret-key"
export OPENAI_API_KEY="your-openai-api-key"

Self-hosting Future AGI? Also set FI_BASE_URL to your install’s API and FI_TRACES_URL to its trace collector (http://localhost:8000 and http://localhost:4318 on a Docker Compose install). See Self-Hosted Docker Compose.

3. Add tracing and make one call

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from traceai_openai import OpenAIInstrumentor
from openai import OpenAI

# Connect to Future AGI and create (or reuse) a project
trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="my-llm-app",
)

# Auto-instrument OpenAI: every call is now traced
OpenAIInstrumentor().instrument(tracer_provider=trace_provider)

# Use OpenAI exactly as you normally would
client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Say hello to Future AGI in one sentence."}],
)
print(response.choices[0].message.content)
import { register, ProjectType } from "@traceai/fi-core";
import { OpenAIInstrumentation } from "@traceai/openai";
import OpenAI from "openai";

// Connect to Future AGI and create (or reuse) a project
const tracerProvider = register({
  projectType: ProjectType.OBSERVE,
  projectName: "my-llm-app",
});

// Explicitly instrument the imported SDK for ESM/TypeScript
const instrumentation = new OpenAIInstrumentation({});
instrumentation.setTracerProvider(tracerProvider);
instrumentation.manuallyInstrument(OpenAI);

// Use OpenAI exactly as you normally would
const client = new OpenAI();
const response = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Say hello to Future AGI in one sentence." }],
});
console.log(response.choices[0].message.content);

Save this as quickstart.py (Python) or quickstart.mts (JS/TS). The .mts extension runs the file as an ES module, which the top-level await needs.

4. Run it

python quickstart.py
npx tsx quickstart.mts

You will see the model’s reply in your terminal, and traceAI sends the trace to Future AGI in the background

Inspect your trace

Open the Future AGI dashboard, select the Tracing tab. your my-llm-app project, should be visible as shown below open it.

Future AGI Tracing tab showing the my-llm-app project

Open the latest trace and confirm you can see:

  • The model and the prompt you sent
  • The model’s response
  • Token count, latency, and cost
Trace detail view in Future AGISpan drawer for a trace in Future AGI

Congratulations! You’ve successfully sent your first trace!🎉

Troubleshooting

Not seeing your traces? Try checking these:

  • Authentication error: check that FI_API_KEY and FI_SECRET_KEY are the pair saved from the creation dialog. If you did not save both values, create a new key at Dashboard → Build → Keys → Add API Key and copy both before closing
  • No trace in Tracing: let the script finish. Traces flush as the program exits, so don’t stop it early
  • Wrong place: confirm you’re on the Tracing tab of platform and in the my-llm-app project

Dive deeper