MCPcopy Create free account
hub / github.com/agentrpc/agentrpc / createApiClient

Function createApiClient

sdk-node/src/create-client.ts:8–43  ·  view source on GitHub ↗
({
  baseUrl,
  machineId,
  clientAbortController,
  apiSecret,
}: {
  baseUrl?: string;
  machineId?: string;
  clientAbortController?: AbortController;
  apiSecret?: string;
})

Source from the content-addressed store, hash-verified

6 * Provides raw API access to the Inferable API.
7 */
8export const createApiClient = ({
9 baseUrl,
10 machineId,
11 clientAbortController,
12 apiSecret,
13}: {
14 baseUrl?: string;
15 machineId?: string;
16 clientAbortController?: AbortController;
17 apiSecret?: string;
18}) =>
19 initClient(contract, {
20 baseUrl: baseUrl ?? "https://api.agentrpc.com",
21 baseHeaders: {
22 "x-machine-sdk-version": SDK_VERSION,
23 "x-machine-sdk-language": "typescript",
24 ...(apiSecret ? { authorization: apiSecret } : {}),
25 ...(machineId ? { "x-machine-id": machineId } : {}),
26 },
27 api: async (args) => {
28 try {
29 return await tsRestFetchApi({
30 ...args,
31 ...(clientAbortController
32 ? { signal: clientAbortController.signal }
33 : {}),
34 });
35 } catch (e) {
36 return {
37 status: -1,
38 headers: new Headers(),
39 body: e,
40 };
41 }
42 },
43 });

Callers 3

bin.tsFile · 0.90
constructorMethod · 0.90
constructorMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected