Remix

Set up the inference shell proxy in Remix applications.


Installation

bash
1npm install @inferencesh/sdk

Basic Setup

Create app/routes/api.inference.proxy.ts:

typescript
1import { createHandler } from "@inferencesh/sdk/proxy/remix";23const handler = createHandler({ allowedEndpoints: ["my-team/*"] });45// Handle both GET and POST requests6export const loader = handler;7export const action = handler;

The proxy forwards app runs and agent chats only; allowedEndpoints limits them to your apps and agents. See options.

[!WARNING] Anyone who can reach the proxy route runs apps and agents on your API key. In production set allowedEndpoints and isAuthenticated (see what the proxy forwards), and create a Run only key in a workspace that holds nothing else.


Environment Variable

Add to your .env:

bash
1INFERENCE_API_KEY="inf_your_key_here"

Client Configuration

typescript
1import { inference } from "@inferencesh/sdk";23const client = inference({4  proxyUrl: "/api/inference/proxy"5});67export async function generateImage(prompt: string) {8  const result = await client.run({9    app: "infsh/flux",10    input: { prompt }11  });12  13  return result.output;14}

With Authentication

isAuthenticated gets the Request; false answers 401:

typescript
1import { createHandler } from "@inferencesh/sdk/proxy/remix";2import { getSession } from "~/lib/session.server";34const handler = createHandler({5  allowedEndpoints: ["my-team/*"],6  isAuthenticated: async (request) => {7    const session = await getSession(request.headers.get("Cookie"));8    return Boolean(session.userId);9  },10});1112export const loader = handler;13export const action = handler;

Custom API Key Resolution

typescript
1import { createHandler } from "@inferencesh/sdk/proxy/remix";23const handler = createHandler({4  resolveApiKey: async () => {5    // Load from secrets manager6    return await getSecret("INFERENCE_API_KEY");7  }8});910export const loader = handler;11export const action = handler;

Route Naming

Remix uses file-based routing with dots as path separators:

FileURL
api.inference.proxy.ts/api/inference/proxy
api_.inference.proxy.ts/api/inference/proxy (no layout)

Streaming

The Remix handler supports streaming responses for real-time task updates.

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.