Lightweight, type-safe TypeScript SDK for the Edgee AI Gateway.
npm install edgee
import Edgee from 'edgee'; const edgee = new Edgee("your-api-key"); // Send a simple request const response = await edgee.send({ model: 'anthropic/claude-haiku-4-5', input: 'What is the capital of France?', }); console.log(response.text); // "The capital of France is Paris."
The send() method makes non-streaming chat completion requests:
const response = await edgee.send({ model: 'anthropic/claude-haiku-4-5', input: 'Hello, world!', }); // Access response console.log(response.text); // Text content console.log(response.finishReason); // Finish reason console.log(response.toolCalls); // Tool calls (if any) // Access usage and compression info if (response.usage) { console.log(`Tokens used: ${response.usage.total_tokens}`); } if (response.compression) { console.log(`Saved tokens: ${response.compression.saved_tokens}`); console.log(`Reduction: ${response.compression.reduction}%`); console.log(`Cost savings: $${(response.compression.cost_savings / 1_000_000).toFixed(3)}`); console.log(`Time: ${response.compression.time_ms} ms`); }
The stream() method enables real-time streaming responses:
for await (const chunk of edgee.stream('anthropic/claude-haiku-4-5', 'Tell me a story')) { if (chunk.text) { process.stdout.write(chunk.text); } if (chunk.finishReason) { console.log(`\nFinished: ${chunk.finishReason}`); } }
- ✅ Type-safe - Full TypeScript support with comprehensive types
- ✅ OpenAI-compatible - Works with any model supported by Edgee
- ✅ Streaming - Real-time response streaming
- ✅ Tool calling - Full support for function calling
- ✅ Flexible input - Accept strings or structured objects
- ✅ Compression info - Access token compression metrics in responses
- ✅ Zero dependencies - Lightweight and fast
For complete documentation, examples, and API reference, visit:
👉 Official TypeScript SDK Documentation
The documentation includes:
- Configuration guide - Multiple ways to configure the SDK
- Send method - Complete guide to non-streaming requests
- Stream method - Streaming responses guide
- Tools - Function calling guide
Licensed under the Apache License, Version 2.0. See LICENSE for details.