Setup¶
Get your account, API key, and first provider connected in a few minutes.
1. Create your account¶
Sign in at tokensor.dev. If you have not onboarded yet you will be taken through the onboarding flow.
2. Get your Tokensor API key¶
Your Tokensor API key (ts_...) is shown in onboarding Step 2 and on the Settings page. Use it as the X-Tokensor-Key header for every request, or as the apiKey/Authorization: Bearer value when routing a provider through Tokensor.
Keep it secret
The ts_... key grants access to your Tokensor account. Do not commit it to source control.
3. Connect an LLM provider key¶
Tokensor stores your provider API key (OpenAI, Anthropic, or OpenCode) on your account and injects it upstream when proxying calls — so your app only ever holds the Tokensor key.
- OpenAI —
sk-proj-...key from the OpenAI dashboard. - Anthropic —
sk-ant-...key from the Anthropic console. - OpenCode — Zen/Go API key from your OpenCode workspace.
Connect it either during onboarding or in Settings → Integrations.
4. Route your traffic through Tokensor¶
Once a provider key is stored, point your app at the Tokensor proxy:
| Provider | Base URL |
|---|---|
| OpenAI | https://tokensor.dev/proxy/openai/v1 |
| Anthropic | https://tokensor.dev/proxy/anthropic/v1 |
| OpenCode Zen | https://tokensor.dev/proxy/opencode/zen/v1 |
| OpenCode Go | https://tokensor.dev/proxy/opencode/go/v1 |
Authenticate with Authorization: Bearer <your Tokensor key> (or X-Tokensor-Key: <your Tokensor key>).
Example with the OpenAI SDK:
from openai import OpenAI
client = OpenAI(
base_url="https://tokensor.dev/proxy/openai/v1",
api_key="ts_your_tokensor_key",
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}],
)
5. Send events directly (SDK / ingest)¶
If you are not proxying a supported provider, send LLM call metadata directly to the ingest endpoint:
curl -X POST https://tokensor.dev/v1/events/batch \
-H "X-Tokensor-Key: <your Tokensor key>" \
-H "Content-Type: application/json" \
-d '{
"events": [
{
"model": "gpt-4o-mini",
"input_tokens": 150,
"output_tokens": 200,
"timestamp": "2026-08-08T10:30:00Z"
}
]
}'
6. Verify¶
Open the dashboard. Your first recorded call appears within ~60 seconds and the connection status flips to connected.
Next steps¶
- Send agent framework traces: see Agent Frameworks.
- Wire up OpenCode CLI: see OpenCode.
- Reference every endpoint: see the API Reference.