edgee 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Edgee TypeScript SDK
2
2
 
3
- Lightweight, type-safe TypeScript SDK for the [Edgee AI Gateway](https://www.edgee.cloud).
3
+ Lightweight, type-safe TypeScript SDK for the [Edgee AI Gateway](https://www.edgee.ai).
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/edgee.svg)](https://www.npmjs.com/package/edgee)
6
6
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
@@ -20,7 +20,11 @@ const edgee = new Edgee("your-api-key");
20
20
 
21
21
  // Send a simple request
22
22
  const response = await edgee.send({
23
- model: 'gpt-4o',
23
+ <<<<<<< HEAD
24
+ model: 'gpt-5.2',
25
+ =======
26
+ model: 'anthropic/claude-haiku-4-5',
27
+ >>>>>>> ecec4c8 (feat: update compression response to new API format)
24
28
  input: 'What is the capital of France?',
25
29
  });
26
30
 
@@ -34,7 +38,7 @@ The `send()` method makes non-streaming chat completion requests:
34
38
 
35
39
  ```typescript
36
40
  const response = await edgee.send({
37
- model: 'gpt-4o',
41
+ model: 'anthropic/claude-haiku-4-5',
38
42
  input: 'Hello, world!',
39
43
  });
40
44
 
@@ -42,6 +46,18 @@ const response = await edgee.send({
42
46
  console.log(response.text); // Text content
43
47
  console.log(response.finishReason); // Finish reason
44
48
  console.log(response.toolCalls); // Tool calls (if any)
49
+
50
+ // Access usage and compression info
51
+ if (response.usage) {
52
+ console.log(`Tokens used: ${response.usage.total_tokens}`);
53
+ }
54
+
55
+ if (response.compression) {
56
+ console.log(`Saved tokens: ${response.compression.saved_tokens}`);
57
+ console.log(`Reduction: ${response.compression.reduction}%`);
58
+ console.log(`Cost savings: $${(response.compression.cost_savings / 1_000_000).toFixed(3)}`);
59
+ console.log(`Time: ${response.compression.time_ms} ms`);
60
+ }
45
61
  ```
46
62
 
47
63
  ## Stream Method
@@ -49,7 +65,7 @@ console.log(response.toolCalls); // Tool calls (if any)
49
65
  The `stream()` method enables real-time streaming responses:
50
66
 
51
67
  ```typescript
52
- for await (const chunk of edgee.stream('gpt-4o', 'Tell me a story')) {
68
+ for await (const chunk of edgee.stream('anthropic/claude-haiku-4-5', 'Tell me a story')) {
53
69
  if (chunk.text) {
54
70
  process.stdout.write(chunk.text);
55
71
  }
@@ -67,19 +83,20 @@ for await (const chunk of edgee.stream('gpt-4o', 'Tell me a story')) {
67
83
  - ✅ **Streaming** - Real-time response streaming
68
84
  - ✅ **Tool calling** - Full support for function calling
69
85
  - ✅ **Flexible input** - Accept strings or structured objects
86
+ - ✅ **Compression info** - Access token compression metrics in responses
70
87
  - ✅ **Zero dependencies** - Lightweight and fast
71
88
 
72
89
  ## Documentation
73
90
 
74
91
  For complete documentation, examples, and API reference, visit:
75
92
 
76
- **👉 [Official TypeScript SDK Documentation](https://www.edgee.cloud/docs/sdk/typescript)**
93
+ **👉 [Official TypeScript SDK Documentation](https://www.edgee.ai/docs/sdk/typescript)**
77
94
 
78
95
  The documentation includes:
79
- - [Configuration guide](https://www.edgee.cloud/docs/sdk/typescript/configuration) - Multiple ways to configure the SDK
80
- - [Send method](https://www.edgee.cloud/docs/sdk/typescript/send) - Complete guide to non-streaming requests
81
- - [Stream method](https://www.edgee.cloud/docs/sdk/typescript/stream) - Streaming responses guide
82
- - [Tools](https://www.edgee.cloud/docs/sdk/typescript/tools) - Function calling guide
96
+ - [Configuration guide](https://www.edgee.ai/docs/sdk/typescript/configuration) - Multiple ways to configure the SDK
97
+ - [Send method](https://www.edgee.ai/docs/sdk/typescript/send) - Complete guide to non-streaming requests
98
+ - [Stream method](https://www.edgee.ai/docs/sdk/typescript/stream) - Streaming responses guide
99
+ - [Tools](https://www.edgee.ai/docs/sdk/typescript/tools) - Function calling guide
83
100
 
84
101
  ## License
85
102
 
package/dist/index.d.ts CHANGED
@@ -33,6 +33,9 @@ export interface InputObject {
33
33
  messages: Message[];
34
34
  tools?: Tool[];
35
35
  tool_choice?: ToolChoice;
36
+ tags?: string[];
37
+ enable_compression?: boolean;
38
+ compression_rate?: number;
36
39
  }
37
40
  export interface SendOptions {
38
41
  model: string;
@@ -54,10 +57,21 @@ export declare class SendResponse {
54
57
  completion_tokens: number;
55
58
  total_tokens: number;
56
59
  };
60
+ compression?: {
61
+ saved_tokens: number;
62
+ cost_savings: number;
63
+ reduction: number;
64
+ time_ms: number;
65
+ };
57
66
  constructor(choices: Choice[], usage?: {
58
67
  prompt_tokens: number;
59
68
  completion_tokens: number;
60
69
  total_tokens: number;
70
+ }, compression?: {
71
+ saved_tokens: number;
72
+ cost_savings: number;
73
+ reduction: number;
74
+ time_ms: number;
61
75
  });
62
76
  get text(): string | null;
63
77
  get message(): {
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  export class SendResponse {
2
- constructor(choices, usage) {
2
+ constructor(choices, usage, compression) {
3
3
  this.choices = choices;
4
4
  this.usage = usage;
5
+ this.compression = compression;
5
6
  }
6
7
  get text() {
7
8
  if (this.choices[0]?.message?.content) {
@@ -74,6 +75,12 @@ export default class Edgee {
74
75
  body.tools = input.tools;
75
76
  if (input.tool_choice)
76
77
  body.tool_choice = input.tool_choice;
78
+ if (input.tags)
79
+ body.tags = input.tags;
80
+ if (input.enable_compression !== undefined)
81
+ body.enable_compression = input.enable_compression;
82
+ if (input.compression_rate !== undefined)
83
+ body.compression_rate = input.compression_rate;
77
84
  }
78
85
  const res = await fetch(`${this.baseUrl}/v1/chat/completions`, {
79
86
  method: "POST",
@@ -88,7 +95,7 @@ export default class Edgee {
88
95
  throw new Error(`API error ${res.status}: ${errorBody}`);
89
96
  }
90
97
  const data = await res.json();
91
- return new SendResponse(data.choices, data.usage);
98
+ return new SendResponse(data.choices, data.usage, data.compression);
92
99
  }
93
100
  async *_handleStreamingResponse(url, body) {
94
101
  const res = await fetch(url, {
@@ -149,6 +156,12 @@ export default class Edgee {
149
156
  body.tools = input.tools;
150
157
  if (input.tool_choice)
151
158
  body.tool_choice = input.tool_choice;
159
+ if (input.tags)
160
+ body.tags = input.tags;
161
+ if (input.enable_compression !== undefined)
162
+ body.enable_compression = input.enable_compression;
163
+ if (input.compression_rate !== undefined)
164
+ body.compression_rate = input.compression_rate;
152
165
  }
153
166
  yield* this._handleStreamingResponse(`${this.baseUrl}/v1/chat/completions`, body);
154
167
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "edgee",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/edgee-cloud/typescript-sdk"
9
+ "url": "https://github.com/edgee-ai/typescript-sdk"
10
10
  },
11
11
  "exports": {
12
12
  ".": {