Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 56 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,86 @@
# Edgee Gateway SDK
# Edgee TypeScript SDK

Lightweight TypeScript SDK for Edgee AI Gateway.
Lightweight, type-safe TypeScript SDK for the [Edgee AI Gateway](https://www.edgee.cloud).

[![npm version](https://img.shields.io/npm/v/edgee.svg)](https://www.npmjs.com/package/edgee)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)

## Installation

```bash
npm install edgee
```

## Usage
## Quick Start

```typescript
import Edgee from "edgee";

const edgee = new Edgee(process.env.EDGEE_API_KEY);
```
import Edgee from 'edgee';

### Simple Input
const edgee = new Edgee("your-api-key");

```typescript
// Send a simple request
const response = await edgee.send({
model: "gpt-4o",
input: "What is the capital of France?",
model: 'gpt-4o',
input: 'What is the capital of France?',
});

console.log(response.choices[0].message.content);
console.log(response.text);
// "The capital of France is Paris."
```

### Full Input with Messages

```typescript
const response = await edgee.send({
model: "gpt-4o",
input: {
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Hello!" },
],
},
});
```
## Send Method

### With Tools
The `send()` method makes non-streaming chat completion requests:

```typescript
const response = await edgee.send({
model: "gpt-4o",
input: {
messages: [{ role: "user", content: "What's the weather in Paris?" }],
tools: [
{
type: "function",
function: {
name: "get_weather",
description: "Get weather for a location",
parameters: {
type: "object",
properties: {
location: { type: "string" },
},
},
},
},
],
tool_choice: "auto",
},
model: 'gpt-4o',
input: 'Hello, world!',
});

if (response.choices[0].message.tool_calls) {
console.log(response.choices[0].message.tool_calls);
}
// Access response
console.log(response.text); // Text content
console.log(response.finishReason); // Finish reason
console.log(response.toolCalls); // Tool calls (if any)
```

## Response
## Stream Method

The `stream()` method enables real-time streaming responses:

```typescript
interface SendResponse {
choices: {
index: number;
message: {
role: string;
content: string | null;
tool_calls?: ToolCall[];
};
finish_reason: string | null;
}[];
usage?: {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
};
for await (const chunk of edgee.stream('gpt-4o', 'Tell me a story')) {
if (chunk.text) {
process.stdout.write(chunk.text);
}

if (chunk.finishReason) {
console.log(`\nFinished: ${chunk.finishReason}`);
}
}
```

## Features

- ✅ **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
- ✅ **Zero dependencies** - Lightweight and fast

## Documentation

For complete documentation, examples, and API reference, visit:

**👉 [Official TypeScript SDK Documentation](https://www.edgee.cloud/docs/sdk/typescript)**

The documentation includes:
- [Configuration guide](https://www.edgee.cloud/docs/sdk/typescript/configuration) - Multiple ways to configure the SDK
- [Send method](https://www.edgee.cloud/docs/sdk/typescript/send) - Complete guide to non-streaming requests
- [Stream method](https://www.edgee.cloud/docs/sdk/typescript/stream) - Streaming responses guide
- [Tools](https://www.edgee.cloud/docs/sdk/typescript/tools) - Function calling guide

## License

Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.