@payhos/api
v2.5.0
Published
An API package for payhos's API built for JavaScript and Typescript developers
Readme
PayHos API SDK
PayHos is an easy go-to solution for many day-to-day application problems by providing an easily access to send emails, SMS etc. For a full documentations of PayHos API and fully supported features, visit PayHos API Docs.
This API SDK is intended to assist web applications of any kind to interact with the PayHos API server by utilizing its simple schematics. For a more modular usage, this library is designed such that bundlers with tree-shaking is enhanced.
PayHos API SDK
PayHos provides a small client SDK to interact with the PayHos API for sending email, SMS and requesting prerendered HTML pages.
Install
npm install @payhos/api --saveSMS
Use the sms helper to send messages.
import { PayHos } from "@payhos/api";
const payhos = new PayHos("<YOUR_API_TOKEN>");
await payhos.sms.send({
message: "Hello from PayHos",
recipients: ["+1234567890"],
senderId: "PayHos",
});Use the email helper to send emails.
import { PayHos } from "@payhos/api";
const payhos = new PayHos("<YOUR_API_TOKEN>");
await payhos.email.send({
subject: "Hi",
html: "<p>Hello</p>",
recipients: [{ email: "[email protected]", name: "Jane" }],
sender: { name: "PayHos", email: "[email protected]" },
});Prerender
Use the prerender helper to request a pre-rendered HTML snapshot of a URL.
import { PayHos } from "@payhos/api";
const payhos = new PayHos("<YOUR_API_TOKEN>");
const resp = await payhos.prerender.page({
url: "https://example.com",
cacheMs: 86400000,
});
console.log(resp.data);AI
Use the ai helper to send prompts to PayHos AI API.
import { PayHos } from "@payhos/api";
const payhos = new PayHos("<YOUR_API_TOKEN>");
const resp = await payhos.ai.prompt({
prompt: "Write a short release note for a payments API update.",
});
if (resp.success && resp.data) {
console.log(resp.data.response);
console.log(resp.data.usage.totalChars, resp.data.usage.cost);
}AI provider selection
const geminiResp = await payhos.ai.prompt({
prompt: "Summarize this in 3 bullets",
provider: "gemini", // default if omitted
model: "gemini-2.0-flash-lite",
temperature: 0.6,
maxInputChars: 4000,
maxOutputChars: 1200,
});
const gptResp = await payhos.ai.prompt({
prompt: "Create a concise onboarding checklist.",
provider: "gpt",
model: "gpt-4o-mini",
});AI billing
- Rate:
0.003 USDper1000characters - Metering basis: prompt characters + response characters
- Usage details are returned in
data.usage
// Example usage payload shape
// {
// inputChars: number,
// outputChars: number,
// totalChars: number,
// cost: number,
// ratePer1000Chars: number
// }For full API details, see https://docs.payhos.com.
