ai
Skill533 starsChanged 6 months agoMITView on GitHub
Use when calling the app's AI gateway from agent tools — chat completions, embeddings, listing models, configuring defaults or BYOK, reading token/cost usage
In this repository40 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- butterbase-skillsSkill
- agentsSkill
- auth-setupSkill
- build-appSkill
- contributingSkill
- debug-rlsSkill
- deploy-frontendSkill
- durable-objectsSkill
- function-devSkill
- integrationsSkill
- journey-agentsSkill
- journey-aiSkill
- journey-authSkill
- journey-deploySkill
- journey-docsSkill
- journey-durableSkill
- journey-frontendSkill
- journey-functionsSkill
- journey-ideaSkill
- journey-planSkill
- journey-preflightSkill
- journey-ragSkill
- journey-realtimeSkill
- journey-rlsSkill
- journey-schemaSkill
- journeySkill
- journey-storageSkill
- journey-submitSkill
- journey-substrateSkill
- journey-templatesSkill
- meetingsSkill
- migrationsSkill
- paymentsSkill
- rag-devSkill
- realtimeSkill
- schema-designSkill
- storageSkill
- substrateSkill
- templatesSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Every app has an LLM gateway with chat, embeddings, model listing, configuration, and usage reporting.
- Distinctive: line 64
Use this to discover what the app can call — capabilities + context window matter when picking a model.
- Very specific: line 127
If a docs/butterbase/00-state.md exists in the working directory, prefer invoking via /butterbase-skills:journey-ai so the journey …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Butterbase AI Gateway
Every app has an LLM gateway with chat, embeddings, model listing, configuration, and usage reporting. One umbrella tool: manage_ai.
| Action | What it does | Returns |
chat | Synchronous chat completion (no streaming) | OpenAI-shaped { choices: [...] } |
embed | Vector embeddings for string or string[] | OpenAI-shaped { data: [{ embedding: [...] }] } |
list_models | Available models with capabilities | { models: AiModel[] } |
get_config | Current AI config (default model, BYOK key flag, etc.) | AiConfig |
update_config | Set defaults, allowed models, max tokens, BYOK | AiConfig |
get_usage | Token + cost aggregate over a window | usage record |
1. Chat
manage_ai({
action: "chat",
app_id,
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What's RAG?" }
],
model: "openai/gpt-4o-mini", // optional — falls back to app's default
temperature: 0.2, // optional
max_tokens: 500 // optional
})This action sets stream: false deliberately — agent tools don't stream. If you need partial-token deltas, drive the SDK's ai.chatStream(…) from inside a function or DO instead.
messages[].content can be a string or an array of content parts ({ type: "text", text }, { type: "image_url", image_url: {...} }, { type: "video_url", video_url: {...} }).
2. Embed
manage_ai({
action: "embed",
app_id,
input: "hello world", // or ["a", "b", "c"]
model: "openai/text-embedding-3-small", // optional
encoding_format: "float" // or "base64"
})3. List models
manage_ai({ action: "list_models", app_id })
// → { models: [{ id, provider, capabilities: ["chat", "embed", ...], context_window, pricing }, ...] }Use this to discover what the app can call — capabilities + context window matter when picking a model.
4. Configure
manage_ai({
action: "update_config",
app_id,
config: {
defaultModel: "openai/gpt-4o-mini",
allowedModels: ["openai/gpt-4o-mini", "anthropic/claude-haiku-4-5"],
maxTokensPerRequest: 4000,
byokKey: "..." // optional — rotates the customer-supplied OpenRouter / Anthropic key
}
})maxTokensPerRequestis server-clamped to 1–100000.allowedModelsis a whitelist — empty means all models the provider exposes.- Setting
byokKeyswitches the app to route through that customer key. Clear it by passingbyokKey: ""(returns to platform pool).
5. Usage
manage_ai({
action: "get_usage",
app_id,
startDate: "2026-05-01",
endDate: "2026-05-31"
})Returns aggregate token counts + cost. Useful for billing reconciliation, spending-cap diagnostics, and showing dashboards.
6. Common pitfalls
- Trying to stream from a tool —
manage_aiis synchronous. Use the SDK inside a function for streamed deltas. - Sending
stream: truein the body — the tool ignores it; always wired tofalse. - Hardcoding
model— better to omit, let the app'sdefaultModelwin, and surface that knob viaupdate_config. - Skipping
list_modelsbefore suggesting one — model availability shifts; verify before recommending.
7. What this skill does NOT cover
- Streaming chat — use the SDK (
ai.chatStream) inside a function or DO. - Vector storage / retrieval — see
butterbase-skills:rag-dev(RAG collections wrap embeddings + search together). - AI in deployed functions — they import
@butterbase/sdkand callclient.ai.*directly; no MCP needed at runtime.
8. Decisions (typed classification)
For routing, classification, moderation or scoring, where code needs a choice / yes-no / score with probabilities, use manage_ai action: "decide" (SDK ai.decide) with a decision model (default typesafe/jev-1.13) instead of asking a chat model for JSON. It is cheaper, faster and returns typed probabilities. Full reference: butterbase_docs topic ai, "Decision models".
If a docs/butterbase/00-state.md exists in the working directory, prefer invoking via /butterbase-skills:journey-ai so the journey orchestrator stays in sync.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

