Last updated: 2026-04-20

Groq Integration

Route Groq API calls through SpendLil.

SpendLil proxies Groq's API. Swap api.groq.com for groq.gateway.spendlil.ai and add X-SpendLil-Key. Groq is OpenAI-compatible — use the OpenAI SDK with the Groq gateway.

URL Pattern

diff Before → After
- POST https://api.groq.com/openai/v1/chat/completions
+ POST https://groq.gateway.spendlil.ai/openai/v1/chat/completions

OpenAI SDK (Python)

python Use the OpenAI SDK with the Groq gateway
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ['GROQ_API_KEY'],
    base_url='https://groq.gateway.spendlil.ai/openai/v1',
    default_headers={'X-SpendLil-Key': os.environ['SPENDLIL_KEY']},
)

response = client.chat.completions.create(
    model='llama-3.3-70b-versatile',
    messages=[{'role': 'user', 'content': 'Hello'}],
)
print(response.choices[0].message.content)

cURL

bash Direct HTTP request
curl https://groq.gateway.spendlil.ai/openai/v1/chat/completions \
  -H "Authorization: Bearer $GROQ_API_KEY" \
  -H "X-SpendLil-Key: $SPENDLIL_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama-3.3-70b-versatile",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
OpenAI-compatible

Groq's API mirrors OpenAI's chat completions schema. Any OpenAI SDK or tool that accepts a base_url override will work unchanged.