Last updated: 2026-04-12

Postman & Insomnia

Import SpendLil API collections into Postman and Insomnia for testing.

Pre-built request collections for testing your SpendLil integration.

Postman Setup

Collection Variables

VariableValueDescription
spendlil_keysl_abc123def456Your SpendLil account key
openai_keysk-...Your OpenAI API key
anthropic_keysk-ant-...Your Anthropic API key
google_keyAIza...Your Google API key

Pre-Request Script (Collection Level)

javascript Pre-request script
pm.request.headers.add({
  key: 'X-SpendLil-Key',
  value: pm.environment.get('spendlil_key')
});

Test Script (Collection Level)

javascript Test script
pm.test('SpendLil tracking active', function () {
  const route = pm.response.headers.get('X-SpendLil-Route');
  pm.expect(route).to.be.oneOf(['governed', 'bypassed']);
});

Example Requests

text OpenAI Chat Completion
POST https://openai.gateway.spendlil.ai/v1/chat/completions

Headers:
  X-SpendLil-Key: {{spendlil_key}}
  X-Provider-Key: Bearer {{openai_key}}
  Content-Type: application/json

Body:
{
  "model": "gpt-4o-mini",
  "messages": [
    {"role": "user", "content": "Hello from Postman"}
  ]
}
text Anthropic Messages
POST https://anthropic.gateway.spendlil.ai/v1/messages

Headers:
  X-SpendLil-Key: {{spendlil_key}}
  X-Provider-Key: Bearer {{anthropic_key}}
  Content-Type: application/json
  anthropic-version: 2023-06-01

Body:
{
  "model": "claude-sonnet-4-5-20250514",
  "max_tokens": 256,
  "messages": [
    {"role": "user", "content": "Hello from Postman"}
  ]
}

Insomnia Setup

  1. Create a new Environment with spendlil_key, openai_key, anthropic_key variables
  2. Create requests using {{ variable }} syntax in headers
  3. Add X-SpendLil-Key and X-Provider-Key headers to each request

Testing Checklist

Response includes X-SpendLil-Route: governed

Confirms SpendLil is tracking the request.

Response body is identical to direct provider call

SpendLil should not modify the response.

Key appears in SpendLil dashboard

The key hint (last 4 chars) should match.

Cost is calculated and visible

Usage record should show token counts and estimated cost.

Errors pass through correctly

Send a bad request — the provider's error should come through unmodified.