# Hono

> Set up the inference shell proxy with Hono for edge and serverless deployments.

**URL:** https://inference.sh/docs/api/sdk/proxy/hono
**Last updated:** 2026-10-11

---

Set up the inference shell proxy with Hono for edge and serverless deployments.

---

## Installation

```bash
npm install @inferencesh/sdk hono
```

---

## Basic Setup

```typescript
import { Hono } from "hono";
import { createHandler } from "@inferencesh/sdk/proxy/hono";

const app = new Hono();
const proxyHandler = createHandler({
  allowedEndpoints: ["my-team/*"],
  isAuthenticated: async (c) => Boolean(await getSession(c)), // your session check
});

app.all("/api/inference/proxy", proxyHandler);

export default app;
```

The proxy forwards app runs and agent chats only; `allowedEndpoints` limits them to your apps and agents, and `isAuthenticated` gets the Hono `Context`. See [options](/docs/api/sdk/server-proxy#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](/docs/api/sdk/server-proxy#what-the-proxy-forwards)), and create a **Run only** key in a workspace that holds nothing else.

---

## Environment Variable

Set your API key in your runtime environment:

```bash
# Cloudflare Workers (wrangler.toml)
[vars]
INFERENCE_API_KEY = "inf_your_key_here"
```

```bash
# Deno Deploy
export INFERENCE_API_KEY="inf_your_key_here"
```

---

## Cloudflare Workers

```typescript
// src/index.ts
import { Hono } from "hono";
import { createHandler } from "@inferencesh/sdk/proxy/hono";

const app = new Hono();

const proxyHandler = createHandler({ allowedEndpoints: ["my-team/*"] });
app.all("/api/inference/proxy", proxyHandler);

export default app;
```

Deploy:

```bash
npx wrangler deploy
```

---

## Deno Deploy

```typescript
// main.ts
import { Hono } from "https://deno.land/x/hono/mod.ts";
import { createHandler } from "@inferencesh/sdk/proxy/hono";

const app = new Hono();
const proxyHandler = createHandler({ allowedEndpoints: ["my-team/*"] });

app.all("/api/inference/proxy", proxyHandler);

Deno.serve(app.fetch);
```

---

## Client Configuration

```typescript
import { inference } from "@inferencesh/sdk";

const client = inference({
  proxyUrl: "https://my-worker.workers.dev/api/inference/proxy"
});

const result = await client.run({
  app: "infsh/flux",
  input: { prompt: "A sunset" }
});
```

---

## Custom API Key Resolution

Load from KV, secrets manager, or other sources:

```typescript
import { createHandler } from "@inferencesh/sdk/proxy/hono";

const proxyHandler = createHandler({
  resolveApiKey: async () => {
    // Load from Cloudflare KV, D1, or external service
    const key = await env.SECRETS.get("INFERENCE_API_KEY");
    return key;
  }
});
```

---

## With Middleware

```typescript
import { Hono } from "hono";
import { cors } from "hono/cors";
import { rateLimiter } from "hono-rate-limiter";
import { createHandler } from "@inferencesh/sdk/proxy/hono";

const app = new Hono();

// CORS
app.use("/api/*", cors({
  origin: "https://myapp.com",
  allowHeaders: ["Content-Type", "x-inf-target-url"],
}));

// Rate limiting
app.use("/api/*", rateLimiter({
  windowMs: 15 * 60 * 1000,
  limit: 100,
}));

// Proxy
const proxyHandler = createHandler({ allowedEndpoints: ["my-team/*"] });
app.all("/api/inference/proxy", proxyHandler);

export default app;
```

---

## Why Hono?

Hono is ideal for:
- **Edge deployments** (Cloudflare Workers, Vercel Edge)
- **Minimal bundle size** (~12kb)
- **Fast cold starts** for serverless
- **Multi-runtime support** (Node, Deno, Bun, Workers)
