Last updated: 2026-04-12

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. Since SpendLil uses X-Provider-Key instead of Authorization, you'll call the gateway directly with fetch/requests rather than using provider SDKs.

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

Since SpendLil uses X-Provider-Key instead of the standard Authorization header, call the gateway directly with fetch or requests rather than using provider SDKs.

javascript Node.js script example
// scripts/generate-docs.mjs
const response = await fetch(
  'https://openai.gateway.spendlil.ai/v1/chat/completions',
  {
    method: 'POST',
    headers: {
      'X-SpendLil-Key': process.env.SPENDLIL_KEY,
      'X-Provider-Key': `Bearer ${process.env.OPENAI_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'gpt-4o-mini',
      messages: [{ role: 'user', content: 'Generate release notes' }],
    }),
  }
);
const data = await response.json();
console.log(data.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