@stnd/ai
Circle 4 — Experimental / Paused · Paused / Reference Draft
Role: OpenRouter LLM client and streaming prompt helpers (currently paused in favor of
@stnd/mcpand Cloudflare AI bindings).When to use: Status: Paused. For AI agent integration and code verification, use
@stnd/mcp.
Quick Start (TL;DR)
// Status: Paused — prefer @stnd/mcp or native Cloudflare Workers AI
OpenRouter AI integration for the Standard Ecosystem.
ELI5
One small client, one API key, and you can call an LLM from Standard code without re-implementing provider plumbing each time.
Overview
@stnd/ai provides a simple and unified interface for interacting with various Large Language Models (LLMs) via OpenRouter. It is designed to work seamlessly within Astro applications and Cloudflare Workers.
Key Features
- Unified API: Access any model supported by OpenRouter with a consistent pattern.
- Streaming Support: Built-in support for streaming responses for real-time interactions.
- Prompt Templates: Utilities for managing and formatting complex prompts.
- Edge-Ready: Optimized for deployment on Cloudflare Pages and Workers.
Usage
import { AI } from "@stnd/ai";
const ai = new AI({
apiKey: process.env.OPENROUTER_API_KEY,
model: "google/gemini-2.0-flash-001"
});
const response = await ai.chat([
{ role: "user", content: "Explain the golden ratio in typography." }
]);
console.log(response.text);
Configuration
The package can be configured globally via the @stnd/core integration or per-instance.
apiKey: Your OpenRouter API key.model: The default model to use.baseURL: (Optional) Custom base URL for OpenRouter API.