Halfred Node.js SDK
Official Halfred SDK for Node.js and TypeScript with modern JavaScript features, full type support, and easy integration.
Installation
npm install halfred.aiyarn add halfred.aipnpm add halfred.aiQuick Start
Basic Setup
import { Halfred } from "halfred.ai";
const client = new Halfred({
apiKey: "halfred_xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
});
async function main() {
const completion = await client.chat.completions.create({
model: "lite",
messages: [{ role: "user", content: "What is the capital of France?" }],
});
console.log(completion.choices[0].message.content);
}
main();With Environment Variables (Recommended)
Chat Completions
Simple Completion
With System Message
Conversation History
With Options
Choosing a Model Profile
Response Format
JSON Mode
JSON Schema Mode
Error Handling
Streaming Responses (Coming Soon)
List Available Models
Best Practices
1. Use Environment Variables
2. Handle Errors Gracefully
3. Choose the Right Profile
4. Monitor Token Usage
Troubleshooting
Module Not Found
TypeScript Errors
API Key Issues
Support
Next Steps
Last updated