Last updated: 2026-04-20
CI/CD & Docker
Route AI calls through SpendLil in CI/CD pipelines, Docker containers, and automated workflows.
If your CI/CD pipelines or automated scripts make AI API calls, route them through SpendLil to track the spend. Your existing provider SDK calls work unchanged — just swap the base URL for the matching SpendLil gateway and add X-SpendLil-Key.
GitHub Actions
yaml .github/workflows/ai-pipeline.yml
name: AI Pipeline
on: [push]
jobs:
generate:
runs-on: ubuntu-latest
env:
SPENDLIL_KEY: ${{ secrets.SPENDLIL_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
steps:
- uses: actions/checkout@v4
- name: Verify SpendLil gateway
run: |
STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://openai.gateway.spendlil.ai/health)
echo "SpendLil gateway status: $STATUS"
- name: Run AI task
run: node scripts/generate-docs.mjs GitLab CI
yaml .gitlab-ci.yml
ai-review:
stage: test
script:
- node scripts/ai-code-review.mjs
variables:
SPENDLIL_KEY: $SPENDLIL_KEY
OPENAI_API_KEY: $OPENAI_API_KEY Docker
yaml docker-compose.yml
services:
app:
build: .
environment:
- SPENDLIL_KEY=${SPENDLIL_KEY}
- OPENAI_API_KEY=${OPENAI_API_KEY}
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} AWS Lambda / Serverless
yaml SAM template.yaml
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs20.x
Environment:
Variables:
SPENDLIL_KEY: !Ref SpendLilKey
OPENAI_API_KEY: !Sub '{{resolve:secretsmanager:my-secrets:SecretString:OPENAI_API_KEY}}' Kubernetes
yaml k8s deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-ai-service
spec:
template:
spec:
containers:
- name: app
image: my-app:latest
env:
- name: SPENDLIL_KEY
valueFrom:
secretKeyRef:
name: spendlil-secrets
key: account-key
- name: OPENAI_API_KEY
valueFrom:
secretKeyRef:
name: openai-secrets
key: api-key Calling SpendLil from Scripts
Use the provider SDK with the SpendLil gateway as the base URL. Your existing auth header is passed through unchanged.
javascript Node.js script example
// scripts/generate-docs.mjs
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: 'https://openai.gateway.spendlil.ai/v1',
defaultHeaders: { 'X-SpendLil-Key': process.env.SPENDLIL_KEY },
});
const response = await client.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'Generate release notes' }],
});
console.log(response.choices[0].message.content); Fallback in CI/CD
bash Health check with fallback
#!/bin/bash
if curl -sf https://openai.gateway.spendlil.ai/health > /dev/null 2>&1; then
export USE_SPENDLIL=true
echo "Routing AI calls through SpendLil"
else
export USE_SPENDLIL=false
echo "SpendLil unavailable — routing direct to provider"
fi