Never paste your Paystack secret key (sk_live_... or sk_test_...) into an LLM chat or prompt. Risks: the key may be included in model fine-tuning data, logged by the AI provider, visible to anyone with access to your conversation history, and leaves no audit trail of which AI action used which key. Correct pattern: run a server-side tool/function that calls Paystack using the secret key stored in environment variables — the LLM calls the tool, never sees the key.
When you paste text into an LLM chat or prompt, that text may be:
A Paystack live secret key can: initialize transactions, charge cards via the Charge API, trigger transfers to bank accounts, access all your customer and transaction data, and create subaccounts. One exposed key can drain your Paystack balance.
Give the LLM a tool (function) to call, not the key directly. The tool lives on your server where the key is safe:
// Server-side tool definition (for Claude API function calling)
const tools = [
{
name: 'get_transactions',
description: 'Fetch recent Paystack transactions. Returns list of transactions.',
input_schema: {
type: 'object',
properties: {
limit: { type: 'number', description: 'Number of transactions to fetch (max 100)' },
status: { type: 'string', enum: ['success', 'failed', 'pending'] },
},
},
},
];
// When Claude calls this tool, you execute it with the key on your server
async function handleToolCall(toolName, toolInput) {
if (toolName === 'get_transactions') {
var res = await fetch('https://api.paystack.co/transaction?perPage=' + (toolInput.limit || 20), {
headers: { Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY }, // key never leaves server
});
return (await res.json()).data;
}
}
The LLM sees the tool results (transaction data), never the key. The key stays in your environment variable, on your server, under your control.
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
See agentic payout safety rails for broader AI payment security.
KES 2,999
The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.
Start Paystack Course