pinme-llm

Use this skill when a PinMe project (Worker TypeScript) needs to call OpenRouter-backed LLM APIs, including models, chat/completions, streaming, or OpenRouter web search. Guides AI to generate correct Worker TS code.

By glitternetwork · 475 installs

npx skills add glitternetwork/pinme --skill pinme-llm

Source repository · Upstream listing

PinMe Worker OpenRouter API Integration Guides how to call PinMe platform's OpenRouter proxy APIs in a PinMe Worker (TypeScript). Workers use the PinMe project API key; they never hold the real OpenRouter API key. Environment Variables The following environment variables are automatically injected when the Worker is created — no manual configuration needed: API KEY authenticates the Worker to PinMe. PROJECT NAME is required for chat/completions and must belong to the same project as API KEY . When BASE URL is not set, use https://pinme.cloud . Models API Endpoint: GET {BASE URL}/api/v1/models Authentication: X API Key header (using env.API KEY ) Request Body: none Use this when the Worker needs to list available OpenRouter models. The response body, status, and headers are passed through from OpenRouter /models . Chat Completions API Endpoint: POST {BASE URL}/api/v1/chat/completions?project name={project name} Authentication: X API Key header (using env.API KEY ) Request Body: OpenRouter chat/completions format, passed through as is after a 1MB size check Streaming: Supports SSE ( stream: true ) Web Search: Supports OpenRouter openrouter:web search server tool via the tools array Request Format Use env.PROJECT NAME from create worker ; always URL encode it in the query string. For available models, call GET /api/v1/models or refer to OpenRouter model IDs. OpenRouter Web Search PinMe does not provide a raw search endpoint. To search the web, pass OpenRouter's openrouter:web search server tool to chat/completions ; the model decides whether and when to search. Always set max results and max total results to keep search volume and cost bounded. Response Format Successful requests return OpenRouter's raw response body. Non streaming Success (200): Streaming Success (200): SSE format Errors: HTTP Status Meaning data.error Example 401 API Key missing, invalid, or mismatched with project name "X API Key header is required" / "Invalid API key" / "Invalid API key or project name" 400 project name missing or OpenRouter key not configured "project name is required" / "LLM service not configured for this project" 403 LLM balance insufficient or disabled "Insufficient balance, please recharge to continue using LLM service" 413 Request body exceeds 1MB "Request body too large (max 1MB)" 500 Proxy failed before upstream request "Failed to build request" 502 LLM service unavailable "LLM service unavailable" If OpenRouter receives the request and returns a 4xx/5xx, PinMe passes through OpenRouter's status, headers, and response body instead of wrapping it. Worker Example Code — Non streaming Worker Example Code — Streaming (SSE Passthrough) Frontend SSE Stream Consumer Example Error Handling Pattern For /api/v1/models and /api/v1/chat/completions , successful responses are raw OpenRouter responses. Proxy failures before the OpenRouter request use PinMe's wrapped error format: Recommended Error Extractor Optional JSON Helper Use this helper for non streaming POST calls. It returns the raw OpenRouter JSON on success. Usage Example