1- # @eternalai-org/typescript- sdk
1+ # @eternalai-org/sdk
22
33Official TypeScript SDK for ** EternalAI** - The next-generation API platform for AI applications. Access hundreds of AI models through one unified interface with cashback rewards on every API call.
44
5- [ ![ npm version] ( https://img.shields.io/npm/v/@eternalai-org/typescript-sdk.svg )] ( https://www.npmjs.com/package/@eternalai-org/typescript-sdk )
5+ [ ![ npm version] ( https://img.shields.io/npm/v/@eternalai-org/sdk.svg )] ( https://www.npmjs.com/package/@eternalai-org/sdk )
6+ [ ![ Bun] ( https://img.shields.io/badge/Bun-1.0+-black?logo=bun )] ( https://bun.sh )
7+ [ ![ Yarn] ( https://img.shields.io/badge/Yarn-1.22+-2C8EBB?logo=yarn&logoColor=white )] ( https://yarnpkg.com )
68[ ![ TypeScript] ( https://img.shields.io/badge/TypeScript-5.3-blue.svg )] ( https://www.typescriptlang.org/ )
79[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( ./LICENSE )
810
911## Quick Start
1012
1113``` typescript
12- import { EternalAPI } from ' @eternalai-org/typescript- sdk' ;
14+ import { EternalAPI } from ' @eternalai-org/sdk' ;
1315
1416const eternalApi = new EternalAPI ({ apiKey: ' your-api-key' });
1517
@@ -29,24 +31,53 @@ for await (const chunk of result) {
2931}
3032```
3133
34+ ### Image Generation Example
35+
36+ For models that support image generation, you can configure image options:
37+
38+ ``` typescript
39+ const result = await eternalApi .chat .send ({
40+ messages: [
41+ {
42+ role: ' user' ,
43+ content: ' Generate a beautiful landscape' ,
44+ },
45+ ],
46+ model: ' image-generation-model' ,
47+ image_config: {
48+ aspect_ratio: ' 16:9' , // Optional: '16:9', '1:1', '9:16', etc.
49+ },
50+ stream: false ,
51+ });
52+
53+ console .log (result .choices [0 ].message .content );
54+ ```
55+
3256## Installation
3357
3458Install from npm:
3559
3660``` bash
61+ # Using Bun (recommended)
62+ bun add @eternalai-org/sdk
63+
3764# Using npm
38- npm install @eternalai-org/typescript- sdk
65+ npm install @eternalai-org/sdk
3966
4067# Using yarn
41- yarn add @eternalai-org/typescript- sdk
68+ yarn add @eternalai-org/sdk
4269
4370# Using pnpm
44- pnpm add @eternalai-org/typescript- sdk
71+ pnpm add @eternalai-org/sdk
4572```
4673
4774Or install directly from GitHub:
4875
4976``` bash
77+ # Using Bun
78+ bun add git+https://github.com/eternalai-org/sdk.git
79+
80+ # Using npm
5081npm install git+https://github.com/eternalai-org/sdk.git
5182```
5283
@@ -123,6 +154,8 @@ Send a chat completion request.
123154- ` request.messages ` (ChatMessage[ ] , required) - Array of chat messages
124155- ` request.model ` (string, required) - Model name (e.g., ` "openai/gpt-5.1" ` )
125156- ` request.stream ` (boolean, optional) - Enable streaming responses (default: ` false ` )
157+ - ` request.image_config ` (ImageConfigOptions, optional) - Image generation configuration for models that support image generation
158+ - ` image_config.aspect_ratio ` (string, optional) - Aspect ratio for generated images (e.g., ` "16:9" ` , ` "1:1" ` , ` "9:16" ` )
126159
127160** Returns:**
128161
@@ -148,7 +181,7 @@ import type {
148181 ChatCompletionMessage ,
149182 ChatCompletionNonStreamingChoice ,
150183 ChatCompletionResponse ,
151- } from ' @eternalai-org/typescript- sdk' ;
184+ } from ' @eternalai-org/sdk' ;
152185```
153186
154187## Error Handling
@@ -166,10 +199,11 @@ try {
166199}
167200```
168201
169- ## Browser vs Node.js
202+ ## Browser vs Node.js vs Bun
170203
171- This SDK works in both Node.js and browser environments:
204+ This SDK works in multiple environments:
172205
206+ - ** Bun** - Full support (v1.0.0+) - Recommended for best performance
173207- ** Node.js** - Full support (v18+)
174208- ** Browser** - Requires a bundler (Webpack, Vite, etc.) that supports ESM
175209
@@ -178,13 +212,14 @@ This SDK works in both Node.js and browser environments:
178212This SDK includes a comprehensive test suite. To run the tests:
179213
180214``` bash
181- # Run all tests
182- npm test
215+ # Using Bun (recommended)
216+ bun test
217+ bun run test:watch
218+ bun run test:coverage
183219
184- # Run tests in watch mode
220+ # Using npm
221+ npm test
185222npm run test:watch
186-
187- # Generate coverage report
188223npm run test:coverage
189224```
190225
@@ -208,7 +243,7 @@ MIT - see [LICENSE](./LICENSE) file for details.
208243## Support
209244
210245For issues and questions:
211- - π¦ ** npm Package** : [ npmjs.com/package/@eternalai-org/typescript- sdk ] ( https://www.npmjs.com/package/@eternalai-org/typescript- sdk )
246+ - π¦ ** npm Package** : [ npmjs.com/package/@eternalai-org/sdk ] ( https://www.npmjs.com/package/@eternalai-org/sdk )
212247- π ** Website** : [ eternalai.org] ( https://eternalai.org )
213248- π ** API Platform** : [ eternalai.org/api/build] ( https://eternalai.org/api/build )
214249- π ** GitHub Issues** : [ github.com/eternalai-org/sdk/issues] ( https://github.com/eternalai-org/sdk/issues )
0 commit comments