Caveman Setup

Caveman Setup

Guides a coding agent to route a repository's LLM calls through the Caveman gateway for spend measurement, with minimal changes and verified results.

Skill files1 file
SKILL.md223 lines
1
---
2
name: caveman-setup
3
description: >
4
Wire a repository through the Caveman Cloud gateway so every LLM request is
5
measured, with no behavior change. Use for "set up caveman" or adding LLM
6
spend observability.
7
---
8
9
You are wiring this repository through the Caveman gateway. Caveman is a
10
byte-preserving LLM proxy: in record mode it measures what your app sends and
11
what it costs, and changes nothing else. Your job is a minimal, verified
12
integration — not a refactor.
13
14
The prompt that sent you here provides four values. Refer to them as:
15
16
- `GATEWAY` — the gateway base URL (e.g. `https://gateway.caveman.so` or `http://127.0.0.1:8787`)
17
- `CAVE_API_KEY` — the gateway auth secret (treat like any API key: env var only, never committed, never printed in full)
18
- `PROVIDER_KEYS` — `stored` (provider keys live encrypted in Caveman Cloud) or `byok` (this app sends its own provider key per request)
19
- `DASHBOARD` — the dashboard base URL (e.g. `https://app.caveman.so`)
20
21
If any value is missing, stop and ask for it. Do not guess a URL or mint a key.
22
23
## Rules (non-negotiable)
24
25
1. **Coherent integration.** Wire every live LLM callsite through existing
26
configuration and responsible seams. Touch each layer correctness requires.
27
No drive-by refactors or formatting sweeps; add an abstraction only when it
28
clarifies ownership or lowers lifecycle cost.
29
2. **Secrets stay in env vars.** `CAVE_API_KEY` goes into the env file the repo
30
already uses (`.env`, `.env.local`, …). If that file isn't gitignored, add it
31
to `.gitignore` and say so. Never hardcode the key in source.
32
3. **Report only what you observed.** The final report states the HTTP status
33
and usage numbers from the real verification response — never assumed
34
success. If verification fails, report the failure template instead.
35
4. **Record mode only.** You are adding measurement. You do not enable any
36
optimization, and you do not claim any savings — verified savings are $0
37
until an optimizer is explicitly turned on and passes its eval gate.
38
5. **Provider keys are not your business.** With `PROVIDER_KEYS: stored` you
39
never see one. With `byok`, the app's existing provider key stays exactly
40
where it already is.
41
42
## Step 1 — Find every live LLM callsite
43
44
Read dependency files (`package.json`, `requirements.txt`, `pyproject.toml`,
45
`go.mod`, lockfiles) and search the source for LLM clients:
46
47
- SDK imports: `openai`, `@anthropic-ai/sdk`, `anthropic`, `ai` +
48
`@ai-sdk/*` (Vercel), `langchain*`, `litellm`, `google-genai` /
49
`@google/genai`, `crewai`, `pydantic_ai`, `openai-agents` / `agents`
50
- Raw HTTP to `api.openai.com`, `api.anthropic.com`, `generativelanguage.googleapis.com`
51
- Existing base-URL env vars: `OPENAI_BASE_URL`, `OPENAI_API_BASE`,
52
`ANTHROPIC_BASE_URL`, `GEMINI_BASE_URL`, `GOOGLE_GEMINI_BASE_URL`
53
54
List what you found (file:line per callsite) before changing anything. If you
55
find **no** LLM callsites, stop and report the "nothing to wire" template at
56
the end of this file — do not invent an integration.
57
58
## Step 2 — Pick the app slug
59
60
One slug names this app in the gateway path: `GATEWAY/w/<app>`. Derive it from
61
the package/module name (e.g. `support-bot`, `acme-api`). Grammar:
62
lowercase `[a-z0-9]` first, then `[a-z0-9._-]`, max 64 chars. Spend for this
63
whole app groups under that slug on the dashboard.
64
65
## Step 3 — Wire each callsite
66
67
The pattern is always the same: **base URL → the gateway with `/w/<app>`,
68
plus one auth header.** Gateway auth is `x-cave-api-key: CAVE_API_KEY`
69
(`Authorization: Bearer CAVE_API_KEY` also works where a header is awkward).
70
With `PROVIDER_KEYS: byok`, also send `x-cave-upstream-key: <the provider key
71
the app already uses>`.
72
73
Two facts that make the wiring safe (both are gateway-enforced, not hopes):
74
the gateway rebuilds upstream auth headers from scratch, so a client's
75
`Authorization`/`x-api-key` value is never forwarded to the provider; and with
76
`stored`, upstream auth comes from the encrypted connection server-side. So in
77
`stored` mode, where an SDK insists on an api-key parameter, set it to the
78
Cave key — it authenticates the gateway and goes no further.
79
80
Exact shapes (use the one matching each callsite — these are the product's
81
published recipes, not suggestions):
82
83
**OpenAI SDK (TS)** — Chat Completions and Responses both route through:
84
```ts
85
const client = new OpenAI({
86
baseURL: `${process.env.CAVE_GATEWAY_URL}/w/<app>/openai/v1`,
87
apiKey: process.env.OPENAI_API_KEY, // byok: unchanged · stored: use CAVE_API_KEY
88
defaultHeaders: {
89
"x-cave-api-key": process.env.CAVE_API_KEY!,
90
// byok only:
91
"x-cave-upstream-key": process.env.OPENAI_API_KEY!,
92
},
93
});
94
```
95
96
**OpenAI SDK (Python)** — same shape: `base_url=f"{gw}/w/<app>/openai/v1"`,
97
`default_headers={"x-cave-api-key": ..., "x-cave-upstream-key": ...}`.
98
99
**Anthropic SDK (TS/Python)** — the SDK appends `/v1/messages` itself. The
100
`x-cave-api-key` header is required here in both modes (this SDK's own key
101
param rides `x-api-key`, which is not a gateway-auth header):
102
```python
103
client = anthropic.Anthropic(
104
base_url=f"{os.environ['CAVE_GATEWAY_URL']}/w/<app>",
105
api_key=os.environ["ANTHROPIC_API_KEY"], # byok: unchanged · stored: use CAVE_API_KEY
106
default_headers={
107
"x-cave-api-key": os.environ["CAVE_API_KEY"],
108
# byok only:
109
"x-cave-upstream-key": os.environ["ANTHROPIC_API_KEY"],
110
},
111
)
112
```
113
114
**Vercel AI SDK** — `createOpenAICompatible({ baseURL: `${gw}/w/<app>/openai/v1`,
115
headers: { "x-cave-api-key": ... } })`; Anthropic models via
116
`createAnthropic({ baseURL: `${gw}/w/<app>/v1`, headers: { ... } })`.
117
118
**LangChain / LangGraph** — `ChatOpenAI(base_url=f"{gw}/w/<app>/openai/v1",
119
default_headers={...})`; `ChatAnthropic(base_url=f"{gw}/w/<app>",
120
default_headers={...})`. LangGraph inherits whatever model you pass it.
121
122
**LiteLLM** — per call `api_base=f"{gw}/w/<app>/openai/v1"` +
123
`extra_headers={...}`, or fleet-wide in the LiteLLM proxy `config.yaml`.
124
125
**Raw HTTP / anything else** — swap the host, keep the provider's native path:
126
`GATEWAY/w/<app>/v1/chat/completions` (OpenAI protocol) or
127
`GATEWAY/w/<app>/v1/messages` (Anthropic protocol), add the header(s).
128
129
Concretely, with slug `support-bot` and the hosted gateway, an OpenAI-SDK base
130
URL reads `https://gateway.caveman.so/w/support-bot/openai/v1`. And in `stored`
131
mode, drop every `x-cave-upstream-key` line entirely — it is byok-only.
132
133
For frameworks not listed (google-genai, crewai, pydantic-ai, openai-agents),
134
fetch the matching page under `<docs origin>/docs/integrations/` — same origin
135
this skill came from — and follow it.
136
137
Add to the repo's env file (and reference from code — no literals):
138
139
```
140
CAVE_GATEWAY_URL=<GATEWAY>
141
CAVE_API_KEY=<CAVE_API_KEY>
142
```
143
144
## Step 4 — Verify with one real request
145
146
The user pasted the setup prompt to authorize exactly this: one small
147
verification request. Send it now — do not pause to ask permission for it.
148
An integration that ends unverified because you hesitated is a worse outcome
149
than one tiny request; finishing the verification and the report autonomously
150
is the point of this skill.
151
152
Send one minimal request through the wiring you just built — the app's own
153
cheapest path if it has a script for it, otherwise curl **on the path matching
154
the protocol you just wired** with the app's own model and a small cap
155
(`max_tokens` ≤ 32):
156
157
```bash
158
# OpenAI-protocol wiring:
159
curl -sS "$CAVE_GATEWAY_URL/w/<app>/v1/chat/completions" \
160
-H "x-cave-api-key: $CAVE_API_KEY" \
161
-H "content-type: application/json" \
162
-d '{"model":"<model the repo already uses>","max_tokens":16,"messages":[{"role":"user","content":"ping"}]}'
163
164
# Anthropic-protocol wiring:
165
curl -sS "$CAVE_GATEWAY_URL/w/<app>/v1/messages" \
166
-H "x-cave-api-key: $CAVE_API_KEY" \
167
-H "anthropic-version: 2023-06-01" \
168
-H "content-type: application/json" \
169
-d '{"model":"<model the repo already uses>","max_tokens":16,"messages":[{"role":"user","content":"ping"}]}'
170
```
171
172
(byok: add `-H "x-cave-upstream-key: $PROVIDER_KEY"`.) This is one real,
173
billable provider request — that is the point: real traffic, real measurement.
174
175
Read the response. Success = HTTP 200 with a `usage` block. Anything else =
176
the matching failure template below.
177
178
## Step 5 — Report
179
180
End with exactly this shape, values filled from what you actually did and saw:
181
182
```
183
## Caveman is live in this repo
184
185
Wired: <n> callsite(s) in <n> file(s)
186
- <file> — <one-line what changed>
187
App slug: <app> — spend for this app groups under it
188
Verified: HTTP 200 · model <model> · <in> in / <out> out tokens (one real request)
189
Mode: record — measured only. No model-visible bytes changed, no optimization
190
enabled. Verified savings are $0 until you turn an optimizer on and it passes
191
its eval gate. That honesty is the product.
192
193
See the dollars: <DASHBOARD>/traces — your request is the top row, priced from
194
the public catalog. <DASHBOARD>/getting-started flips to "First request received."
195
196
Want spend split by workflow (e.g. support-reply vs nightly-digest), not just
197
by app? Say "discover workflows" — I'll fetch <docs origin>/docs/discover-workflows.md
198
and label every callsite by the job it does.
199
```
200
201
## Failure templates (use verbatim, filled in — never soften)
202
203
- **Nothing to wire**: "I found no LLM callsites in this repo (searched SDKs,
204
raw provider HTTP, base-URL env vars). If this repo runs a coding agent
205
rather than shipping LLM code, use `caveman wrap <agent>` instead — see
206
<DASHBOARD>/getting-started."
207
- **Gateway unreachable**: "The verification request could not reach GATEWAY
208
(<error>). Wiring is in place but unverified — nothing will be measured
209
until the gateway is reachable. Check the URL and network, then re-run the
210
verification curl above."
211
- **401 cave_invalid_api_key**: "The gateway rejected CAVE_API_KEY. Mint a new
212
key at <DASHBOARD>/getting-started and update the env file; the wiring
213
itself is unchanged."
214
- **404 cave_route_not_found**: "The gateway matched no route — usually a
215
malformed /w/<app> slug (lowercase [a-z0-9] first, then [a-z0-9._-], max 64)
216
or a path that doesn't match the SDK's protocol. Fix the URL and re-verify."
217
- **Provider error (4xx/5xx via gateway)**: report status + body verbatim; the
218
gateway is reachable and auth passed, the upstream call failed — usually a
219
provider key or model-name issue in the app itself.
220
221
Never report success on any of these. An unverified integration is reported as
222
unverified.
223

© Julius Brussee · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…