{"id":30656013,"url":"https://github.com/nbursa/tetherai","last_synced_at":"2026-01-20T17:33:16.960Z","repository":{"id":311450576,"uuid":"1043737172","full_name":"nbursa/TetherAI","owner":"nbursa","description":"Modular TypeScript SDK for AI providers - streaming-first, retry \u0026 fallback middleware.","archived":false,"fork":false,"pushed_at":"2025-08-24T19:34:30.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-24T19:36:01.796Z","etag":null,"topics":["ai","edge","middleware","nextjs","openai","sdk","streaming","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@tetherai/openai","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nbursa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-24T14:11:35.000Z","updated_at":"2025-08-24T19:34:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"aa72ab3d-eac0-4dc6-9f21-4f1b34c9a121","html_url":"https://github.com/nbursa/TetherAI","commit_stats":null,"previous_names":["nbursa/tetherai"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/nbursa/TetherAI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbursa%2FTetherAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbursa%2FTetherAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbursa%2FTetherAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbursa%2FTetherAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nbursa","download_url":"https://codeload.github.com/nbursa/TetherAI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbursa%2FTetherAI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272965497,"owners_count":25023071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","edge","middleware","nextjs","openai","sdk","streaming","typescript"],"created_at":"2025-08-31T10:03:28.502Z","updated_at":"2026-01-20T17:33:16.947Z","avatar_url":"https://github.com/nbursa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TetherAI\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![Build](https://github.com/nbursa/TetherAI/actions/workflows/ci.yml/badge.svg)](https://github.com/nbursa/TetherAI/actions)\n\nTetherAI is a **standalone-first** TypeScript platform for integrating different AI providers.  \nEach package is **completely self-contained** with no external dependencies - includes all types, utilities, and middleware built-in.  \nThink of it as _\"Express for AI providers\" with everything included_.\n\n## What's New\n\n- **Standalone Packages**: Each provider is completely independent\n- **Enhanced Configuration**: Timeouts, custom endpoints, organization support\n- **Advanced Middleware**: Retry with exponential backoff, multi-provider fallback\n- **Rich Error Handling**: Provider-specific error classes with HTTP status codes\n- **Edge Runtime**: Works everywhere from Node.js to Cloudflare Workers\n- **SSE Utilities**: Built-in Server-Sent Events parsing\n- **Multiple Providers**: OpenAI, Anthropic, Mistral AI, Grok AI, and Local LLM support\n\n## Architecture\n\n- `packages/provider/` – **standalone provider packages** (no external deps)\n  - `@tetherai/openai` – OpenAI provider\n  - `@tetherai/anthropic` – Anthropic provider  \n  - `@tetherai/mistral` – Mistral AI provider\n  - `@tetherai/grok` – Grok AI (xAI) provider\n  - `@tetherai/local` – Local LLM provider (Ollama, LM Studio, etc.)\n- `packages/shared/` – internal development tooling (not published)\n- `examples/` – demo applications (Next.js, Node.js, etc.)\n\n## Quick Start\n\n1. **Install any provider package** (everything included):\n\n   ```bash\n   npm install @tetherai/openai\n   # or\n   npm install @tetherai/anthropic\n   # or\n   npm install @tetherai/mistral\n   # or\n   npm install @tetherai/grok\n   # or\n   npm install @tetherai/local\n   ```\n\n2. **Run an example locally**:\n\n   a. **Next.js example:**\n\n   ```bash\n   cd examples/nextjs\n   npm install\n   export OPENAI_API_KEY=sk-...\n   npm run dev\n   ```\n\n   b. **Node.js example:**\n\n   ```bash\n   cd examples/node\n   npm install\n   export OPENAI_API_KEY=sk-...\n   npm run dev\n   ```\n\n3. **Try it out**:\n\n   a. **Next.js:** Open \u003chttp://localhost:3000\u003e\n\n   b. **Node.js:** POST to \u003chttp://localhost:8787/chat\u003e:\n\n      ```bash\n      curl -N -X POST http://localhost:8787/chat \\\n        -H \"Content-Type: application/json\" \\\n        -d '{\"model\":\"gpt-4o-mini\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello!\"}]}'\n      ```\n\n## Usage\n\n### Create a Provider\n\n```ts\nimport { openAI } from \"@tetherai/openai\";\n\nconst provider = openAI({ \n  apiKey: process.env.OPENAI_API_KEY!,\n  timeout: 30000,        // 30 second timeout\n  organization: process.env.OPENAI_ORG_ID  // Organization support\n});\n```\n\n### Add Retry and Fallback\n\n```ts\nimport { withRetry, withFallback } from \"@tetherai/openai\";\nimport { anthropic } from \"@tetherai/anthropic\";\nimport { mistral } from \"@tetherai/mistral\";\n\nconst resilientProvider = withFallback([\n  withRetry(openAI({ apiKey: process.env.OPENAI_API_KEY! }), { \n    retries: 3,\n    baseMs: 300,\n    factor: 2,\n    jitter: true\n  }),\n  withRetry(anthropic({ apiKey: process.env.ANTHROPIC_API_KEY! }), { \n    retries: 2 \n  }),\n  withRetry(mistral({ apiKey: process.env.MISTRAL_API_KEY! }), { \n    retries: 2 \n  })\n], {\n  onFallback: (error, providerIndex) =\u003e {\n    console.log(`Provider ${providerIndex} failed, trying next...`);\n  }\n});\n```\n\n### Stream a Chat Completion\n\n```ts\nimport type { ChatRequest } from \"@tetherai/openai\";\n\nconst req: ChatRequest = {\n  model: \"gpt-4o-mini\",\n  messages: [{ role: \"user\", content: \"Tell me a joke.\" }],\n};\n\nfor await (const chunk of resilientProvider.streamChat(req)) {\n  if (chunk.done) break;\n  process.stdout.write(chunk.delta);\n}\n```\n\n## Features\n\n- **Streaming-First**: Token stream via AsyncIterable with SSE support\n- **Retry Middleware**: Automatic retry with exponential backoff on transient errors (429, 5xx)\n- **Fallback Middleware**: Multi-provider failover with configurable callbacks\n- **Edge Compatible**: Built on fetch, ReadableStream, works in all modern runtimes\n- **Strict TypeScript**: 100% typed, zero `any` types\n- **Rich Error Handling**: Provider-specific error classes with HTTP status codes\n- **Highly Configurable**: Timeouts, custom endpoints, organization support\n\n## Available Providers\n\n### [@tetherai/openai](https://www.npmjs.com/package/@tetherai/openai)\n\n**Standalone OpenAI provider** - Everything you need in one package!\n\n- **Zero Dependencies**: Everything included, no external packages needed\n- **Production Ready**: Built-in retry, fallback, and error handling\n- **Highly Configurable**: Timeouts, custom endpoints, organization support\n- **Edge Compatible**: Works everywhere from Node.js to Cloudflare Workers\n\n[![npm version](https://img.shields.io/npm/v/@tetherai/openai.svg)](https://www.npmjs.com/package/@tetherai/openai)\n[![npm downloads](https://img.shields.io/npm/dm/@tetherai/openai.svg)](https://www.npmjs.com/package/@tetherai/openai)\n\n[Full README](https://github.com/nbursa/TetherAI/blob/main/packages/provider/openai/README.md)\n\n### [@tetherai/anthropic](https://www.npmjs.com/package/@tetherai/anthropic)\n\n**Standalone Anthropic provider** - Everything you need in one package!\n\n- **Zero Dependencies**: Everything included, no external packages needed\n- **Production Ready**: Built-in retry, fallback, and error handling\n- **Highly Configurable**: Timeouts, custom endpoints, API version control\n- **Edge Compatible**: Works everywhere from Node.js to Cloudflare Workers\n\n[![npm version](https://img.shields.io/npm/v/@tetherai/anthropic.svg)](https://www.npmjs.com/package/@tetherai/anthropic)\n[![npm downloads](https://img.shields.io/npm/dm/@tetherai/anthropic.svg)](https://www.npmjs.com/package/@tetherai/anthropic)\n\n[Full README](https://github.com/nbursa/TetherAI/blob/main/packages/provider/anthropic/README.md)\n\n### [@tetherai/mistral](https://www.npmjs.com/package/@tetherai/mistral)\n\n**Standalone Mistral provider** - Everything you need in one package!\n\n- **Zero Dependencies**: Everything included, no external packages needed\n- **Production Ready**: Built-in retry, fallback, and error handling\n- **Highly Configurable**: Timeouts, custom endpoints, API version control\n- **Edge Compatible**: Works everywhere from Node.js to Cloudflare Workers\n\n[![npm version](https://img.shields.io/npm/v/@tetherai/mistral.svg)](https://www.npmjs.com/package/@tetherai/mistral)\n[![npm downloads](https://img.shields.io/npm/dm/@tetherai/mistral.svg)](https://www.npmjs.com/package/@tetherai/mistral)\n\n[Full README](https://github.com/nbursa/TetherAI/blob/main/packages/provider/mistral/README.md)\n\n### [@tetherai/grok](https://www.npmjs.com/package/@tetherai/grok)\n\n**Standalone Grok AI (xAI) provider** - Everything you need in one package!\n\n- **Zero Dependencies**: Everything included, no external packages needed\n- **Production Ready**: Built-in retry, fallback, and error handling\n- **Highly Configurable**: Timeouts, custom endpoints, API version control\n- **Edge Compatible**: Works everywhere from Node.js to Cloudflare Workers\n- **xAI Integration**: Native support for Grok models (grok-beta, grok-beta-vision, etc.)\n\n[![npm version](https://img.shields.io/npm/v/@tetherai/grok.svg)](https://www.npmjs.com/package/@tetherai/grok)\n[![npm downloads](https://img.shields.io/npm/dm/@tetherai/grok.svg)](https://www.npmjs.com/package/@tetherai/grok)\n\n[Full README](https://github.com/nbursa/TetherAI/blob/main/packages/provider/grok/README.md)\n\n### [@tetherai/local](https://www.npmjs.com/package/@tetherai/local)\n\n**Standalone Local LLM provider** - Everything you need in one package!\n\n- **Zero Dependencies**: Everything included, no external packages needed\n- **Production Ready**: Built-in retry, fallback, and error handling\n- **Highly Configurable**: Timeouts, custom endpoints, API version control\n- **Edge Compatible**: Works everywhere from Node.js to Cloudflare Workers\n- **Local Endpoint Support**: Ollama, LM Studio, and custom OpenAI-compatible APIs\n\n[![npm version](https://img.shields.io/npm/v/@tetherai/local.svg)](https://www.npmjs.com/package/@tetherai/local)\n[![npm downloads](https://img.shields.io/npm/dm/@tetherai/local.svg)](https://www.npmjs.com/package/@tetherai/local)\n\n[Full README](https://github.com/nbursa/TetherAI/blob/main/packages/provider/local/README.md)\n\n## Why TetherAI?\n\n- **Zero Dependencies**: Each package is completely standalone\n- **Production Ready**: Built-in retry, fallback, and error handling\n- **Highly Configurable**: Timeouts, custom endpoints, organization support\n- **Edge Compatible**: Works everywhere from Node.js to Cloudflare Workers\n- **Streaming First**: Real-time token streaming with AsyncIterable\n- **Enterprise Ready**: Organization support, custom fetch, comprehensive error handling\n\n## Examples\n\nSee [examples/](https://github.com/nbursa/TetherAI/tree/main/examples) for ready-to-run demos:\n\n- **Next.js Chat** – Full Edge runtime chat UI with streaming and retry/fallback middleware\n- **Node.js Server** – Minimal backend HTTP server exposing `/chat` endpoint with SSE streaming\n\n## Development\n\n### Building\n\n```bash\n# Build all providers\nnpm run build:providers\n\n# Build individual providers\nnpm run build:openai\nnpm run build:anthropic\n\n# Copy shared files to providers\nnpm run copy-shared\n```\n\n### Testing\n\n```bash\n# Test standalone providers\nnode test-standalone.js\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbursa%2Ftetherai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnbursa%2Ftetherai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbursa%2Ftetherai/lists"}