XRequest
Import |
Source |
Docs |
When To Use#
Initiate a fetch request to LLMs that comply with OpenAI standards.
Examples #
Request Log
Status - |
Update Times 0 |
Loading...
Request Log
Status - |
Update Times 0 |
Loading...
Mock Custom Protocol Log
Loading...
baseURL: https://api.example.com/chat
model: gpt-3.5-turbo
dangerouslyApiKey: Bearer sk-your-dangerouslyApiKey
Request Log
Status - |
Update Times 0 |
Loading...
Request Log request null
Status - |
Update Times 0 |
Loading...
API#
XRequestOptions#
| Property | Description | Type | Default |
|---|---|---|---|
baseURL | Base URL for the API request | string | - |
model | Model name, e.g., 'gpt-3.5-turbo' | string | - |
dangerouslyApiKey | Note: dangerouslyApiKey presents security risks | string | - |
fetch | Optional custom fetch function for making requests | fetch | - |
XRequestFunction#
type XRequestFunction<Input = Record<PropertyKey, any>, Output = Record<string, string>> = (
params: XRequestParams & Input,
callbacks: XRequestCallbacks<Output>,
transformStream?: XStreamOptions<Output>['transformStream']
) => Promise<void>;
XRequestParams#
| Property | Description | Type | Default |
|---|---|---|---|
model | The model to be used for generating responses | string | - |
messages | An array of message objects, each containing a role and content | Record<PropertyKey, any>[] | - |
stream | Indicates whether to use streaming for the response | boolean | false |
XRequestCallbacks#
| Property | Description | Type | Default |
|---|---|---|---|
onSuccess | Callback for successful | (messages: Output[]) => void | - |
onError | Callback for error handling | (error: Error) => void | - |
onUpdate | Callback for message updates | (message: Output) => void | - |
onStream | Callback for stream controller | (controller: AbortController) => void | - |
transformStream | Optional transform function for processing stream data | XStreamOptions<Output>['transformStream'] | - |