You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: async-openai/MIDDLEWARE.md
+6-11Lines changed: 6 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,22 +91,17 @@ Custom tower retry policies can call `middleware::retry::should_retry` to reuse
91
91
92
92
On native targets retries wait using `tokio::time::sleep`. On WASM retries are immediate.
93
93
94
-
## Native and WASM bounds
95
-
96
-
The conceptual middleware boundary stays the same; only the platform thread-safety bounds differ.
94
+
## Error Handling
97
95
98
-
On native targets, middleware services installed with `Client::with_http_service` must be `Send + Sync + 'static` and return `Send + 'static` futures.
96
+
`OpenAIError::Boxed` is available only when the `middleware` feature is enabled.
99
97
100
-
On WASM targets, middleware services and futures must be `'static`.
98
+
Custom middleware services installed with `Client::with_http_service` may use any error type that implements `Into<OpenAIError>`. This lets middleware preserve structured errors when it has a dedicated `OpenAIError` conversion.
101
99
102
-
## Bring Your Own Types Interaction
100
+
Tower's `BoxError` converts into `OpenAIError::Boxed`, which is useful for generic tower layers whose concrete error type is erased. Callers can still downcast the boxed error when they know the original error type.
103
101
104
-
With the `byot` feature, generated `*_byot` methods keep minimal trait bounds. When `middleware` feature is enabled additional `MiddlewareInput` bounds are added based on native or WASM targets so the input can be stored long enough to rebuild a fresh request for retries.
105
102
106
-
## Error Handling
103
+
## Bring Your Own Types Interaction
107
104
108
-
`OpenAIError::Boxed` is available only when the `middleware` feature is enabled.
105
+
With the `byot` feature, generated `*_byot` methods keep the same minimal trait bounds with or without middleware. JSON request bodies are serialized before they enter the replayable middleware request factory; multipart request bodies use the client-level replay bounds required by form handling.
109
106
110
-
Custom middleware services installed with `Client::with_http_service` may use any error type that implements `Into<OpenAIError>`. This lets middleware preserve structured errors when it has a dedicated `OpenAIError` conversion.
111
107
112
-
Tower's `BoxError` converts into `OpenAIError::Boxed`, which is useful for generic tower layers whose concrete error type is erased. Callers can still downcast the boxed error when they know the original error type.
Copy file name to clipboardExpand all lines: async-openai/README.md
+22-20Lines changed: 22 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,10 @@
19
19
20
20
## Overview
21
21
22
-
`async-openai` is an unofficial Rust library for OpenAI, based on [OpenAI OpenAPI spec](https://github.com/openai/openai-openapi). It implements all APIs from the spec:
22
+
`async-openai` is an unofficial Rust library for OpenAI, based on [OpenAI OpenAPI spec](https://github.com/openai/openai-openapi). It implements all APIs from the spec.
23
+
24
+
<details>
25
+
<summary>Feature Flags</summary>
23
26
24
27
| What | APIs | Crate Feature Flags |
25
28
|---|---|---|
@@ -36,16 +39,18 @@
36
39
|**Administration**| Admin API Keys, Invites, Users, Groups, Roles, Role assignments, Projects, Project users, Project groups, Project service accounts, Project API keys, Project rate limits, Audit logs, Usage, Certificates |`administration`|
37
40
|**Legacy**| Completions |`completions`|
38
41
39
-
Features that makes `async-openai` unique:
42
+
</details>
43
+
44
+
40
45
- Bring your own custom types for Request or Response objects.
41
-
- SSE streaming on available APIs.
42
-
- Customize path, query and headers per request; customize path and headers globally (for all requests).
43
-
- Requests (except SSE streaming) including form submissions are retried with exponential backoff when [rate limited](https://platform.openai.com/docs/guides/rate-limits).
46
+
- Requests are retried with exponential backoff when [rate limited](https://platform.openai.com/docs/guides/rate-limits).
44
47
- Ergonomic builder pattern for all request objects.
45
-
- Granular feature flags to enable any types or apis: good for faster compilation and crate reuse.
46
-
- Microsoft Azure OpenAI Service (only for APIs matching OpenAI spec).
47
-
- WASM (doesn't support streaming yet)
48
-
- Middleware support with [tower](https://crates.io/crates/tower) ecosystem
48
+
- SSE streaming.
49
+
- Customize path, query and headers per request or for all requests.
50
+
- Granular feature flags to enable any types or apis.
51
+
- Microsoft Azure OpenAI Service.
52
+
- WASM.
53
+
- Middleware support with [tower](https://crates.io/crates/tower) ecosystem.
Support for webhook includes event types, signature verification, and building webhook events from payloads.
241
+
240
242
## Middleware
241
243
242
244
Middleware is supported via Tower ecosystem, which can be enabled with `middleware` feature. See [middleware](https://github.com/64bit/async-openai/blob/main/async-openai/MIDDLEWARE.md) for more detail.
0 commit comments