UsageTap Integration Guide
The live Code Integration workspace is the source of truth for executable examples:
It generates the smallest current example for your selected features and model provider, shows the exact server-side keys, and links to maintained playgrounds for specialized workflows.
Recommended: let your coding agent implement Meter
Paste the one-prompt setup from the LLM Integration Reference into the coding agent that has access to your repository. The agent is instructed to inspect the existing provider calls and authentication, choose the UsageTap SDK or direct HTTPS, implement the complete Meter lifecycle, add tests, and return the exact key and verification steps.
The initial onboarding target is UsageTap Meter only. Do not add Gateway, Compress, prompt compression, or Stripe synchronization until the first metered call is working and the user explicitly chooses the next product.
Start here
- Keep UsageTap Meter selected for the first integration.
- Pick the provider already used by the application: OpenAI, Anthropic, or OpenRouter. Keep the existing provider and model.
- Pick the implementation: UsageTap SDK, Without UsageTap SDK, or Python.
- Start with Minimal diff, then open Complete example when you need the surrounding request lifecycle.
- Create the keys shown beside the example and place them in your server environment.
- Copy the generated code, run one request, and confirm the call appears in the connection verification step.
- Open UsageTap Quickstart to define the default customer plan, allowances, limits, and limit behavior.
Which key do I need?
| What you are using | Environment variable | Key |
|---|---|---|
| UsageTap Meter | USAGETAP_API_KEY |
utk-… with usage:write |
| UsageTap Compress | USAGETAP_API_KEY |
utk-… with compression:invoke |
| Meter + Compress | USAGETAP_API_KEY |
utk-… with usage:write and compression:invoke |
| UsageTap Gateway | USAGETAP_API_KEY |
utk-… with gateway:invoke |
| OpenAI | OPENAI_API_KEY |
Your OpenAI server key |
| Anthropic | ANTHROPIC_API_KEY |
Your Anthropic server key |
Add usage:read for usage reports, customers:read for customer and plan
listings, and customers:write for provisioning, plan changes, and
replenishment. Existing prefixed keys continue to use their historical
permissions.
| OpenRouter | OPENROUTER_API_KEY | Your OpenRouter server key |
Put these variables in the server environment. For local Next.js development,
that is commonly .env.local. Never use a NEXT_PUBLIC_ name and never send a
provider or UsageTap key to browser code.
Create or manage UsageTap keys
Customer attribution
When an example uses customerId, populate it from your trusted server-side
session or database. Use the same stable ID for the same customer across calls.
Do not accept an unverified customer ID directly from browser input.
End-user attribution is optional. When a customer account has multiple users,
send customerUserId from the same trusted server-side identity. Prefer a
stable, non-PII application user ID. customerUserName and
customerUserEmail are optional display metadata for Live activity and should
be omitted when they are unnecessary.
const usageContext = {
customerId: currentCustomer.id, // Required customer/account ID
customerUserId: currentUser.id, // Optional stable end-user ID
customerUserName: currentUser.name, // Optional display metadata
customerUserEmail: currentUser.email, // Optional display metadata
feature: "chat.reply",
};
Direct HTTP requirements
UsageTap public API requests use:
Authorization: Bearer <USAGETAP_API_KEY>Accept: application/vnd.usagetap.v1+jsonContent-Type: application/jsonwhen a request has a JSON bodyIdempotency-Keyfor retried create, begin, and state-changing requests
The Without UsageTap SDK and Python examples in Code Integration include these headers. See the API reference for request and response contracts.
Specialized workflows
Keep specialized code beside the product workflow that owns it:
- Prompt Compression playground
- Context Summarization Add to Code
- Sampling Add to Code
- Call Profiler
- UsageTap Gateway playground
- UsageTap Gateway setup
- SDK reference
The Examples & playgrounds tab in Code Integration also covers customer management, Gateway batches, compression, summarization, sampling, and profiling without duplicating each product’s local setup.
Integration checklist
- At least one UsageTap feature is selected.
- Every key is server-side.
- The provider key and UsageTap key are separate variables.
customerIdcomes from a trusted server-side identity.- Optional
customerUserIdcomes from trusted application identity, not request input. - Direct API calls send the required versioned
Acceptheader. - Failed provider calls still finish metering with an error.
- The integration has been tested with a real customer and a realistic prompt.
If you need help, use the support option in the application after opening the relevant product workspace.