MCPInstall
caffeinelabs avatar

extension-inference

MANDATORY recipe for every Caffeine build that calls an LLM, chatbot, GPT, or ChatGPT on Caffeine Inference (no user-pasted OpenAI key). The ONLY supported path is the caffeineai-inference-client mops package with Config.fromEnv (), which hands the canister a ready-to-use authenticated config — the app never asks for, stores, or returns a key. Hand-rolling ic.httprequest to inference.caffeine.ai (or api.openai.com) is a FORBIDDEN anti-pattern. Load this skill whenever the user, spec, or any prior task wants an LLM in a Caffeine app — and BEFORE writing any code that talks to an LLM host. Use extension-openai only when the spec explicitly requires a user- or admin-pasted sk-... key against api.openai.com.

Installs
14.3K
Last 24h
+186
Trending rank
#1279
Security
Pass

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/caffeinelabs/skills --skill extension-inference
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads extension-inference automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

Security audits

Independent scans of the skill's instructions and bundled files.

Gen Agent Trust Hub PassSAFE ·This skill provides a secure integration for the Caffeine AI inference platform, focusing on managed authentication to prevent API key exposure. The only identified concern is the standard risk of indirect prompt injection when processing user-supplied input.
Socket PassNo alerts
Snyk PassLOW ·Risk: LOW · No issues

SKILL.md

The instructions your agent reads when the skill is triggered.

Caffeine Inference

LLM extension for Caffeine AI.

Orchestrator routing notes

Treat “use an LLM / GPT / chatbot / summarise with AI” as a first-class platform feature. The default path is Caffeine Inference: an OpenAI-compatible chat endpoint that Caffeine hosts, authenticates, and bills for the app. The canister gets its credentials from the platform at runtime; nobody pastes an API key, and the app never stores or returns one.

User intentCapability
Chat / summarise / classify with an LLM in a Caffeine appcaffeineai-inference-client ChatApi.createChatCompletion via this skill
Call api.openai.com with a user-pasted sk-...extension-openai only

Do not load extension-openai for a normal Caffeine-app LLM. Do not ask the user for an OpenAI API key. Do not add setApiKey endpoints, a key-settings page, or a model picker.

Backend

1. Add caffeineai-inference-client to mops.toml

mops add caffeineai-inference-client@0.2.0

Requires Mops ≥ 2.13. Minimum version: caffeineai-inference-client ≥ 0.2.0.

2. Config comes from the platform

Config.fromEnv<system>() returns a complete Config — endpoint, bearer, and is_replicated = ?false — from the credentials the platform provisions for the app. There is no key to collect and nothing to configure.

  • Call fromEnv<system>() inside the shared method, or in a <system>-parameterised helper, on every request. A module-level let config = fromEnv will not compile, and a cached Config can go stale when the platform rotates credentials on a running canister.
  • It traps when the app has no inference credentials. Let that error reach the caller; hiding it makes a failed AI call look like a working feature:
    • Never pre-check CAFFEINE_INFERENCE_API_KEY (or any other environment variable) and never guard fromEnv with a check that skips the call.
    • Never turn a failed call into an empty success, such as an empty string, an empty list, or placeholder text. Trap or return the error so the frontend can show it and offer a retry.
    • Do not add a "configure AI" empty state or a key-input fallback.
  • Never log the Config, never copy its auth into actor state, and never return it (or any part of it) from a query / shared function.

3. is_replicated = ?false is REQUIRED

fromEnv already sets this. Do not override it to ?true or null.

  1. Security. A replicated outcall sends the bearer from every replica.
  2. Billing. Replicated outcalls multiply inference spend by subnet size.
  3. Determinism. LLM bodies are sampled; consensus would fail.

4. Canonical layout

import Inference "lib/inference";

actor {
  public shared func chat(prompt : Text) : async Text {
    await* Inference.runChat<system>(prompt);
  };
};
import { fromEnv } "mo:caffeineai-inference-client/Config";
import ChatApi "mo:caffeineai-inference-client/Apis/ChatApi";
import ChatCompletionRequest "mo:caffeineai-inference-client/Models/ChatCompletionRequest";
import ChatCompletionRequestMessageOneOf2 "mo:caffeineai-inference-client/Models/ChatCompletionRequestMessageOneOf2";
import Runtime "mo:core/Runtime";

module {
  public func runChat<system>(prompt : Text) : async* Text {
    let config = fromEnv<system>();
    let userMessage = ChatCompletionRequestMessageOneOf2.JSON.init({
      content = #string(prompt);
      role = #user;
    });
    let req = ChatCompletionRequest.JSON.init({
      messages = [#user(userMessage)];
      model = "router";
    });
    let resp = await* ChatApi.createChatCompletion(config, req);
    if (resp.choices.size() == 0) {
      Runtime.trap("Inference returned no choices");
    };
    resp.choices[0].message.content
      ?? Runtime.trap("Inference returned no text content");
  };
};

5. model = "router" — the platform picks the model

"router" is the only public model id, and it is a routing tier rather than a model name. Caffeine Inference sizes each request to the complexity of the query — a small fast model for simple prompts, a stronger one for hard reasoning — and reports "router" back as the response model, so provider names never reach the app.

  • Always send model = "router".
  • Do not add a model dropdown, a "use GPT-4" toggle, or a model parameter on the backend endpoint. There is nothing for the user to choose.
  • Steer quality with the prompt and with the declared sampling fields (temperature, top_p, max_completion_tokens), not with model selection.

6. Call shapes

  • Function form: ChatApi.createChatCompletion(config, req) : async* — use await*.
  • Suite form: let api = ChatApi(config); api.createChatCompletion(req) : async.

7. Available API surface — chat completions

caffeineai-inference-client@0.2.0 is generated from public-api-v0.1.0:

ModuleEntry pointRoute
ChatApicreateChatCompletionPOST /v1/chat/completions
ModelsApilistModelsGET /v1/models — catalog only; the model is always "router", so an app never needs this
<!-- motoko-check:skip -->
import ChatApi "mo:caffeineai-inference-client/Apis/ChatApi";
import { fromEnv } "mo:caffeineai-inference-client/Config";

Chat completions are the whole product surface. Not available on this host (404, and not in the package): embeddings, images, audio, moderations, files, legacy completions, Assistants, Responses, and raw ic.http_request. If the spec genuinely needs an OpenAI-only API with a pasted sk-..., switch to extension-openai.

8. Cycles

Leave cycles unset (null): each call attaches the fee the IC charges for that request, which is zero on subnets where outcalls are free. ?n attaches exactly n cycles: the IC rejects the call when n is below its fee, and the call traps on a subnet where the canister holds fewer than n.

Streaming (stream = ?true) is unsupported — management-canister HTTP returns the full body. Leave stream = null.

9. Things that will bite you

  • Call fromEnv<system>() inside the shared method (or a <system> helper). A module-level let config = fromEnv will not compile.
  • Surface failures. No credential pre-checks, no guard around fromEnv, and no empty result in place of an error. See §2.
  • model = "router" — not "gpt-4o-mini". See §5.
  • User turns are #user(ChatCompletionRequestMessageOneOf2.JSON.init({ content = #string(prompt); role = #user })).
  • JSON.init for required fields; layer optionals with record update. Do not hand-list every null.
  • resp.choices[0].message.content is ?Text. Check choices.size() first.
  • One chat call is one HTTP outcall inside an update call: budget seconds, not milliseconds.

Frontend

The app is ready to chat on first load — there is nothing to configure.

  1. No API-key UI. No settings page, no password input, no "configured?" indicator, no localStorage. If a spec or mock shows an "AI settings" screen, drop it.
  2. No model picker. See §5.
  3. Call the backend chat endpoint (chat(prompt)) and render the returned text. There is no frontend LLM SDK — the canister is the client, so the credentials never reach the browser.
  4. Show a pending state while the call is in flight (an outcall round-trip takes seconds) and surface a retry on trap.

FAQ

What does the extension-inference skill do?

MANDATORY recipe for every Caffeine build that calls an LLM, chatbot, GPT, or ChatGPT on Caffeine Inference (no user-pasted OpenAI key). The ONLY supported path is the caffeineai-inference-client mops package with Config.fromEnv (), which hands the canister a ready-to-use authenticated config — the app never asks for, stores, or returns a key. Hand-rolling ic.httprequest to inference.caffeine.ai (or api.openai.com) is a FORBIDDEN anti-pattern. Load this skill whenever the user, spec, or any prior task wants an LLM in a Caffeine app — and BEFORE writing any code that talks to an LLM host. Use extension-openai only when the spec explicitly requires a user- or admin-pasted sk-... key against api.openai.com.

How do I install extension-inference?

Run npx skills add https://github.com/caffeinelabs/skills --skill extension-inference in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/extension-inference/ (personal) or .claude/skills/extension-inference/ (project).

Which AI agents can use extension-inference?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is extension-inference safe to install?

Security partners have reviewed it: Gen Agent Trust Hub passed; Socket passed; Snyk passed. As with any skill, read the SKILL.md and bundled scripts before installing.

Who maintains extension-inference?

It is published by caffeinelabs in caffeinelabs/skills. It has 14,292 recorded installs.

More from caffeinelabs/skills

View all →

Support for organising events/meetings and sending invitations by email.

caffeinelabs avatar

extension-stripe

caffeinelabs/skills

Payment support based on Stripe, supporting credit cards and debit cards. Checkout and session status use HTTP outcalls. For inbound Stripe webhooks (POST to the canister), also load extension-http-endpoints.

Backend & APIs30.6K installs
caffeinelabs avatar

extension-qr-code

caffeinelabs/skills

QR code scanner using the camera.

30.5K installs
caffeinelabs avatar

extension-email-marketing

caffeinelabs/skills

Send personalised marketing emails to subscribers with an unsubscribe link.

Marketing & SEO30.5K installs
caffeinelabs avatar

extension-camera

caffeinelabs/skills

Web-camera support.

30.5K installs
caffeinelabs avatar

extension-authorization

caffeinelabs/skills

Authorization system with role-based access control. Must-have for all apps that manage personal or access-restricted data.

30.5K installs

Popular ai & agents skills

View category →
google avatar

google-agents-cli-publish

google/agents-cli

This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).

AI & Agents556.1K installs
google avatar

google-agents-cli-eval

google/agents-cli

This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).

AI & Agents555.2K installs
anthropics avatar

skill-creator

anthropics/skills

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.

OfficialAI & Agents426.7K installs
prime-skills avatar

codex-pet

prime-skills/runcomfy-agent-skills

Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.

AI & Agents407.2K installs
leonxlnx avatar

full-output-enforcement

leonxlnx/taste-skill

Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.

AI & Agents401.1K installs
obra avatar

executing-plans

obra/superpowers

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

AI & Agents255.9K installs