primellm-sdk
v1.0.0
Published
Official JavaScript SDK for PrimeLLM - Tool calling, streaming, multi-turn agents.
Maintainers
Readme
PrimeLLM JavaScript SDK
Official JavaScript/TypeScript SDK for the PrimeLLM unified AI API.
PrimeLLM lets you access multiple AI models (GPT-5.1, Claude, Gemini) through a single, simple API.
Installation
npm install primellmQuick Start
import PrimeLLM from "primellm";
// Create a client with your API key
const client = new PrimeLLM({
apiKey: "primellm_XXX", // Get from https://primellm.in/dashboard
});
// Send a chat message
const response = await client.chat({
model: "gpt-5.1",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is TypeScript?" },
],
});
// Access the response
console.log(response.choices[0].message.content);
console.log("Tokens used:", response.usage.total_tokens);
console.log("Credits left:", response.credits.remaining);Available Models
| Model | Description |
|-------|-------------|
| gpt-5.1 | Latest GPT model (default) |
| claude-sonnet-4.5 | Claude Sonnet 4.5 |
| gemini-3.0 | Gemini 3.0 |
API Reference
Creating a Client
const client = new PrimeLLM({
apiKey: "primellm_XXX", // Required
baseURL: "https://api.primellm.in", // Optional, this is the default
timeoutMs: 60000, // Optional, 60 seconds default
});client.chat(request)
Send a chat completion request.
const response = await client.chat({
model: "gpt-5.1",
messages: [
{ role: "user", content: "Hello!" }
],
temperature: 0.7, // Optional
max_tokens: 1000, // Optional
});Response:
{
id: "chatcmpl_xxx",
model: "gpt-5.1",
choices: [{
index: 0,
message: { role: "assistant", content: "..." },
finish_reason: "stop"
}],
usage: {
prompt_tokens: 10,
completion_tokens: 20,
total_tokens: 30
},
credits: {
remaining: 149.99,
cost: 0.00006
}
}TypeScript Support
This SDK is written in TypeScript and includes full type definitions.
import PrimeLLM, { ChatRequest, ChatResponse } from "primellm";
const client = new PrimeLLM({ apiKey: "..." });
const request: ChatRequest = {
model: "gpt-5.1",
messages: [{ role: "user", content: "Hello!" }],
};
const response: ChatResponse = await client.chat(request);Error Handling
try {
const response = await client.chat({
model: "gpt-5.1",
messages: [{ role: "user", content: "Hello!" }],
});
} catch (error) {
console.error("API Error:", error.message);
}License
MIT
