Getting Started
Nerovai is a lightweight SDK that sits between your application and any AI provider - tracking tokens, costs, and latency in real time. Setup takes two minutes.
What Nerovai tracks
For every AI API call wrapped with track(), Nerovai captures:
| Field | Type | Description |
|---|---|---|
| provider | string | Auto-detected from the API base URL (e.g. "openai", "anthropic") |
| model | string | The model identifier from the response (e.g. "gpt-4o") |
| tokens_in | number | Prompt / input tokens consumed |
| tokens_out | number | Completion / output tokens generated |
| cost_usd | number | Calculated cost in USD based on current published pricing |
| latency_ms | number | End-to-end wall-clock time from call start to response received |
2-minute quickstart
Install the package, set your API key, and wrap your first call. That's it - your dashboard starts populating immediately.
Installation
Nerovai works in any Node.js environment - Express, Next.js, serverless functions, CLI scripts, anything.
Install the package
Install from npm. We recommend pinning to a minor version.
Configure your API key
Get your API key from the dashboard at /app â Settings â API Keys. Then set it as an environment variable:
NEROVAI_API_KEY automatically on startup. You can also pass the key explicitly via require('nerovai').init({ apiKey: '...' }) if you prefer programmatic config.Complete working example
Below is a full example with OpenAI. The pattern is identical for every other provider - just swap the client.
TypeScript
Nerovai ships with full TypeScript definitions. No @types package needed.
SDK Reference
The Nerovai SDK exports two primary functions and an optional initialiser.
track(operation, options?)
Wraps an AI API call, captures its metadata, and streams the data to your Nerovai dashboard. Returns the original API response completely untouched - your existing code needs zero changes beyond adding the wrapper.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| operation | Promise<T> | required | The AI API call to track. Pass the Promise directly - do not await it before passing. |
| options.project_id | string | optional | Associate this call with a project in your dashboard. Create projects at /app â Projects. |
| options.endpoint_name | string | optional | Label for the endpoint or feature making the call (e.g. "summarize", "chat", "classify"). Helps group costs by feature. |
| options.metadata | object | optional | Arbitrary key-value pairs attached to the log entry. Useful for user IDs, request IDs, environment flags. Values must be strings, numbers, or booleans. |
| options.cost | number | optional | Override the automatically calculated cost (in USD). Use this if you have a negotiated pricing agreement with a provider. |
| options.provider | string | optional | Override the auto-detected provider name. Useful when using proxy clients or custom OpenAI-compatible endpoints. |
Returns
A Promise<T> that resolves to exactly the same value as the original API call. The tracking happens as a non-blocking side-effect and does not alter the response in any way.
calculateCost(model, promptTokens, completionTokens)
Utility function to compute the USD cost for a given number of tokens without making an API call. Useful for cost estimation before making a request.
Environment Variables
The SDK is configured entirely via environment variables. No config file needed.
| Variable | Required | Default | Description |
|---|---|---|---|
| NEROVAI_API_KEY | required | - | Your Nerovai API key. Get one from /app â Settings â API Keys. |
| NEROVAI_ENDPOINT | optional | https://api.nerovai.com | Override the API endpoint. Used for proxies, testing, or future self-hosted deployments. |
| NEROVAI_SILENT | optional | false | Set to true to suppress all SDK console output including warnings and errors. |
| NEROVAI_DEBUG | optional | false | Set to true to enable verbose debug logging. Useful when troubleshooting missing data. |
API Reference
The Nerovai REST API is available at https://api.nerovai.com. All endpoints require your API key in the x-api-key header unless noted otherwise.
Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
| POST | /api/logs | â required | Record a single AI API call. Used by the SDK internally. |
| GET | /api/logs | â required | List log entries. Supports filtering by project_id, provider, model, date range, and pagination. |
| GET | /api/logs/:id | â required | Retrieve a single log entry by ID. |
| GET | /api/projects | â required | List all projects in your account. |
| POST | /api/projects | â required | Create a new project. |
| GET | /api/stats/summary | â required | Get aggregated spend, call count, and token totals for a date range. |
| GET | /api/stats/daily | â required | Get per-day spend and call count - powers the dashboard chart. |
| POST | /api/billing/create-checkout | â required | Create a Stripe checkout session. Returns a { url } to redirect the user. |
| GET | /api/billing/portal | â required | Create a Stripe billing portal session for managing subscriptions and invoices. |
| GET | /api/health | open | Returns {"status":"ok"}. Use for uptime monitoring. |
POST /api/logs - example
Record an AI call manually. All fields except provider and model are optional.
Response
GET /api/logs - query parameters
| Param | Type | Description |
|---|---|---|
| project_id | string | Filter by project. |
| provider | string | Filter by provider (e.g. "openai", "anthropic"). |
| model | string | Filter by model name. |
| from | ISO 8601 | Start of date range (inclusive). |
| to | ISO 8601 | End of date range (inclusive). |
| limit | number | Number of results per page (default 50, max 500). |
| cursor | string | Pagination cursor from previous response. |
Providers
Nerovai supports 9 major AI providers out of the box. Provider detection is automatic - we parse the API base URL and response structure to identify who made the call.
| Provider | Key Models | Auto Cost Calc |
|---|---|---|
| OpenAI | gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-3.5-turbo, o1, o1-mini, text-embedding-3-small, text-embedding-3-large | â |
| Anthropic | claude-3-5-sonnet, claude-3-5-haiku, claude-3-opus, claude-3-sonnet, claude-3-haiku | â |
| gemini-1.5-pro, gemini-1.5-flash, gemini-2.0-flash, gemini-2.5-pro, gemini-pro, text-embedding-004 | â | |
| Mistral | mistral-large, mistral-small, mistral-nemo, codestral, mixtral-8x22b, pixtral-large | â |
| DeepSeek | deepseek-chat, deepseek-reasoner, deepseek-coder | â |
| Groq | llama-3.3-70b-versatile, llama-3.1-8b-instant, gemma2-9b-it, mixtral-8x7b-32768, whisper-large-v3 | â |
| Kimi (Moonshot) | moonshot-v1-8k, moonshot-v1-32k, moonshot-v1-128k, kimi-latest | â |
| Cohere | command-r-plus, command-r, command-light, embed-multilingual-v3.0, rerank-english-v3.0 | â |
| Perplexity | llama-3.1-sonar-large-128k-online, llama-3.1-sonar-small-128k-online, llama-3.1-sonar-large-128k-chat | â |
options.provider and options.cost to supply values explicitly. Request new providers on our GitHub issues.OpenAI-compatible providers
Many providers expose an OpenAI-compatible API (Together, Fireworks, Anyscale, LM Studio, Ollama, etc.). These work automatically with Nerovai when you pass options.provider to identify the correct pricing:
FAQ
Answers to the most common questions about Nerovai.
options.provider and optionally options.cost to manually set the values. We add new providers within days of significant launches - request one on our GitHub issues page.
calculateCost() returns null and you can provide a manual cost override in track() options. We also expose cost overrides at the project level for teams with negotiated rates.
NEROVAI_API_KEY, run npm install nerovai, and wrap your first AI call with track(). Your dashboard starts populating within 5-10 seconds of the first tracked request. No onboarding call is required. If you run into any issues, we're on Discord (link in the dashboard) and respond to every message, usually within the hour during business days.