Skip to content

Quickstart: logs in 2 minutes ​

See every model and tool call your app makes, with its cost, latency and errors, in the project's Logs. Change one address and one key; no code changes.

In development

The AI Gateway and the SDK below are in development as ways to connect a project, so you can't choose them on the platform yet; OpenTelemetry works now. Projects already connected through the gateway or the SDK keep working, and the steps below still apply to them.

1. Make a project token that may upload ​

In the project, open Automations → API tokens, enter a name such as production, tick "Allow uploading logs and experiments", click "Create token" and copy the pj_… token (shown only this once). It is the key for all three ways below.

2. Send your calls ​

Pick one. Targets in the project shows each with your address and project filled in.

The AI Gateway (OpenAI or Anthropic SDK) ​

Point your SDK's base URL at the platform and use the project token as its API key:

bash
# OpenAI SDKs (chat completions, responses, embeddings)
OPENAI_BASE_URL=https://<platform address>/gw/openai/v1
OPENAI_API_KEY=pj_your_token_here

# Anthropic SDKs (messages)
ANTHROPIC_BASE_URL=https://<platform address>/gw/anthropic
ANTHROPIC_API_KEY=pj_your_token_here
  • On the platform's models, nothing else is needed: the call is answered by one of the platform's models and billed by usage at list price plus 30% (GET /gw/openai/v1/models lists them).
  • On your own provider key, add the header x-provider-key: <your OpenAI, Anthropic or Google key>. The call goes to that provider, you pay it directly, and the platform charges nothing for the call. The key is never stored or logged.
ts
const openai = new OpenAI({
  baseURL: 'https://<platform address>/gw/openai/v1',
  apiKey: process.env.PREWORLD_API_KEY,                                   // pj_…
  defaultHeaders: { 'x-provider-key': process.env.OPENAI_API_KEY!, 'x-preworld-environment': 'prod' },
});

Each call becomes one trace with one span: the model, tokens, cost, the request and the reply. x-preworld-environment tags it dev, staging, prod or ci.

OpenTelemetry ​

Already instrumented with OpenTelemetry (OpenLLMetry, OpenInference, the Vercel AI SDK, or the GenAI semantic conventions)? Point the OTLP exporter at the platform:

bash
OTEL_EXPORTER_OTLP_ENDPOINT=https://<platform address>/otel
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20pj_your_token_here
OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=prod

The exporter sends to /otel/v1/traces (OTLP over HTTP, protobuf or JSON). Spans keep their tree, so an agent's run shows its model, tool and retrieval calls under it.

The SDK ​

ts
import { traced, wrapOpenAI } from '@preworld/sdk';
const openai = wrapOpenAI(new OpenAI());
const handle = traced(async (message: string) => { /* your agent */ }, { name: 'support-agent', kind: 'agent' });

With PREWORLD_API_KEY, PREWORLD_PROJECT, PREWORLD_BASE_URL and PREWORLD_ENVIRONMENT set (see the SDK quickstart). Python: wrap_openai, wrap_anthropic, @traced.

3. Open Logs ​

Make a call, then open Logs. Traces show within seconds: time, input, output, status, latency, cost, model. Click one to see its spans; click a facet (a model, a tool, "error") to filter. Read on in the Logs guide.

Next steps ​

The legal texts on this site are drafts pending legal review and are not yet in force.