Home/Tools/@tpmjs/tools-openrouter

assignGuardrailKeys

@tpmjs/tools-openrouter

Bulk assign API keys to a guardrail.

Official
agent
v0.1.0
MIT

Interactive Playground

Test @tpmjs/tools-openrouter (assignGuardrailKeys) with AI-powered execution

0/2000 characters

Installation & Usage

Install this tool and use it with the AI SDK

1. Install the package

npm install @tpmjs/tools-openrouter
pnpm add @tpmjs/tools-openrouter
yarn add @tpmjs/tools-openrouter
bun add @tpmjs/tools-openrouter
deno add npm:@tpmjs/tools-openrouter

2. Import the tool

import { assignGuardrailKeys } from '@tpmjs/tools-openrouter';

3. Use with AI SDK

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { assignGuardrailKeys } from '@tpmjs/tools-openrouter';

const result = await generateText({
  model: openai('gpt-4o'),
  tools: { assignGuardrailKeys },
  prompt: 'Your prompt here...',
});

console.log(result.text);

Signature

(id: string, key_hashes: string[]) => Promise<unknown>

Tags

agent
ai
api
assign
bulk
guardrail
keys
llm
openrouter
tpmjs

Parameters

Available configuration options

Auto-extracted
id
Required
Type: string

Guardrail ID

key_hashes
Required
Type: array

Array of API key hashes to assign

Schema extracted: 2/28/2026, 4:02:23 AM

README

@tpmjs/tools-openrouter

Complete OpenRouter API tools for AI agents. 33 tools covering chat completions, embeddings, model discovery, API key management, credits, analytics, and guardrails.

Installation

npm install @tpmjs/tools-openrouter

Environment Variables

VariableRequiredDescription
OPENROUTER_API_KEYYesYour OpenRouter API key
OPENROUTER_REFERERNoHTTP Referer header (default: https://tpmjs.com)
OPENROUTER_TITLENoX-Title header (default: TPMJS Agent)

Tools

Chat & AI

ToolDescription
chatCompletionSend chat completions to 400+ models
createResponseResponses API (beta)
createEmbeddingGenerate text embeddings

Models & Discovery

ToolDescription
listModelsList all models with pricing
countModelsGet total model count
listUserModelsModels filtered by user prefs
listEmbeddingModelsList embedding models
listProvidersList all providers
listEndpointsEndpoints for a specific model
previewZdrPreview ZDR impact

Account

ToolDescription
getCreditsGet remaining credits
createCoinbaseChargeAdd credits via crypto
getUserActivityUsage analytics
getGenerationGeneration metadata by ID

API Keys

ToolDescription
listApiKeysList all API keys
createApiKeyCreate new key
getApiKeyGet key by hash
getCurrentApiKeyGet current key details
updateApiKeyUpdate key settings
deleteApiKeyDelete a key

Guardrails

ToolDescription
listGuardrailsList all guardrails
createGuardrailCreate guardrail
getGuardrailGet guardrail details
updateGuardrailUpdate guardrail
deleteGuardrailDelete guardrail
listGuardrailKeyAssignmentsAll key assignments
listGuardrailMemberAssignmentsAll member assignments
getGuardrailKeysKeys for a guardrail
assignGuardrailKeysAssign keys
getGuardrailMembersMembers for a guardrail
assignGuardrailMembersAssign members
unassignGuardrailKeysUnassign keys
unassignGuardrailMembersUnassign members

Usage

import { chatCompletion, listModels, getCredits } from '@tpmjs/tools-openrouter';

// Chat completion
const result = await chatCompletion.execute({
  model: 'openai/gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }],
});

// List models
const models = await listModels.execute({});

// Check credits
const credits = await getCredits.execute({});

License

MIT

Statistics

Downloads/month

94

GitHub Stars

0

Quality Score

77%

Bundle Size

NPM Keywords

tpmjs
openrouter
llm
ai
agent
api

Maintainers

thomasdavis(thomasalwyndavis@gmail.com)

Frameworks

vercel-ai