@logspine/sdk-ts
v0.2.0
Published
Drop-in observability SDK for AI agents (TypeScript / Node / Edge). The Helicone replacement built for solo devs and small teams.
Downloads
83
Maintainers
Readme
@logspine/sdk-ts
Drop-in observability SDK for AI agents. TypeScript / Node / Edge. Auto-instruments OpenAI and Anthropic.
Python SDK:
pip install logspine— see Python docs
The Helicone replacement built for solo devs and small teams. One line of code, zero infrastructure, pricing that doesn't punish growth — start at $19/mo for 100k spans.
→ logspine.dev · Full docs · Quickstart · Data model
Install
pnpm add @logspine/sdk-ts
# or: npm install @logspine/sdk-ts
# or: yarn add @logspine/sdk-tsQuick start
import { Logspine } from '@logspine/sdk-ts';
Logspine.init({
apiKey: process.env.LOGSPINE_API_KEY!,
});
const trace_id = Logspine.trace({
name: 'support-bot',
input: { user_question: 'How do refunds work?' },
});
Logspine.span({
trace_id,
name: 'retrieve-docs',
output: { hits: 4 },
});
// Before process exit:
await Logspine.shutdown();Get your API key at logspine.dev → Settings → API Keys.
Auto-instrumentation
Wrap your existing client and every call is tracked automatically — with real latency, token counts, and cost in USD (computed from per-model pricing tables, updated quarterly).
OpenAI
import OpenAI from 'openai';
import { Logspine } from '@logspine/sdk-ts';
import { instrumentOpenAI } from '@logspine/sdk-ts/openai';
Logspine.init({ apiKey: process.env.LOGSPINE_API_KEY! });
const openai = instrumentOpenAI(new OpenAI());
// Now every call emits a trace:
const res = await openai.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'hi' }],
});Supports:
chat.completions.create(sync + streaming)embeddings.create- Prompt caching (cached tokens billed at the cached rate automatically)
Anthropic
import Anthropic from '@anthropic-ai/sdk';
import { Logspine } from '@logspine/sdk-ts';
import { instrumentAnthropic } from '@logspine/sdk-ts/anthropic';
Logspine.init({ apiKey: process.env.LOGSPINE_API_KEY! });
const anthropic = instrumentAnthropic(new Anthropic());Supports:
messages.create(sync + streaming)- Cache reads (
cache_read_input_tokensbilled at 10% of input rate)
API
| Method | Description |
| --- | --- |
| Logspine.init(opts) | Initialize. Required: apiKey. Optional: endpoint, flushIntervalMs (default 2000), maxBatch (default 100), projectId, disabled, onError. |
| Logspine.trace({ name, input, output, model, prompt_tokens, completion_tokens, cost_usd, start_ts, end_ts, status, error, metadata }) | Create top-level trace. Returns trace_id. |
| Logspine.span({ trace_id, name, ... }) | Child span inside a trace. |
| Logspine.flush() | Force-flush the queue. |
| Logspine.shutdown() | Stop timer + flush. Call before process exit. |
Spans are batched automatically: every 2 seconds, or when the queue hits 100 spans.
Full method reference, options table, and runtime support matrix: /docs/sdk/typescript.
Pricing table
@logspine/sdk-ts ships a model→price table covering:
- OpenAI: GPT-4o, GPT-4o-mini, GPT-4.1, GPT-4, GPT-3.5, o1, o1-mini, o3, o3-mini, text-embedding-3 (small/large), text-embedding-ada-002
- Anthropic: Claude 4 (opus/sonnet/haiku), Claude 3.5 (sonnet/haiku), Claude 3 (opus/sonnet/haiku), Claude 2
If a model isn't recognized (new release, fine-tuned variant), cost_usd will be 0 and a warning is not logged — the trace still goes through.
Prices are updated each quarter. Source: pricing.ts.
Edge / serverless runtimes
Works on:
- Node 18+
- Cloudflare Workers (
nodejs_compatnot required) - Vercel Edge Functions
- Deno (via npm: specifier)
- Bun
The SDK uses fetch() and crypto.subtle — no native Node dependencies.
License
MIT © Adam Kallen — see LICENSE.
