Quickstart

Install fagi from npm, sign in with your API key and secret key, send one trace from your app and read it back in the terminal

Install fagi, sign in, check your setup, then send one trace from a Python app and read it back in the terminal.

Prerequisites
  • Node.js 22.15 or later on the 22 line, or 23.11 or later, with npm (see Install)
  • A Future AGI API key and secret key: in the dashboard, open Build > Keys and copy both keys of the same entry (see API keys)
  • A Python app that makes one OpenAI call, and an OPENAI_API_KEY

Steps

Install the CLI

npm install -g @future-agi/cli
fagi version

Sign in

fagi auth login
fagi auth status

auth login asks for your API key and secret key without echoing them and saves them in your OS keychain. auth status checks the keys with the platform and prints who you are signed in as.

In CI, or on a self-hosted install, see Sign in with environment variables or Self-hosted.

Check the setup

fagi doctor

Every row should read ok; Check your setup explains each check.

The Agents row warns when no tracing agent is installed. That is expected: the next step adds tracing in your code instead.

Send a trace from your app

In your app’s folder, create a futureagi.toml that holds the project name:

fagi init --yes --project my-app

Install the tracing package and the OpenAI instrumentor:

pip install fi-instrumentation-otel traceAI-openai

The tracing package reads your keys from the environment, not from the keychain, so export them for the app:

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

On a self-hosted install, also point the tracing package at your collector with FI_GRPC_URL (see Export formats).

Register the project with the same name as init, then call OpenAI as usual. Save this as app.py:

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

# Connect to Future AGI and create (or reuse) an Observe project
trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="my-app",
    transport=Transport.GRPC,
)

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

# Use OpenAI exactly as you normally would
client = OpenAI()
completion = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Suggest one habit I could build to keep improving every day."}],
)
print(completion.choices[0].message.content)
python app.py

For other frameworks and languages, see the Observe quickstart. To start a Node, Go or Ruby program with tracing and no code changes, see Run a program with tracing.

Read the trace back

The platform creates the project when your app exports its first trace, so run the app first; a watch on a project that doesn’t exist yet exits 2 at once. Then, in the app’s folder, wait for the first stored trace:

fagi trace watch --until-first

It reads the project name from futureagi.toml and waits about a minute (30 polls, at most 90 seconds). Copy the trace_id it prints, then view the trace:

fagi trace view TRACE_ID

Your app’s trace has one llm span for the OpenAI call; Read a stored trace explains the output.

If the watch fails:

  • project_not_found (exit 2): no trace has created the project yet. Check that the app uses the project name my-app, run it, then watch again
  • trace_not_observed (exit 6): nothing new arrived while it watched. Run the app again and repeat the watch, or pass a larger --timeout and --max-polls (see Watch for new traces)

Dive deeper

Was this page helpful?

Questions & Discussion