@hebo-ai/gateway 0.9.4 → 0.10.0
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 +23 -12
- package/dist/endpoints/chat-completions/schema.d.ts +289 -57
- package/dist/endpoints/conversations/schema.d.ts +200 -40
- package/dist/endpoints/messages/converters.d.ts +24 -0
- package/dist/endpoints/messages/converters.js +661 -0
- package/dist/endpoints/messages/handler.d.ts +2 -0
- package/dist/endpoints/messages/handler.js +142 -0
- package/dist/endpoints/messages/index.d.ts +4 -0
- package/dist/endpoints/messages/index.js +4 -0
- package/dist/endpoints/messages/otel.d.ts +6 -0
- package/dist/endpoints/messages/otel.js +171 -0
- package/dist/endpoints/messages/schema.d.ts +623 -0
- package/dist/endpoints/messages/schema.js +185 -0
- package/dist/endpoints/responses/schema.d.ts +237 -45
- package/dist/endpoints/shared/schema.d.ts +23 -2
- package/dist/endpoints/shared/schema.js +3 -1
- package/dist/errors/anthropic.d.ts +10 -0
- package/dist/errors/anthropic.js +46 -0
- package/dist/errors/openai.js +1 -10
- package/dist/errors/utils.d.ts +3 -1
- package/dist/errors/utils.js +9 -0
- package/dist/gateway.d.ts +1 -0
- package/dist/gateway.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lifecycle.js +12 -3
- package/dist/models/anthropic/middleware.js +5 -0
- package/dist/providers/bedrock/middleware.js +16 -1
- package/dist/providers/registry.d.ts +1 -1
- package/dist/types.d.ts +6 -5
- package/dist/utils/response.d.ts +1 -0
- package/dist/utils/stream.d.ts +1 -0
- package/dist/utils/stream.js +10 -3
- package/package.json +14 -3
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ Learn more in our blog post: [Yet Another AI Gateway?](https://hebo.ai/blog/2601
|
|
|
12
12
|
|
|
13
13
|
## 🍌 Features
|
|
14
14
|
|
|
15
|
-
- 🌐 OpenAI-compatible
|
|
16
|
-
-
|
|
17
|
-
-
|
|
15
|
+
- 🌐 OpenAI-compatible `/chat/completions`, `/embeddings` & `/models` endpoints.
|
|
16
|
+
- 💬 Open Responses `/responses` endpoint (stateless), including /conversations.
|
|
17
|
+
- 🗨️ Anthropic-compatible `/messages` endpoint.
|
|
18
18
|
- 🔌 Integrate into your existing Hono, Elysia, Next.js & TanStack apps.
|
|
19
19
|
- 🧩 Provider registry compatible with Vercel AI SDK providers.
|
|
20
20
|
- 🧭 Canonical model IDs and parameter naming across providers.
|
|
@@ -40,7 +40,7 @@ bun install @hebo-ai/gateway
|
|
|
40
40
|
- Runtime Support
|
|
41
41
|
- [Vercel Edge](#vercel-edge) | [Cloudflare Workers](#cloudflare-workers) | [Deno Deploy](#deno-deploy) | [AWS Lambda](#aws-lambda)
|
|
42
42
|
- Endpoints
|
|
43
|
-
- [/chat/completions](#chatcompletions) | [/embeddings](#embeddings) | [/models](#models) | [/responses](#responses) | [/conversations](#conversations)
|
|
43
|
+
- [/chat/completions](#chatcompletions) | [/embeddings](#embeddings) | [/models](#models) | [/responses](#responses) | [/messages](#messages) | [/conversations](#conversations)
|
|
44
44
|
- OpenAI Extensions
|
|
45
45
|
- [Reasoning](#reasoning) | [Service Tier](#service-tier) | [Prompt Caching](#prompt-caching) | [Compressed Requests](#compressed-requests)
|
|
46
46
|
- Advanced Usage
|
|
@@ -584,7 +584,7 @@ export const handler = awsLambdaEventHandler({
|
|
|
584
584
|
|
|
585
585
|
## 🚀 Endpoints
|
|
586
586
|
|
|
587
|
-
Hebo Gateway provides
|
|
587
|
+
Hebo Gateway provides OpenAI-, OpenResponses- and Anthropic-compatible endpoints.
|
|
588
588
|
|
|
589
589
|
### `/chat/completions`
|
|
590
590
|
|
|
@@ -665,6 +665,19 @@ It supports:
|
|
|
665
665
|
- **`include`**: Selective response fields (e.g., `logprobs`, `reasoning.encrypted_content`, and tool-specific outputs).
|
|
666
666
|
- **`stream_options.include_obfuscation`**: Normalizing payload sizes to mitigate side-channel attacks.
|
|
667
667
|
|
|
668
|
+
### `/messages`
|
|
669
|
+
|
|
670
|
+
Hebo Gateway provides a `/messages` endpoint compatible with the [Anthropic Messages API](https://docs.anthropic.com/en/api/messages).
|
|
671
|
+
|
|
672
|
+
Official documentation: [Anthropic Messages API Reference](https://docs.anthropic.com/en/api/messages)
|
|
673
|
+
|
|
674
|
+
It supports:
|
|
675
|
+
|
|
676
|
+
- The same models, providers, hooks, and extensions as `/chat/completions`.
|
|
677
|
+
- Anthropic Messages API request/response format.
|
|
678
|
+
- Streaming responses.
|
|
679
|
+
- Tool use and multimodal inputs.
|
|
680
|
+
|
|
668
681
|
### `/conversations`
|
|
669
682
|
|
|
670
683
|
Hebo Gateway provides a dedicated `/conversations` endpoint for managing persistent conversation state. It is designed as an extension of the [OpenAI Conversations API](https://developers.openai.com/api/reference/resources/conversations/methods/create) and supports standard CRUD operations alongside advanced listing with metadata filtering.
|
|
@@ -792,10 +805,9 @@ Provider behavior:
|
|
|
792
805
|
- **Google Gemini**: maps `cached_content` to Gemini `cachedContent`.
|
|
793
806
|
- **Amazon Nova (Bedrock)**: maps `cache_control` to Bedrock `cachePoints` and inserts an automatic cache point on a stable prefix when none is provided.
|
|
794
807
|
|
|
795
|
-
|
|
796
808
|
### Compressed Requests
|
|
797
809
|
|
|
798
|
-
The gateway supports gzip and deflate compressed request bodies via the Web Compression Streams API. The `maxBodySize` option controls the maximum
|
|
810
|
+
The gateway supports gzip and deflate compressed request bodies via the Web Compression Streams API. The `maxBodySize` option controls the maximum _decompressed_ body size for these compressed requests, protecting against gzip bombs and oversized payloads.
|
|
799
811
|
|
|
800
812
|
```ts
|
|
801
813
|
import { gateway } from "@hebo-ai/gateway";
|
|
@@ -811,7 +823,7 @@ const gw = gateway({
|
|
|
811
823
|
Compressed requests that exceed this limit after decompression receive an HTTP `413 Payload Too Large` response. Unsupported `Content-Encoding` values return HTTP `415 Unsupported Media Type`.
|
|
812
824
|
|
|
813
825
|
> [!IMPORTANT]
|
|
814
|
-
> **Plain (uncompressed) request body size limits** are
|
|
826
|
+
> **Plain (uncompressed) request body size limits** are _not_ enforced by the gateway — they should be configured at the framework or server level. The gateway only enforces `maxBodySize` on decompressed output, since the framework cannot know the decompressed size ahead of time.
|
|
815
827
|
>
|
|
816
828
|
> Framework-level configuration examples:
|
|
817
829
|
>
|
|
@@ -1122,10 +1134,9 @@ Non-streaming versions are available via `toChatCompletionsResponse`. Equivalent
|
|
|
1122
1134
|
> [!TIP]
|
|
1123
1135
|
> Since Zod v4.3 you can generate a JSON Schema from any zod object by calling `z.toJSONSchema(...)`. This is useful for producing OpenAPI documentation from the same source of truth.
|
|
1124
1136
|
|
|
1125
|
-
|
|
1126
1137
|
### Request Body Size
|
|
1127
1138
|
|
|
1128
|
-
The gateway supports gzip and deflate compressed request bodies via the Web Compression Streams API. The `maxBodySize` option controls the maximum
|
|
1139
|
+
The gateway supports gzip and deflate compressed request bodies via the Web Compression Streams API. The `maxBodySize` option controls the maximum _decompressed_ body size for these compressed requests, protecting against gzip bombs and oversized payloads.
|
|
1129
1140
|
|
|
1130
1141
|
```ts
|
|
1131
1142
|
import { gateway } from "@hebo-ai/gateway";
|
|
@@ -1141,7 +1152,7 @@ const gw = gateway({
|
|
|
1141
1152
|
Compressed requests that exceed this limit after decompression receive an HTTP `413 Payload Too Large` response. Unsupported `Content-Encoding` values return HTTP `415 Unsupported Media Type`.
|
|
1142
1153
|
|
|
1143
1154
|
> [!IMPORTANT]
|
|
1144
|
-
> **Plain (uncompressed) request body size limits** are
|
|
1155
|
+
> **Plain (uncompressed) request body size limits** are _not_ enforced by the gateway — they should be configured at the framework or server level. The gateway only enforces `maxBodySize` on decompressed output, since the framework cannot know the decompressed size ahead of time.
|
|
1145
1156
|
>
|
|
1146
1157
|
> Framework-level configuration examples:
|
|
1147
1158
|
>
|
|
@@ -1150,4 +1161,4 @@ Compressed requests that exceed this limit after decompression receive an HTTP `
|
|
|
1150
1161
|
> - **Hono** — [`bodyLimit` middleware](https://hono.dev/docs/middleware/builtin/body-limit): `app.use(bodyLimit({ maxSize: 10 * 1024 * 1024 }))`
|
|
1151
1162
|
> - **Express** — [`express.json({ limit: '10mb' })`](https://expressjs.com/en/api.html#express.json)
|
|
1152
1163
|
> - **Fastify** — [`fastify({ bodyLimit: 10485760 })`](https://fastify.dev/docs/latest/Reference/Server/#bodylimit)
|
|
1153
|
-
> - **Node.js `http`** — [`server.maxRequestSize`](https://nodejs.org/api/http.html) (v22.6+), or use a reverse proxy like nginx (`client_max_body_size 10m`)
|
|
1164
|
+
> - **Node.js `http`** — [`server.maxRequestSize`](https://nodejs.org/api/http.html) (v22.6+), or use a reverse proxy like nginx (`client_max_body_size 10m`)
|