@echollm/echo-sdk
v1.0.1
Published
Edge-first API relay that streams tokens in the OpenAI Responses SSE schema and injects ads mid-stream. Auth via short-lived JWT from POST /api/auth. Chat relay streams to client and publishes plain-text deltas to a KV bridge for AdRetrieval; when AdRetri
Maintainers
Readme
EchoApi TypeScript SDK 1.0.0
Welcome to the EchoApi SDK documentation. This guide will help you get started with integrating and using the EchoApi SDK in your project.
Versions
- SDK version:
1.0.0
About the API
Edge-first API relay that streams tokens in the OpenAI Responses SSE schema and injects ads mid-stream. Auth via short-lived JWT from POST /api/auth. Chat relay streams to client and publishes plain-text deltas to a KV bridge for AdRetrieval; when AdRetrieval returns, an ad event is injected.
Table of Contents
Setup & Configuration
Supported Language Versions
This SDK is compatible with the following versions: TypeScript >= 4.8.4
Installation
To get started with the SDK, we recommend installing using npm:
npm install echo apiAuthentication
Access Token Authentication
The EchoApi API uses an Access Token for authentication.
This token must be provided to authenticate your requests to the API.
Setting the Access Token
When you initialize the SDK, you can set the access token as follows:
const sdk = new EchoApi({ token: 'YOUR_TOKEN' });If you need to set or update the access token after initializing the SDK, you can use:
const sdk = new EchoApi();
sdk.token = 'YOUR_TOKEN';Setting a Custom Timeout
You can set a custom timeout for the SDK's HTTP requests as follows:
const echoApi = new EchoApi({ timeout: 10000 });Sample Usage
Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint:
import { EchoApi } from 'echo api';
(async () => {
const echoApi = new EchoApi({
token: 'YOUR_TOKEN',
});
const { data } = await echoApi.models.listModels();
console.log(data);
})();Services
The SDK provides various services to interact with the API.
| Name | | :------------------------------------------------------- | | AuthService | | ModelsService | | ChatService | | HealthService |
Models
The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently.
| Name | Description | | :------------------------------------------------------- | :---------- | | AuthRequest | | | AuthResponse | | | Error | | | ModelsResponse | | | ModelItem | | | RelayRequest | | | Message | | | Error | | | HealthResponse | |
